Update the RevokeAndACK message for Taproot support.

This commit is contained in:
Arik Sosman 2023-03-29 16:35:05 -07:00
parent fe25bbb44e
commit 15dbe55e67
No known key found for this signature in database
GPG Key ID: F4FB5A3366C4D92E
3 changed files with 27 additions and 2 deletions

View File

@ -3910,6 +3910,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
channel_id: self.channel_id,
per_commitment_secret,
next_per_commitment_point,
#[cfg(taproot)]
next_local_nonce: None,
}
}

View File

@ -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() });

View File

@ -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<musig2::types::PublicNonce>
}
/// 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();