diff --git a/lightning/src/events/bump_transaction.rs b/lightning/src/events/bump_transaction.rs index 2d44275abb5..accf3ee1a7d 100644 --- a/lightning/src/events/bump_transaction.rs +++ b/lightning/src/events/bump_transaction.rs @@ -37,11 +37,11 @@ use bitcoin::secp256k1; use bitcoin::secp256k1::{PublicKey, Secp256k1}; use bitcoin::secp256k1::ecdsa::Signature; -const EMPTY_SCRIPT_SIG_WEIGHT: u64 = 1 /* empty script_sig */ * WITNESS_SCALE_FACTOR as u64; +pub(crate) const EMPTY_SCRIPT_SIG_WEIGHT: u64 = 1 /* empty script_sig */ * WITNESS_SCALE_FACTOR as u64; const BASE_INPUT_SIZE: u64 = 32 /* txid */ + 4 /* vout */ + 4 /* sequence */; -const BASE_INPUT_WEIGHT: u64 = BASE_INPUT_SIZE * WITNESS_SCALE_FACTOR as u64; +pub(crate) const BASE_INPUT_WEIGHT: u64 = BASE_INPUT_SIZE * WITNESS_SCALE_FACTOR as u64; /// The parameters required to derive a channel signer via [`SignerProvider`]. #[derive(Clone, Debug, PartialEq, Eq)] diff --git a/lightning/src/ln/interactivetxs.rs b/lightning/src/ln/interactivetxs.rs index 7d550fb929c..1e18d762daa 100644 --- a/lightning/src/ln/interactivetxs.rs +++ b/lightning/src/ln/interactivetxs.rs @@ -21,6 +21,7 @@ use crate::sign::EntropySource; use core::ops::Deref; use std::io::sink; use bitcoin::consensus::Encodable; +use crate::events::bump_transaction::{BASE_INPUT_WEIGHT, EMPTY_SCRIPT_SIG_WEIGHT}; use crate::util::ser::TransactionU16LenLimited; /// The number of received `tx_add_input` messages during a negotiation at which point the @@ -320,11 +321,8 @@ impl NegotiationContext { return Err(AbortReason::TransactionTooLarge); } - // TODO: - // - Use existing rust-lightning/rust-bitcoin constants. - // - How do we enforce their fees cover the witness without knowing its expected length? - // - Read eclair's code to see if they do this? - const INPUT_WEIGHT: u64 = (32 + 4 + 4) * WITNESS_SCALE_FACTOR as u64; + // TODO: How do we enforce their fees cover the witness without knowing its expected length? + const INPUT_WEIGHT: u64 = BASE_INPUT_WEIGHT + EMPTY_SCRIPT_SIG_WEIGHT; // - the peer's paid feerate does not meet or exceed the agreed feerate (based on the minimum fee). let counterparty_output_weight_contributed: u64 = counterparty_outputs_contributed.clone().map(|output|