Skip to content

Commit 0c604dd

Browse files
committed
ln/test: test_channel_common zero fee commitment anchor handling
1 parent 845aa04 commit 0c604dd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lightning/src/ln/channel.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16532,6 +16532,14 @@ mod tests {
1653216532
let mut htlc_counterparty_sig_iter = holder_commitment_tx.counterparty_htlc_sigs.iter();
1653316533

1653416534
$({
16535+
let (htlc_sighashtype, num_anchors) = if $channel_type_features.supports_anchor_zero_fee_commitments() {
16536+
(EcdsaSighashType::SinglePlusAnyoneCanPay, 1)
16537+
} else if $channel_type_features.supports_anchors_zero_fee_htlc_tx() {
16538+
(EcdsaSighashType::SinglePlusAnyoneCanPay, 2)
16539+
} else {
16540+
(EcdsaSighashType::All, 0)
16541+
};
16542+
1653516543
log_trace!($logger, "verifying htlc {}", $htlc_idx);
1653616544
let remote_signature = Signature::from_der(&<Vec<u8>>::from_hex($counterparty_htlc_sig_hex).unwrap()[..]).unwrap();
1653716545

@@ -16541,7 +16549,6 @@ mod tests {
1654116549
$chan.funding.get_counterparty_selected_contest_delay().unwrap(),
1654216550
&htlc, $channel_type_features, &keys.broadcaster_delayed_payment_key, &keys.revocation_key);
1654316551
let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&htlc, $channel_type_features, &keys);
16544-
let htlc_sighashtype = if $channel_type_features.supports_anchors_zero_fee_htlc_tx() { EcdsaSighashType::SinglePlusAnyoneCanPay } else { EcdsaSighashType::All };
1654516552
let htlc_sighash = Message::from_digest(sighash::SighashCache::new(&htlc_tx).p2wsh_signature_hash(0, &htlc_redeemscript, htlc.to_bitcoin_amount(), htlc_sighashtype).unwrap().as_raw_hash().to_byte_array());
1654616553
assert!($secp_ctx.verify_ecdsa(&htlc_sighash, &remote_signature, &keys.countersignatory_htlc_key.to_public_key()).is_ok(), "verify counterparty htlc sig");
1654716554

@@ -16572,7 +16579,6 @@ mod tests {
1657216579
preimage: preimage.clone(),
1657316580
counterparty_sig: *htlc_counterparty_sig,
1657416581
}, &$secp_ctx).unwrap();
16575-
let num_anchors = if $channel_type_features.supports_anchors_zero_fee_htlc_tx() { 2 } else { 0 };
1657616582
assert_eq!(htlc.transaction_output_index, Some($htlc_idx + num_anchors), "output index");
1657716583

1657816584
let signature = Signature::from_der(&<Vec<u8>>::from_hex($htlc_sig_hex).unwrap()[..]).unwrap();

0 commit comments

Comments
 (0)