Skip to content

Commit

Permalink
Use constants from ln crate
Browse files Browse the repository at this point in the history
  • Loading branch information
jurvis committed Sep 15, 2023
1 parent 94d8200 commit 059af71
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lightning/src/events/bump_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
8 changes: 3 additions & 5 deletions lightning/src/ln/interactivetxs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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|
Expand Down

0 comments on commit 059af71

Please sign in to comment.