Skip to content

Commit 059af71

Browse files
committed
Use constants from ln crate
1 parent 94d8200 commit 059af71

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lightning/src/events/bump_transaction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ use bitcoin::secp256k1;
3737
use bitcoin::secp256k1::{PublicKey, Secp256k1};
3838
use bitcoin::secp256k1::ecdsa::Signature;
3939

40-
const EMPTY_SCRIPT_SIG_WEIGHT: u64 = 1 /* empty script_sig */ * WITNESS_SCALE_FACTOR as u64;
40+
pub(crate) const EMPTY_SCRIPT_SIG_WEIGHT: u64 = 1 /* empty script_sig */ * WITNESS_SCALE_FACTOR as u64;
4141

4242
const BASE_INPUT_SIZE: u64 = 32 /* txid */ + 4 /* vout */ + 4 /* sequence */;
4343

44-
const BASE_INPUT_WEIGHT: u64 = BASE_INPUT_SIZE * WITNESS_SCALE_FACTOR as u64;
44+
pub(crate) const BASE_INPUT_WEIGHT: u64 = BASE_INPUT_SIZE * WITNESS_SCALE_FACTOR as u64;
4545

4646
/// The parameters required to derive a channel signer via [`SignerProvider`].
4747
#[derive(Clone, Debug, PartialEq, Eq)]

lightning/src/ln/interactivetxs.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use crate::sign::EntropySource;
2121
use core::ops::Deref;
2222
use std::io::sink;
2323
use bitcoin::consensus::Encodable;
24+
use crate::events::bump_transaction::{BASE_INPUT_WEIGHT, EMPTY_SCRIPT_SIG_WEIGHT};
2425
use crate::util::ser::TransactionU16LenLimited;
2526

2627
/// The number of received `tx_add_input` messages during a negotiation at which point the
@@ -320,11 +321,8 @@ impl NegotiationContext {
320321
return Err(AbortReason::TransactionTooLarge);
321322
}
322323

323-
// TODO:
324-
// - Use existing rust-lightning/rust-bitcoin constants.
325-
// - How do we enforce their fees cover the witness without knowing its expected length?
326-
// - Read eclair's code to see if they do this?
327-
const INPUT_WEIGHT: u64 = (32 + 4 + 4) * WITNESS_SCALE_FACTOR as u64;
324+
// TODO: How do we enforce their fees cover the witness without knowing its expected length?
325+
const INPUT_WEIGHT: u64 = BASE_INPUT_WEIGHT + EMPTY_SCRIPT_SIG_WEIGHT;
328326

329327
// - the peer's paid feerate does not meet or exceed the agreed feerate (based on the minimum fee).
330328
let counterparty_output_weight_contributed: u64 = counterparty_outputs_contributed.clone().map(|output|

0 commit comments

Comments
 (0)