Skip to content

Commit 006b5cc

Browse files
committed
ln/test: test_channel_common zero fee commitment anchor handling
1 parent 87b8aca commit 006b5cc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lightning/src/ln/channel.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16509,6 +16509,15 @@ mod tests {
1650916509
let mut htlc_counterparty_sig_iter = holder_commitment_tx.counterparty_htlc_sigs.iter();
1651016510

1651116511
$({
16512+
let (htlc_sighashtype, num_anchors) = if $channel_type_features.supports_anchor_zero_fee_commitments() {
16513+
(EcdsaSighashType::SinglePlusAnyoneCanPay, 1)
16514+
} else if $channel_type_features.supports_anchors_zero_fee_htlc_tx() {
16515+
// Note: we don't currently allow testing trimming regular anchors in this util.
16516+
(EcdsaSighashType::SinglePlusAnyoneCanPay, 2)
16517+
} else {
16518+
(EcdsaSighashType::All, 0)
16519+
};
16520+
1651216521
log_trace!($logger, "verifying htlc {}", $htlc_idx);
1651316522
let remote_signature = Signature::from_der(&<Vec<u8>>::from_hex($counterparty_htlc_sig_hex).unwrap()[..]).unwrap();
1651416523

@@ -16518,7 +16527,6 @@ mod tests {
1651816527
$chan.funding.get_counterparty_selected_contest_delay().unwrap(),
1651916528
&htlc, $channel_type_features, &keys.broadcaster_delayed_payment_key, &keys.revocation_key);
1652016529
let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&htlc, $channel_type_features, &keys);
16521-
let htlc_sighashtype = if $channel_type_features.supports_anchors_zero_fee_htlc_tx() { EcdsaSighashType::SinglePlusAnyoneCanPay } else { EcdsaSighashType::All };
1652216530
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());
1652316531
assert!($secp_ctx.verify_ecdsa(&htlc_sighash, &remote_signature, &keys.countersignatory_htlc_key.to_public_key()).is_ok(), "verify counterparty htlc sig");
1652416532

@@ -16549,7 +16557,6 @@ mod tests {
1654916557
preimage: preimage.clone(),
1655016558
counterparty_sig: *htlc_counterparty_sig,
1655116559
}, &$secp_ctx).unwrap();
16552-
let num_anchors = if $channel_type_features.supports_anchors_zero_fee_htlc_tx() { 2 } else { 0 };
1655316560
assert_eq!(htlc.transaction_output_index, Some($htlc_idx + num_anchors), "output index");
1655416561

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

0 commit comments

Comments
 (0)