From: Arik Sosman Date: Wed, 29 Mar 2023 23:35:05 +0000 (-0700) Subject: Update the `RevokeAndACK` message for Taproot support. X-Git-Tag: v0.0.115~40^2~1 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=15dbe55e676e858ddfde774c9e24a2ede4421ec5;p=rust-lightning Update the `RevokeAndACK` message for Taproot support. --- diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index e2b3fb066..39e07bed8 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -3910,6 +3910,8 @@ impl Channel { channel_id: self.channel_id, per_commitment_secret, next_per_commitment_point, + #[cfg(taproot)] + next_local_nonce: None, } } diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index af547b3af..c77195cfa 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -1470,7 +1470,9 @@ fn test_fee_spike_violation_fails_htlc() { let raa_msg = msgs::RevokeAndACK { channel_id: chan.2, per_commitment_secret: local_secret, - next_per_commitment_point: next_local_point + next_per_commitment_point: next_local_point, + #[cfg(taproot)] + next_local_nonce: None, }; nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &raa_msg); @@ -7498,7 +7500,13 @@ fn test_counterparty_raa_skip_no_crash() { } nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), - &msgs::RevokeAndACK { channel_id, per_commitment_secret, next_per_commitment_point }); + &msgs::RevokeAndACK { + channel_id, + per_commitment_secret, + next_per_commitment_point, + #[cfg(taproot)] + next_local_nonce: None, + }); assert_eq!(check_closed_broadcast!(nodes[1], true).unwrap().data, "Received an unexpected revoke_and_ack"); check_added_monitors!(nodes[1], 1); check_closed_event!(nodes[1], 1, ClosureReason::ProcessingError { err: "Received an unexpected revoke_and_ack".to_string() }); diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 61e18648a..2557454b4 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -442,6 +442,9 @@ pub struct RevokeAndACK { pub per_commitment_secret: [u8; 32], /// The next sender-broadcast commitment transaction's per-commitment point pub next_per_commitment_point: PublicKey, + #[cfg(taproot)] + /// Musig nonce the recipient should use in their next commitment signature message + pub next_local_nonce: Option } /// An [`update_fee`] message to be sent to or received from a peer @@ -1518,12 +1521,22 @@ impl_writeable_msg!(OpenChannel, { (1, channel_type, option), }); +#[cfg(not(taproot))] impl_writeable_msg!(RevokeAndACK, { channel_id, per_commitment_secret, next_per_commitment_point }, {}); +#[cfg(taproot)] +impl_writeable_msg!(RevokeAndACK, { + channel_id, + per_commitment_secret, + next_per_commitment_point +}, { + (4, next_local_nonce, option) +}); + impl_writeable_msg!(Shutdown, { channel_id, scriptpubkey @@ -2753,6 +2766,8 @@ mod tests { channel_id: [2; 32], 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], next_per_commitment_point: pubkey_1, + #[cfg(taproot)] + next_local_nonce: None, }; let encoded_value = raa.encode(); let target_value = hex::decode("02020202020202020202020202020202020202020202020202020202020202020101010101010101010101010101010101010101010101010101010101010101031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f").unwrap();