Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #2981 +/- ##
==========================================
+ Coverage 89.42% 90.22% +0.79%
==========================================
Files 117 118 +1
Lines 96290 104849 +8559
Branches 96290 104849 +8559
==========================================
+ Hits 86109 94600 +8491
- Misses 7962 8103 +141
+ Partials 2219 2146 -73 ☔ View full report in Codecov by Sentry. |
|
The most recent commit is a rough exploration of how we might handle splice in and out. Definitely needs polish. |
36e7452 to
f0e1aff
Compare
c8a3b8e to
7192fce
Compare
7192fce to
7423e05
Compare
TheBlueMatt
left a comment
There was a problem hiding this comment.
Just some questions about the last commit, sorry for the delay here.
d653c51 to
e092d93
Compare
e092d93 to
00edcef
Compare
|
Updated last commit. Sorry, there was rebase on diff --git a/lightning/src/ln/interactivetxs.rs b/lightning/src/ln/interactivetxs.rs
index e514ae63..5ba67ff2 100644
--- a/lightning/src/ln/interactivetxs.rs
+++ b/lightning/src/ln/interactivetxs.rs
@@ -182,3 +182,23 @@ impl ConstructedTransaction {
- pub fn build_unsigned_tx(&self) -> Result<Transaction, AbortReason> {
+ pub fn weight(&self) -> u64 {
+ let inputs_weight = self.remote_inputs.iter().chain(self.local_inputs.iter()).fold(
+ 0u64,
+ |weight, InteractiveTxInput { prev_output, .. }| {
+ weight.saturating_add(estimate_input_weight(prev_output))
+ },
+ );
+ let outputs_weight = self.remote_outputs.iter().chain(self.local_outputs.iter()).fold(
+ 0u64,
+ |weight, InteractiveTxOutput { tx_out, .. }| {
+ weight.saturating_add(get_output_weight(&tx_out.script_pubkey))
+ },
+ );
+
+ let tx =
+ Transaction { version: 2, lock_time: self.lock_time, input: vec![], output: vec![] };
+
+ tx.weight().to_wu().saturating_add(inputs_weight).saturating_add(outputs_weight)
+ }
+
+ pub fn into_unsigned_tx(self) -> Result<Transaction, AbortReason> {
// Inputs and outputs must be sorted by serial_id
@@ -194,5 +214,5 @@ impl ConstructedTransaction {
let input: Vec<TxIn> =
- inputs.clone().into_iter().map(|InteractiveTxInput { input, .. }| input).collect();
+ inputs.into_iter().map(|InteractiveTxInput { input, .. }| input).collect();
let output: Vec<TxOut> =
- outputs.clone().into_iter().map(|InteractiveTxOutput { tx_out, .. }| tx_out).collect();
+ outputs.into_iter().map(|InteractiveTxOutput { tx_out, .. }| tx_out).collect();
@@ -219,2 +239,14 @@ struct NegotiationContext {
+pub(crate) fn estimate_input_weight(prev_output: &TxOut) -> u64 {
+ if prev_output.script_pubkey.is_v0_p2wpkh() {
+ P2WPKH_INPUT_WEIGHT_LOWER_BOUND
+ } else if prev_output.script_pubkey.is_v0_p2wsh() {
+ P2WSH_INPUT_WEIGHT_LOWER_BOUND
+ } else if prev_output.script_pubkey.is_v1_p2tr() {
+ P2TR_INPUT_WEIGHT_LOWER_BOUND
+ } else {
+ UNKNOWN_SEGWIT_VERSION_INPUT_WEIGHT_LOWER_BOUND
+ }
+}
+
pub(crate) fn get_output_weight(script_pubkey: &ScriptBuf) -> u64 {
@@ -482,11 +514,3 @@ impl NegotiationContext {
total_inputs_weight =
- total_inputs_weight.saturating_add(if prev_output.script_pubkey.is_v0_p2wpkh() {
- P2WPKH_INPUT_WEIGHT_LOWER_BOUND
- } else if prev_output.script_pubkey.is_v0_p2wsh() {
- P2WSH_INPUT_WEIGHT_LOWER_BOUND
- } else if prev_output.script_pubkey.is_v1_p2tr() {
- P2TR_INPUT_WEIGHT_LOWER_BOUND
- } else {
- UNKNOWN_SEGWIT_VERSION_INPUT_WEIGHT_LOWER_BOUND
- });
+ total_inputs_weight.saturating_add(estimate_input_weight(prev_output));
}
@@ -552,4 +576,3 @@ impl NegotiationContext {
- let unsigned_tx = constructed_tx.build_unsigned_tx()?;
- if unsigned_tx.weight().to_wu() > MAX_STANDARD_TX_WEIGHT as u64 {
+ if constructed_tx.weight() > MAX_STANDARD_TX_WEIGHT as u64 {
return Err(AbortReason::TransactionTooLarge);
@@ -1233,4 +1256,4 @@ mod tests {
assert_eq!(
- final_tx_a.unwrap().build_unsigned_tx().unwrap(),
- final_tx_b.unwrap().build_unsigned_tx().unwrap()
+ final_tx_a.unwrap().into_unsigned_tx().unwrap(),
+ final_tx_b.unwrap().into_unsigned_tx().unwrap()
); |
00edcef to
3ced4e3
Compare
Changes:
|
3ced4e3 to
570ebfa
Compare
Changes:
|
570ebfa to
e857937
Compare
|
Update the last commit message as we no longer split inputs and outputs. |
e857937 to
937f8bf
Compare
Changes:
|
| if counterparty_fees_contributed < required_counterparty_contribution_fee { | ||
| return Err(AbortReason::InsufficientFees); | ||
| } | ||
| self.check_counterparty_fees(remote_inputs_value.saturating_sub(remote_outputs_value))?; |
There was a problem hiding this comment.
Wont this always fail for a splice-out cause the param will be 0 (we ignore self.to_remote_value_satoshis) and check_counterparty_fees will always fail cause the required fee is non-0?
…ght_contributed calc
937f8bf to
59a8bd5
Compare
Changes:
|
|
Gonna go ahead and merge since this only really touches |
Fixes #2955.