From 6793d00a0ccd97c8ee3018d906b298a4106449f4 Mon Sep 17 00:00:00 2001 From: xstoicunicornx Date: Mon, 9 Nov 2026 20:54:18 +0000 Subject: [PATCH] Make TransactionType upgradable before release TransactionType was serialized with impl_writeable_tlv_based_enum, which fails to read any variant it doesn't know, odd or even. A node reading a payment classified with a later variant would fail to decode the whole PaymentDetails, and with it the payment store. No release writes tx_type yet, so the reader can still change for free. Serialize TransactionType with impl_writeable_tlv_based_enum_upgradable and read both fields holding one, PaymentKind::Onchain's tx_type and ChannelTxFacts' self_role, as upgradable_option, as we already do for LDK's ClosureReason and PaymentFailureReason. An unknown odd variant now reads as no classification, while an unknown even one is still required. The written bytes are unchanged. Written with the help of Claude Code. --- src/payment/store.rs | 6 +++--- src/wallet/provenance.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/payment/store.rs b/src/payment/store.rs index d5ed722e2c..d6dee70ffe 100644 --- a/src/payment/store.rs +++ b/src/payment/store.rs @@ -16,7 +16,7 @@ use lightning::offers::offer::OfferId; use lightning::util::ser::{Readable, Writeable}; use lightning::{ _init_and_read_len_prefixed_tlv_fields, impl_writeable_tlv_based, - impl_writeable_tlv_based_enum, write_tlv_fields, + impl_writeable_tlv_based_enum, impl_writeable_tlv_based_enum_upgradable, write_tlv_fields, }; use lightning_types::payment::{PaymentHash, PaymentPreimage, PaymentSecret}; use lightning_types::string::UntrustedString; @@ -490,7 +490,7 @@ pub enum TransactionType { }, } -impl_writeable_tlv_based_enum!(TransactionType, +impl_writeable_tlv_based_enum_upgradable!(TransactionType, (0, Funding) => { (0, channels, optional_vec), }, @@ -639,7 +639,7 @@ impl PaymentKind { impl_writeable_tlv_based_enum!(PaymentKind, (0, Onchain) => { (0, txid, required), - (1, tx_type, option), + (1, tx_type, upgradable_option), (2, status, required), }, (2, Bolt11) => { diff --git a/src/wallet/provenance.rs b/src/wallet/provenance.rs index 94523de9d1..2029d12f5d 100644 --- a/src/wallet/provenance.rs +++ b/src/wallet/provenance.rs @@ -145,7 +145,7 @@ pub(crate) struct ChannelTxFacts { impl_writeable_tlv_based!(ChannelTxFacts, { (0, txid, required), (2, outputs, optional_vec), - (4, self_role, option), + (4, self_role, upgradable_option), (6, local_figures, option), (8, recorded_at_height, required), });