Skip to content

Commit 5c515a9

Browse files
committed
Update the RevokeAndACK message for Taproot support.
1 parent e4de0bd commit 5c515a9

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

lightning/src/ln/channel.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3910,6 +3910,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
39103910
channel_id: self.channel_id,
39113911
per_commitment_secret,
39123912
next_per_commitment_point,
3913+
#[cfg(taproot)]
3914+
next_local_nonce: None,
39133915
}
39143916
}
39153917

lightning/src/ln/functional_tests.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,9 @@ fn test_fee_spike_violation_fails_htlc() {
14701470
let raa_msg = msgs::RevokeAndACK {
14711471
channel_id: chan.2,
14721472
per_commitment_secret: local_secret,
1473-
next_per_commitment_point: next_local_point
1473+
next_per_commitment_point: next_local_point,
1474+
#[cfg(taproot)]
1475+
next_local_nonce: None,
14741476
};
14751477
nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &raa_msg);
14761478

@@ -7498,7 +7500,13 @@ fn test_counterparty_raa_skip_no_crash() {
74987500
}
74997501

75007502
nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(),
7501-
&msgs::RevokeAndACK { channel_id, per_commitment_secret, next_per_commitment_point });
7503+
&msgs::RevokeAndACK {
7504+
channel_id,
7505+
per_commitment_secret,
7506+
next_per_commitment_point,
7507+
#[cfg(taproot)]
7508+
next_local_nonce: None,
7509+
});
75027510
assert_eq!(check_closed_broadcast!(nodes[1], true).unwrap().data, "Received an unexpected revoke_and_ack");
75037511
check_added_monitors!(nodes[1], 1);
75047512
check_closed_event!(nodes[1], 1, ClosureReason::ProcessingError { err: "Received an unexpected revoke_and_ack".to_string() });

lightning/src/ln/msgs.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,9 @@ pub struct RevokeAndACK {
442442
pub per_commitment_secret: [u8; 32],
443443
/// The next sender-broadcast commitment transaction's per-commitment point
444444
pub next_per_commitment_point: PublicKey,
445+
#[cfg(taproot)]
446+
/// Musig nonce the recipient should use in their next commitment signature message
447+
pub next_local_nonce: Option<musig2::types::PublicNonce>
445448
}
446449

447450
/// An [`update_fee`] message to be sent to or received from a peer
@@ -1518,12 +1521,22 @@ impl_writeable_msg!(OpenChannel, {
15181521
(1, channel_type, option),
15191522
});
15201523

1524+
#[cfg(not(taproot))]
15211525
impl_writeable_msg!(RevokeAndACK, {
15221526
channel_id,
15231527
per_commitment_secret,
15241528
next_per_commitment_point
15251529
}, {});
15261530

1531+
#[cfg(taproot)]
1532+
impl_writeable_msg!(RevokeAndACK, {
1533+
channel_id,
1534+
per_commitment_secret,
1535+
next_per_commitment_point
1536+
}, {
1537+
(4, next_local_nonce, option)
1538+
});
1539+
15271540
impl_writeable_msg!(Shutdown, {
15281541
channel_id,
15291542
scriptpubkey
@@ -2753,6 +2766,8 @@ mod tests {
27532766
channel_id: [2; 32],
27542767
per_commitment_secret: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
27552768
next_per_commitment_point: pubkey_1,
2769+
#[cfg(taproot)]
2770+
next_local_nonce: None,
27562771
};
27572772
let encoded_value = raa.encode();
27582773
let target_value = hex::decode("02020202020202020202020202020202020202020202020202020202020202020101010101010101010101010101010101010101010101010101010101010101031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f").unwrap();

0 commit comments

Comments
 (0)