Skip to content

Commit b56223b

Browse files
committed
Update the AcceptChannel message for Taproot support.
1 parent 17bdf1d commit b56223b

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

lightning/src/ln/channel.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5332,6 +5332,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
53325332
None => Builder::new().into_script(),
53335333
}),
53345334
channel_type: Some(self.channel_type.clone()),
5335+
#[cfg(taproot)]
5336+
next_local_nonce: None,
53355337
}
53365338
}
53375339

lightning/src/ln/msgs.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ pub struct AcceptChannel {
249249
/// our feature bits with our counterparty's feature bits from the [`Init`] message.
250250
/// This is required to match the equivalent field in [`OpenChannel::channel_type`].
251251
pub channel_type: Option<ChannelTypeFeatures>,
252+
#[cfg(taproot)]
253+
/// Next nonce the channel initiator should use to create a funding output signature against
254+
pub next_local_nonce: Option<musig2::types::PublicNonce>,
252255
}
253256

254257
/// A [`funding_created`] message to be sent to or received from a peer.
@@ -1293,7 +1296,28 @@ impl Readable for OptionalField<u64> {
12931296
}
12941297
}
12951298

1299+
#[cfg(not(taproot))]
1300+
impl_writeable_msg!(AcceptChannel, {
1301+
temporary_channel_id,
1302+
dust_limit_satoshis,
1303+
max_htlc_value_in_flight_msat,
1304+
channel_reserve_satoshis,
1305+
htlc_minimum_msat,
1306+
minimum_depth,
1307+
to_self_delay,
1308+
max_accepted_htlcs,
1309+
funding_pubkey,
1310+
revocation_basepoint,
1311+
payment_point,
1312+
delayed_payment_basepoint,
1313+
htlc_basepoint,
1314+
first_per_commitment_point,
1315+
shutdown_scriptpubkey
1316+
}, {
1317+
(1, channel_type, option),
1318+
});
12961319

1320+
#[cfg(taproot)]
12971321
impl_writeable_msg!(AcceptChannel, {
12981322
temporary_channel_id,
12991323
dust_limit_satoshis,
@@ -1312,6 +1336,7 @@ impl_writeable_msg!(AcceptChannel, {
13121336
shutdown_scriptpubkey
13131337
}, {
13141338
(1, channel_type, option),
1339+
(4, next_local_nonce, option),
13151340
});
13161341

13171342
impl_writeable_msg!(AnnouncementSignatures, {
@@ -2449,6 +2474,8 @@ mod tests {
24492474
first_per_commitment_point: pubkey_6,
24502475
shutdown_scriptpubkey: if shutdown { OptionalField::Present(Address::p2pkh(&::bitcoin::PublicKey{compressed: true, inner: pubkey_1}, Network::Testnet).script_pubkey()) } else { OptionalField::Absent },
24512476
channel_type: None,
2477+
#[cfg(taproot)]
2478+
next_local_nonce: None,
24522479
};
24532480
let encoded_value = accept_channel.encode();
24542481
let mut target_value = hex::decode("020202020202020202020202020202020202020202020202020202020202020212345678901234562334032891223698321446687011447600083a840000034d000c89d4c0bcc0bc031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f024d4b6cd1361032ca9bd2aeb9d900aa4d45d9ead80ac9423374c451a7254d076602531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe33703462779ad4aad39514614751a71085f2f10e1c7a593e4e030efb5b8721ce55b0b0362c0a046dacce86ddd0343c6d3c7c79c2208ba0d9c9cf24a6d046d21d21f90f703f006a18d5653c4edf5391ff23a61f03ff83d237e880ee61187fa9f379a028e0a").unwrap();

0 commit comments

Comments
 (0)