Skip to content

Make TransactionType upgradable before release - #1228

Open
tnull wants to merge 1 commit into
lightningdevkit:mainfrom
tnull:2026-11-make-transaction-type-upgradable
Open

tnull wants to merge 1 commit into
lightningdevkit:mainfrom
tnull:2026-11-make-transaction-type-upgradable

Conversation

@tnull

@tnull tnull commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1226

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.

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.
@tnull tnull added this to the 0.8 milestone Nov 10, 2026
@tnull
tnull requested a review from jkczyz November 10, 2026 09:38
@ldk-reviews-bot

ldk-reviews-bot commented Nov 10, 2026 •

Copy link
Copy Markdown

👋 Thanks for assigning @jkczyz as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@Camillarhi Camillarhi left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this LGTM.

I noticed ChannelOutputRole and SpliceKind have the same issue. Both are new this cycle and still use the plain impl_writeable_tlv_based_enum!, so adding a variant to either would break reading the store after a downgrade. Could we fix them here or in a follow-up before the release?

Nit: the docs on PaymentKind::Onchain::tx_type list the reasons it can be None. It would help to add: "the transaction was classified by a newer version of LDK Node using a type this version doesn't recognize."

jkczyz
jkczyz previously approved these changes Nov 10, 2026
@tnull
tnull force-pushed the 2026-11-make-transaction-type-upgradable branch from 8ad902d to 6793d00 Compare November 11, 2026 06:33
@tnull
tnull requested a review from jkczyz November 11, 2026 06:33
@tnull

tnull commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

I noticed ChannelOutputRole and SpliceKind have the same issue. Both are new this cycle and still use the plain impl_writeable_tlv_based_enum!, so adding a variant to either would break reading the store after a downgrade. Could we fix them here or in a follow-up before the release?

Hmm, briefly considered it, but at least for SpliceKind it probably doesn't matter much. ChannelOutputRole maybe more, but it's a bit tedious to break the macro, so to do it properly we'd need to handle Options for these everywhere.

@jkczyz Thoughts? Worth now, or just when something breaks in the future?

@jkczyz

jkczyz commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Hmm, briefly considered it, but at least for SpliceKind it probably doesn't matter much. ChannelOutputRole maybe more, but it's a bit tedious to break the macro, so to do it properly we'd need to handle Options for these everywhere.

@jkczyz Thoughts? Worth now, or just when something breaks in the future?

FWIW, SpliceKind could probably be dropped now that #1080 removed the use of SpliceIntent (which could as well).

Regarding, ChannelOutputRole, could the macro be fixed upstream?

@jkczyz

jkczyz commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

FWIW, SpliceKind could probably be dropped now that #1080 removed the use of SpliceIntent (which could as well).

Opened #1232.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make TransactionType upgradable before it ships

5 participants