From 78f428edcc712af389005fcf4cddc1d71f2eb6d6 Mon Sep 17 00:00:00 2001 From: optout <13562139+optout21@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:32:49 +0200 Subject: [PATCH] Proper serialization of new field in TLVs (b/w comp) --- lightning/src/ln/channel.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index d24c05a26b6..136893437d7 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -8893,7 +8893,6 @@ impl Writeable for Channel where SP::Target: SignerProvider { self.context.channel_transaction_parameters.write(writer)?; self.context.funding_transaction.write(writer)?; - self.context.funding_transaction_broadcast.write(writer)?; self.context.counterparty_cur_commitment_point.write(writer)?; self.context.counterparty_prev_commitment_point.write(writer)?; @@ -8954,6 +8953,8 @@ impl Writeable for Channel where SP::Target: SignerProvider { let cur_holder_commitment_point = Some(self.context.holder_commitment_point.current_point()); let next_holder_commitment_point = self.context.holder_commitment_point.next_point(); + let funding_transaction_broadcast = Some(self.context.funding_transaction_broadcast); + write_tlv_fields!(writer, { (0, self.context.announcement_sigs, option), // minimum_depth and counterparty_selected_channel_reserve_satoshis used to have a @@ -8994,7 +8995,8 @@ impl Writeable for Channel where SP::Target: SignerProvider { (47, next_holder_commitment_point, option), (49, self.context.local_initiated_shutdown, option), // Added in 0.0.122 (51, is_manual_broadcast, option), // Added in 0.0.124 - (53, funding_tx_broadcast_safe_event_emitted, option) // Added in 0.0.124 + (53, funding_tx_broadcast_safe_event_emitted, option), // Added in 0.0.124 + (55, funding_transaction_broadcast, option), // Added in 1.0.1 }); Ok(()) @@ -9234,7 +9236,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch let mut channel_parameters: ChannelTransactionParameters = Readable::read(reader)?; let funding_transaction: Option = Readable::read(reader)?; - let funding_transaction_broadcast: bool = Readable::read(reader)?; let counterparty_cur_commitment_point = Readable::read(reader)?; @@ -9310,6 +9311,8 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch let mut next_holder_commitment_point_opt: Option = None; let mut is_manual_broadcast = None; + let mut funding_transaction_broadcast: Option = None; + read_tlv_fields!(reader, { (0, announcement_sigs, option), (1, minimum_depth, option), @@ -9345,6 +9348,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch (49, local_initiated_shutdown, option), (51, is_manual_broadcast, option), (53, funding_tx_broadcast_safe_event_emitted, option), + (55, funding_transaction_broadcast, option), // Added in 1.0.1 }); let (channel_keys_id, holder_signer) = if let Some(channel_keys_id) = channel_keys_id { @@ -9563,7 +9567,8 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch channel_transaction_parameters: channel_parameters, funding_transaction, - funding_transaction_broadcast, + // If value is missing, we use false, which may result in rebroadcast + funding_transaction_broadcast: funding_transaction_broadcast.unwrap_or(false), is_batch_funding, counterparty_cur_commitment_point,