Skip to content

Commit c255084

Browse files
committed
Add a note that the anchor transaction in 0FC channels has a max size of 1000vB
1 parent 1d60fa3 commit c255084

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lightning/src/events/bump_transaction/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ pub trait CoinSelectionSource {
364364
/// other claims, implementations must be willing to double spend their UTXOs. The choice of
365365
/// which UTXOs to double spend is left to the implementation, but it must strive to keep the
366366
/// set of other claims being double spent to a minimum.
367+
///
368+
/// Note that in 0FC channels, the anchor transaction has a max size of 1000vB.
367369
fn select_confirmed_utxos<'a>(
368370
&'a self, claim_id: ClaimId, must_spend: Vec<Input>, must_pay_to: &'a [TxOut],
369371
target_feerate_sat_per_1000_weight: u32,
@@ -833,6 +835,12 @@ where
833835
assert!(package_fee >= expected_package_fee);
834836
}
835837

838+
#[cfg(debug_assertions)]
839+
if channel_type.supports_anchor_zero_fee_commitments() {
840+
assert!(commitment_tx.weight().to_wu() < chan_utils::MAX_TRUC_WEIGHT);
841+
assert!(anchor_tx.weight().to_wu() < chan_utils::UNCONF_ANCESTOR_MAX_TRUC_WEIGHT);
842+
}
843+
836844
log_info!(
837845
self.logger,
838846
"Broadcasting anchor transaction {} to bump channel close with txid {}",

lightning/src/ln/chan_utils.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,12 @@ pub const P2A_ANCHOR_INPUT_WITNESS_WEIGHT: u64 = 1;
9696
/// The maximum value of a P2A anchor.
9797
pub const P2A_MAX_VALUE: u64 = 240;
9898

99-
/// The maximum weight of a TRUC transaction, see BIP431
99+
/// The maximum weight of a TRUC transaction, see BIP431.
100100
pub const MAX_TRUC_WEIGHT: u64 = 10_000 * WITNESS_SCALE_FACTOR as u64;
101101

102+
/// The maximum weight of a TRUC transaction with an unconfirmed TRUC ancestor, see BIP431.
103+
pub const UNCONF_ANCESTOR_MAX_TRUC_WEIGHT: u64 = 1000 * WITNESS_SCALE_FACTOR as u64;
104+
102105
/// The maximum weight of any standard transaction, see bitcoin/src/policy/policy.h
103106
pub const MAX_STANDARD_TX_WEIGHT: u64 = 400_000;
104107

0 commit comments

Comments
 (0)