Convert `channelmonitor` `vec_type` TLV writes to required/optional
authorMatt Corallo <git@bluematt.me>
Fri, 7 Jul 2023 19:57:23 +0000 (19:57 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 11 Jul 2023 16:20:03 +0000 (16:20 +0000)
 * `HolderSignedTx::htlc_outputs` has always been written since it
   was converted to TLVs in 86641ea68062388a01c99c6ed131f56477c8e4.
 * `ChanelMonitorUpdateStep::*::htlc_outputs` have been written
   since the enum was converted to TLVs in 86641ea68062388a01c99c6.

lightning/src/chain/channelmonitor.rs

index 904d9941349804f99cb31127e2757fcc51bbf473..71fc1cb6f06845e9ad49a611fce7be552a11fd00 100644 (file)
@@ -262,7 +262,7 @@ impl_writeable_tlv_based!(HolderSignedTx, {
        (8, delayed_payment_key, required),
        (10, per_commitment_point, required),
        (12, feerate_per_kw, required),
-       (14, htlc_outputs, vec_type)
+       (14, htlc_outputs, required_vec)
 });
 
 impl HolderSignedTx {
@@ -538,15 +538,15 @@ impl ChannelMonitorUpdateStep {
 impl_writeable_tlv_based_enum_upgradable!(ChannelMonitorUpdateStep,
        (0, LatestHolderCommitmentTXInfo) => {
                (0, commitment_tx, required),
-               (1, claimed_htlcs, vec_type),
-               (2, htlc_outputs, vec_type),
+               (1, claimed_htlcs, optional_vec),
+               (2, htlc_outputs, required_vec),
                (4, nondust_htlc_sources, optional_vec),
        },
        (1, LatestCounterpartyCommitmentTXInfo) => {
                (0, commitment_txid, required),
                (2, commitment_number, required),
                (4, their_per_commitment_point, required),
-               (6, htlc_outputs, vec_type),
+               (6, htlc_outputs, required_vec),
        },
        (2, PaymentPreimage) => {
                (0, payment_preimage, required),
@@ -1075,12 +1075,12 @@ impl<Signer: WriteableEcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signe
 
                write_tlv_fields!(writer, {
                        (1, self.funding_spend_confirmed, option),
-                       (3, self.htlcs_resolved_on_chain, vec_type),
-                       (5, self.pending_monitor_events, vec_type),
+                       (3, self.htlcs_resolved_on_chain, required_vec),
+                       (5, self.pending_monitor_events, required_vec),
                        (7, self.funding_spend_seen, required),
                        (9, self.counterparty_node_id, option),
                        (11, self.confirmed_commitment_tx_counterparty_output, option),
-                       (13, self.spendable_txids_confirmed, vec_type),
+                       (13, self.spendable_txids_confirmed, required_vec),
                        (15, self.counterparty_fulfilled_htlcs, required),
                });
 
@@ -4051,12 +4051,12 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
                let mut counterparty_fulfilled_htlcs = Some(HashMap::new());
                read_tlv_fields!(reader, {
                        (1, funding_spend_confirmed, option),
-                       (3, htlcs_resolved_on_chain, vec_type),
-                       (5, pending_monitor_events, vec_type),
+                       (3, htlcs_resolved_on_chain, optional_vec),
+                       (5, pending_monitor_events, optional_vec),
                        (7, funding_spend_seen, option),
                        (9, counterparty_node_id, option),
                        (11, confirmed_commitment_tx_counterparty_output, option),
-                       (13, spendable_txids_confirmed, vec_type),
+                       (13, spendable_txids_confirmed, optional_vec),
                        (15, counterparty_fulfilled_htlcs, option),
                });