Skip to content

Commit 8d2b31c

Browse files
committed
Add a recommendation to not consolidate UTXOs when bumping 0FC claims
1 parent f4a0cf5 commit 8d2b31c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lightning/src/events/bump_transaction/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,9 @@ pub trait CoinSelectionSource {
366366
/// other claims, implementations must be willing to double spend their UTXOs. The choice of
367367
/// which UTXOs to double spend is left to the implementation, but it must strive to keep the
368368
/// set of other claims being double spent to a minimum.
369+
///
370+
/// In 0FC channels, we strongly recommend you select a single UTXO to bump anchor and HTLC
371+
/// transactions.
369372
fn select_confirmed_utxos<'a>(
370373
&'a self, claim_id: ClaimId, must_spend: Vec<Input>, must_pay_to: &'a [TxOut],
371374
target_feerate_sat_per_1000_weight: u32,
@@ -835,6 +838,12 @@ where
835838
assert!(package_fee >= expected_package_fee);
836839
}
837840

841+
#[cfg(debug_assertions)]
842+
if channel_type.supports_anchor_zero_fee_commitments() {
843+
assert!(commitment_tx.weight().to_wu() < chan_utils::MAX_TRUC_WEIGHT);
844+
assert!(anchor_tx.weight().to_wu() < chan_utils::UNCONF_ANCESTOR_MAX_TRUC_WEIGHT);
845+
}
846+
838847
log_info!(
839848
self.logger,
840849
"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)