Skip to content

Commit

Permalink
Proper serialization of new field in TLVs (b/w comp)
Browse files Browse the repository at this point in the history
  • Loading branch information
optout21 committed Sep 18, 2024
1 parent ef5830a commit 78f428e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8893,7 +8893,6 @@ impl<SP: Deref> Writeable for Channel<SP> 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)?;
Expand Down Expand Up @@ -8954,6 +8953,8 @@ impl<SP: Deref> Writeable for Channel<SP> 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
Expand Down Expand Up @@ -8994,7 +8995,8 @@ impl<SP: Deref> Writeable for Channel<SP> 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(())
Expand Down Expand Up @@ -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<Transaction> = Readable::read(reader)?;
let funding_transaction_broadcast: bool = Readable::read(reader)?;

let counterparty_cur_commitment_point = Readable::read(reader)?;

Expand Down Expand Up @@ -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<PublicKey> = None;
let mut is_manual_broadcast = None;

let mut funding_transaction_broadcast: Option<bool> = None;

read_tlv_fields!(reader, {
(0, announcement_sigs, option),
(1, minimum_depth, option),
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 78f428e

Please sign in to comment.