Skip to content

Commit 538c4cc

Browse files
tankyleoTheBlueMatt
andcommitted
Set version 3 on transactions for HTLC signatures in 0FC channels
Co-authored-by: Matt Corallo <[email protected]>
1 parent 1cef4c3 commit 538c4cc

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

lightning/src/ln/chan_utils.rs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -810,18 +810,30 @@ pub(crate) fn make_funding_redeemscript_from_slices(broadcaster_funding_key: &[u
810810
///
811811
/// Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
812812
/// commitment transaction).
813-
#[rustfmt::skip]
814-
pub fn build_htlc_transaction(commitment_txid: &Txid, feerate_per_kw: u32, contest_delay: u16, htlc: &HTLCOutputInCommitment, channel_type_features: &ChannelTypeFeatures, broadcaster_delayed_payment_key: &DelayedPaymentKey, revocation_key: &RevocationKey) -> Transaction {
815-
let txins= vec![build_htlc_input(commitment_txid, htlc, channel_type_features)];
816-
817-
let mut txouts: Vec<TxOut> = Vec::new();
818-
txouts.push(build_htlc_output(
819-
feerate_per_kw, contest_delay, htlc, channel_type_features,
820-
broadcaster_delayed_payment_key, revocation_key
821-
));
813+
pub fn build_htlc_transaction(
814+
commitment_txid: &Txid, feerate_per_kw: u32, contest_delay: u16, htlc: &HTLCOutputInCommitment,
815+
channel_type_features: &ChannelTypeFeatures,
816+
broadcaster_delayed_payment_key: &DelayedPaymentKey, revocation_key: &RevocationKey,
817+
) -> Transaction {
818+
let txins = vec![build_htlc_input(commitment_txid, htlc, channel_type_features)];
819+
820+
let txouts: Vec<TxOut> = vec![build_htlc_output(
821+
feerate_per_kw,
822+
contest_delay,
823+
htlc,
824+
channel_type_features,
825+
broadcaster_delayed_payment_key,
826+
revocation_key,
827+
)];
828+
829+
let version = if channel_type_features.supports_anchor_zero_fee_commitments() {
830+
Version::non_standard(3)
831+
} else {
832+
Version::TWO
833+
};
822834

823835
Transaction {
824-
version: Version::TWO,
836+
version,
825837
lock_time: LockTime::from_consensus(if htlc.offered { htlc.cltv_expiry } else { 0 }),
826838
input: txins,
827839
output: txouts,

0 commit comments

Comments
 (0)