Skip to content

[1/3] aux revocation: add deterministic HTLCs - #11094

Merged
Roasbeef merged 4 commits into
lightningnetwork:masterfrom
GeorgeTsagk:deterministic-htlcs
Nov 25, 2026
Merged

Roasbeef merged 4 commits into
lightningnetwork:masterfrom
GeorgeTsagk:deterministic-htlcs

Conversation

@GeorgeTsagk

@GeorgeTsagk GeorgeTsagk commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Punishing a revoked commitment on an asset channel requires more than the bitcoin-level justice sweep: the asset side needs a valid asset witness for whatever transaction the cheater actually confirms, including second-level HTLC spends.

Under the normal SINGLE|ANYONECANPAY scheme those second-level transactions are malleable (the broadcaster can add fee inputs, batch, or RBF them), so their final form is unknowable in advance and no asset witness or proof chain could be prepared for them. With deterministic HTLCs both parties commit to the exact final second-level transaction via SIGHASH_DEFAULT, so the revoking party can pre-sign asset-level signatures for both spend paths of every HTLC and hand them over in RevokeAndAck (this will be the next part), giving the honest party everything needed to claim the assets no matter which path a breach takes.

An existing channel switches over once both peers negotiate the feature. The signer of a commitment decides its HTLC sighash type and states it in a custom record on commitment_signed, so a commitment that was signed before the switch and is retransmitted after it is still verified as it was signed.

Next PR: #11111

@GeorgeTsagk GeorgeTsagk self-assigned this Aug 18, 2026
@github-actions github-actions Bot added the severity-critical Requires expert review - security/consensus critical label Aug 18, 2026
@github-actions

Copy link
Copy Markdown

🔴 PR Severity: CRITICAL

file classification | 23 files | 1205 lines changed (768 excluding tests)

🔴 Critical (14 files)
  • contractcourt/chain_arbitrator.go - on-chain dispute resolution coordination
  • contractcourt/chain_watcher.go - on-chain dispute resolution coordination
  • contractcourt/contract_resolver.go - on-chain dispute/breach resolution logic
  • contractcourt/htlc_success_resolver.go - HTLC breach/resolution handling
  • contractcourt/htlc_timeout_resolver.go - HTLC breach/resolution handling
  • htlcswitch/link.go - HTLC forwarding state machine
  • htlcswitch/mock.go - htlcswitch package support code
  • lnwallet/aux_signer.go - commitment/signing logic
  • lnwallet/chanfunding/coin_select.go - channel funding coin selection
  • lnwallet/channel.go - channel state, commitment transactions
  • lnwallet/commitment.go - commitment transaction construction
  • lnwallet/mock.go - lnwallet package support code
  • lnwallet/transactions.go - transaction construction/signing
  • server.go - core server coordination
🟢 Low (9 files, tests only)
  • contractcourt/breach_arbitrator_test.go
  • contractcourt/contract_resolver_test.go
  • htlcswitch/mailbox_test.go
  • input/size_test.go
  • lnrpc/walletrpc/walletkit_server_test.go
  • lnwallet/aux_signer_test.go
  • lnwallet/channel_test.go
  • lnwallet/chanfunding/coin_select_test.go
  • lnwallet/transactions_test.go

Analysis

This PR touches core contractcourt/*, htlcswitch/*, and lnwallet/* packages — on-chain breach/HTLC resolution, HTLC forwarding, and commitment transaction/signing logic — each of which is independently CRITICAL. The change spans multiple distinct critical packages (contractcourt, htlcswitch, lnwallet) and modifies ~768 non-test lines across 14 non-test files, well above the >500 line bump threshold, reinforcing the CRITICAL classification. Given the surface area (commitment transactions, HTLC resolvers, channel funding), this warrants expert review focused on correctness of on-chain resolution paths and signing logic.


To override, add a severity-override-{critical,high,medium,low} label.

@GeorgeTsagk

Copy link
Copy Markdown
Collaborator Author

Added no-changelog label, will include one with the 3rd and final part of this PR series.

@gijswijs gijswijs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we are nearly there with this PR. I did a real human-powered, thorough review of the code and found some issues, that I commented on inline. The below comment is about a commit message.

The commit message on the first commit claims to replace CustomBlob.IsSome() but I don't see that specific method being replaced anywhere. Where does that come from?

Comment thread input/size_test.go Resolved
Comment thread lnwallet/aux_signer.go Resolved
Comment thread lnwallet/aux_signer_test.go Resolved
Comment thread lnwallet/channel.go Resolved
Comment thread contractcourt/contract_resolver.go Resolved
Comment thread contractcourt/contract_resolver.go Resolved
Comment thread contractcourt/contract_resolver.go Resolved
Comment thread contractcourt/htlc_timeout_resolver.go Resolved
Comment thread contractcourt/contract_resolver.go Resolved
Comment thread lnwallet/channel.go Resolved

@gijswijs gijswijs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! 🦺

@ziggie1984 ziggie1984 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Cool PR !!! I think we should adjust and not hard-code 1.1 sat for the second-level transactions. Why not use the Commitment Fee which should always be closer to the minMemPool fee.

Do you think using the P2Anchor instead of the 330 anchor would be more benefical, since we could use the value 0 sat ?

Comment thread lnwallet/aux_signer.go Resolved
Comment thread lnwallet/commitment.go Resolved
Comment thread lnwallet/aux_signer.go Resolved
Comment thread lnwallet/channel.go Resolved
Comment thread contractcourt/contract_resolver.go Resolved
Comment thread lnwallet/chanfunding/coin_select.go Resolved
Comment thread lnwallet/channel_test.go Resolved
@GeorgeTsagk

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. Answering the two points from the description here, the inline threads have the details.

On not hard-coding 1.1 sat and using the commitment fee instead: I implemented it, measured it, and reverted it. Short version is that the anchor exists precisely so the pre-signed parent does not have to predict the fee market at signing time, and on aux channels the HTLC's whole on-chain BTC value is 1200 sats which is already fully spent on the parent fee, the anchor, and a second-level output that must fund its own claiming sweep. At 1000 sat/kw the commitment-rate fee alone is 817 sats, at 2500 it exceeds the entire budget, so every asset HTLC gets trimmed to dust. Clamping it to what the HTLC can afford does not work either: the breach itest then strands the assets, because the output ends up at exactly the dust limit and cannot pay for the justice sweep. Numbers and logs are in the commitment.go thread.

On P2A instead of the 330 sat anchor: I agree with the direction, and it is the same answer as the fee question, since a 0-value anchor only works inside a TRUC/v3 package where the child pays for both. That also removes the one gap the current design has, a parent below the mempool minimum, and frees the 330 sats plus the parent fee, which would let taproot-assets drop its 1200 sat per-HTLC carrier to roughly 600 and lower the minimum asset payment we quote over RFQ.

I would rather not pull it into this series though. It changes the pre-signed transaction format, so it is a new negotiated variant rather than a drop-in, it needs machinery lnd does not have yet (no P2A script type, no v3 construction, no TRUC-aware sweeper, only SubmitPackage exists), and it changes the taproot-assets allocation and exclusion-proof layout that the companion series and its itests are built against. On top of that it is currently untestable end to end: both lnd's and taproot-assets' itest frameworks mine with btcd, which has no TRUC or ephemeral dust policy and no server-side submitpackage, so a 0-fee parent with a 0-value output would never be mined. Validating it needs a Core-mined harness, which is its own piece of work.

Happy to open a tracking issue for the P2A/TRUC variant so it does not get lost, and there is a cheaper intermediate step available: submitting parent plus child as a package with the existing anchor closes the mempool-minimum gap without any format change.

@GeorgeTsagk
GeorgeTsagk requested a review from ziggie1984 August 24, 2026 14:40
GeorgeTsagk added a commit to lightninglabs/taproot-assets that referenced this pull request Aug 24, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.

@ziggie1984 ziggie1984 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall, the core design looks good to me now. The fixed floor-fee parent plus CPFP anchor is a reasonable fit for the constrained Taproot Assets carrier, and the analysis in the review threads clarified the main trade-offs.

I think the PR still needs a small cleanup/rework pass before final approval:

  • Remove the post-publish retry from this PR as discussed. It retries immediate SweepInput call errors, but cannot observe or repair the later sweeper admission/monitoring failures it was intended to handle. A reliable retry belongs in a follow-up with a proper acknowledgement or persistence boundary.
  • Make the SigHashDefault policy consistent across commitment construction, auxiliary leaf creation, signing, and verification. The commitment builder currently snapshots the result while other paths can consult live negotiation; either use one resolved value per commitment transition or demonstrate with a focused test why divergence cannot occur.
  • Open and link the package-relay follow-up for the known case where the standalone floor-fee parent is below the dynamic mempool minimum.
  • Split the independent maxFeeRatio relaxation if possible. Wherever it lands, cap the override at the concrete tapd requirement (5.0) rather than 100.0, and add a focused Taproot Assets test proving the realistic near-dust re-anchor flow needs a ratio above one.

Once those points are addressed and the relevant tests are green, I think this should be ready for a final pass.

@GeorgeTsagk
GeorgeTsagk requested a review from ziggie1984 August 25, 2026 18:27
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Aug 25, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Aug 26, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.

@ziggie1984 ziggie1984 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ACK. Re-reviewed the current head (2a465a5). The sweeper/contractcourt responsibility split now looks sound: contractcourt constructs the immutable parent/anchor request, while PublishPreSignedTx owns publication, retry, spend monitoring, and CPFP lifecycle. The remaining package-relay admission gap and NoInputBatch wallet-UTXO pressure are acknowledged and tracked separately (#11124 and #11576). Targeted tests pass locally: go test ./sweep ./contractcourt ./lnwallet and go test -tags=dev ./htlcswitch.

@litbot-9000

Copy link
Copy Markdown
Collaborator

@yyforyongyu: review reminder
@GeorgeTsagk, remember to re-request review from reviewers when ready

GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Nov 23, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
@ziggie1984

Copy link
Copy Markdown
Collaborator

I think we need an explicit decision on the upgrade behavior here.

There appears to be a reestablishment window where a legacy commitment_signed has been created and persisted by one peer, but the state transition has not completed on the other peer. If both peers upgrade at that point and negotiate DeterministicHTLCs, the receiving peer refreshes its next-commitment sighash policy before processing the retransmitted state. The sender can then retransmit the persisted legacy signatures while the receiver reconstructs/verifies the commitment using SIGHASH_DEFAULT. With a non-dust HTLC, that mismatch should make ReceiveNewCommitment fail and take the LinkFailureForceClose path.

The commitment blob cached by the sender does not by itself solve this case because the receiver has not accepted or persisted that commitment yet. The current upgrade test appears to exercise a clean commitment boundary rather than an outstanding commitment_signed across the upgrade.

I am personally okay with accepting this narrow force-close risk if that is the deliberate trade-off, but I think the PR author/editor should explore and explicitly decide between both options:

  1. Accept and document the risk, including the required clean upgrade boundary and operational guidance.
  2. Preserve the old policy for an in-flight commitment, either by binding the policy to commitment_signed or delaying activation until a mutually acknowledged clean boundary.

The fix may not be very complicated, so it seems worth exploring before deciding to accept the risk. In either case, a regression test with a persisted legacy commitment_signed, disconnect before acknowledgement, upgrade of both peers, and retransmission on reestablishment would make the behavior explicit.

@yyforyongyu yyforyongyu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Astra found a few blocking issues, I've checked and agree we should address them before merging. One of them is what's raised by @ziggie1984 below.

Comment thread htlcswitch/link.go Resolved
Comment thread sweep/presigned.go Resolved
Comment thread sweep/presigned.go Resolved
Comment thread sweep/presigned.go Resolved
Comment thread sweep/presigned_test.go Resolved
Comment thread htlcswitch/link.go Resolved
Comment thread lnwallet/transactions_test.go Resolved
Comment thread lnwallet/transactions_test.go Resolved
Comment thread lnwallet/channel_test.go Resolved
@GeorgeTsagk

Copy link
Copy Markdown
Collaborator Author

On the upgrade behavior with an in-flight commitment_signed: we are going with accepting the risk and documenting it. The docs will state that the upgrade needs a clean commitment boundary and give operational guidance for it.

Comment thread sweep/presigned.go Resolved
Comment thread sweep/presigned.go Resolved
Comment thread sweep/presigned_test.go Resolved
Introduce a feature-bit negotiation approach for choosing the sighash
type of second-level HTLC transactions, via a new
AuxSigner.HtlcSigHashType hook.

Add a ResolveHtlcSigHashType helper that queries the aux signer for a
channel-specific sighash override based on negotiated features, falling
back to the default HtlcSigHashType when no aux signer is present or
the feature isn't negotiated. Thread the auxSigner through all HTLC
second-level transaction signing and validation call sites.

Which source the answer comes from follows one rule. The party that
signs a commitment decides its sighash type, from the live feature
negotiation at that time, and a chain whose latest commitment uses
SigHashDefault never goes back. The channel resolves the live answer
when it is constructed and again once the link has re-established the
channel, which is when the aux signer learns the negotiated features
(RefreshHtlcSigHashType). Estimates about future commitments follow the
same answer. A decision about a commitment that already exists, such as
resolving a force close, reads the sighash recorded in the custom blob
of that very commitment.

The receiver of a commitment does not derive its type, it is told. A
commitment_signed is retransmitted as it was first signed, possibly in
a later connection with different features negotiated: one that was
signed before both peers upgraded reaches the receiver after it picked
up the new negotiation, and verifying it as SigHashDefault fails and
force closes the channel. So a commitment_signed that uses
SigHashDefault states it in a custom record, and one without the record
uses the standard sighash flags of the channel type, which is what
every message signed before the feature existed looks like. The
receiver builds and verifies the commitment with the stated type and
refuses SigHashDefault when the feature is not negotiated, a return to
the legacy sighash after its latest commitment used SigHashDefault, and
an unknown value. The type is handed to the aux leaf store with every
commitment that is built (CommitDiffAuxInput.SigHashDefault), so the
blob records what the signer decided rather than what the leaf store
would derive on its own. Only channels with a tapscript root and an aux
signer carry or read the record, the commitment_signed of every other
channel is unchanged.

A channel opened before both peers upgraded therefore switches over
cleanly, also with a commitment_signed in flight: its existing
commitments stay what they were built as, and only new ones use the
negotiated type.

An earlier draft of this feature selected the sighash based on the
presence of the commitment's custom blob alone, which is backwards
incompatible: a peer that has not upgraded would disagree on the
sighash and force close the channel. Explicit feature negotiation
ensures both channel parties agree on the sighash type before it is
ever used.
When DeterministicHTLCs is negotiated (SigHashDefault second-level
HTLCs), the peer's signature commits to the entire transaction, so the
sweeper can neither add fee inputs nor RBF the pre-signed tx. Instead of
baking a large fixed fee into the transaction, give it a minimal
baked-in fee plus a CPFP anchor:

- The pre-signed second-level HTLC tx gets a second output: a taproot
  anchor (AnchorSize sats, keyed to the broadcaster's delay key) that
  the local party can sweep to CPFP-bump the package fee rate.
- The baked-in fee is 1.1x the relay floor over the tx weight (including
  the anchor output), which is enough for the pre-signed tx to clear
  min-relay on its own. It deliberately does not track the negotiated
  commitment fee rate: the whole on-chain BTC value of an aux-channel
  HTLC is a small fixed budget that already pays this fee, funds the
  anchor, and must still leave a second-level output that is non-dust
  AND able to fund the third-level sweep claiming it. At a realistic
  commitment fee rate the fee alone exceeds that budget, and capping it
  at what keeps the output non-dust leaves the output unable to pay for
  its own sweep, stranding the asset value it carries. Adapting to the
  fee market is the CPFP child's job. Where a mempool minimum sits above
  the parent's own rate, a separately published child cannot rescue a
  parent the mempool never accepted. That takes submitting both as a
  package, which only bitcoind supports today and is left for later.
- HtlcIsDust and the second-level fee/output-amount calculations are
  threaded with the sigHashDefault flag so dust decisions and the HTLC
  output value account for both the baked-in fee and the AnchorSize
  reduction. The flag is that of the commitment in question: the
  type its signer decided for a new commitment, the type recorded in
  its blob for one restored from disk, closed on chain or revoked.
- The sweep sign descriptor for the second-level output is reduced by
  AnchorSize accordingly, so the sweeper signs for the correct value.

Only aux/custom (taproot asset) channels can negotiate SigHashDefault
(see ResolveHtlcSigHashType); all other channel types keep their
existing fee and transaction form.
…eeper

When a second-level HTLC transaction was signed with SigHashDefault, the
peer's signature commits to the entire transaction: the sweeper's usual
flow of rebuilding the tx with extra fee inputs or batched outputs would
invalidate it. Such a transaction has to be published verbatim, and a
pre-signed timeout tx carries an absolute locktime, so it is only final
once the chain reaches that height and has to be retried on later
blocks after a "non final" or transient mempool rejection.

Rather than growing a second publication engine in contractcourt, hand
the whole lifecycle to the sweeper. UtxoSweeper gains
PublishPreSignedTx: the caller supplies the exact transaction, the
outputs it spends, an optional CPFP anchor input with its budget, and a
deadline, and the sweeper owns everything from there inside its
existing block-driven event loop: it watches the spent outputs, gates
publication on the locktime, re-broadcasts on every block until the
wallet accepts the tx, registers the anchor with its regular input
machinery once the parent is in the mempool, and reports a single final
outcome on the returned channel.

The lifecycle only ends on chain evidence. The sweeper registers a
spend notification for every input of the tx before it publishes
anything: the tx itself as the spender means it confirmed and only the
anchor is left to sweep, any other spender means it can never confirm
(ErrPreSignedTxConflict). Until then every step is retried on every
block: a rejected publication, including one the wallet reports as a
double spend, since the backend maps a missing input to the same error
and a commitment that is gone after a re-org comes back; a failed
anchor registration, which happens inline in the collector via
handleNewInput so that a nil error is a real acknowledgement; and an
anchor sweep that failed, most commonly because the parent left the
mempool (evicted or replaced) and nobody else re-broadcasts it, in which
case the lifecycle goes back to publishing the parent. The deadline
only drives the fee rate of the anchor child. It does not bound the
retries: the output the tx claims stays claimable past it, so giving up
there would abandon a valid claim over a transient error.

The anchor is registered with input batching disabled: it spends an
unconfirmed parent, and a parent that goes missing must only ever fail
the anchor's own sweep tx. Our child confirming, or a third party
spending the anchor, concludes the lifecycle, both imply the parent
confirmed.

Duplicate requests attach as additional listeners, shutdown releases
pending callers with ErrSweeperShuttingDown, and nothing is persisted:
like regular inputs, a resolver re-submits after a restart, at which
point an already-published tx is a no-op broadcast. The parent is
always published on its own. Submitting it together with its anchor
child as a package only works on bitcoind today, so that is left for
when btcd and neutrino support 1P1C relay, and can then be added inside
this one API without touching the resolvers.

On the contractcourt side the timeout and success resolvers detect the
SigHashDefault case through isSecondLevelSigHashDefault, which also
requires the channel type to carry a tapscript root: SigHashDefault is
the zero value of SigHashType, so without the explicit channel-type
check any channel that never populates SignDetails.SigHashType would
false-positively match. Only aux/custom (taproot asset) channels carry
a tapscript root, so non-custom channels provably keep using the sweeper
flow. The resolvers build the request, with the commitment HTLC output
as the spent output and the broadcast height as the height hint, and
hand it over; a tracked goroutine logs the eventual outcome. A
synchronous hand-off failure clears the resolver's launched flag so the
next Launch can retry instead of no-op'ing until restart.
The pre-signed second-level HTLC tx cannot be RBF'd under SigHashDefault
(the peer's signature commits to the full tx), so CPFP via the anchor at
output index 1 is its only fee-bumping path. Build the anchor input and
pass it, with its budget, in the PublishPreSignedTx request, so the
sweeper CPFPs the parent as soon as it is in the mempool.

The anchor input carries a key-path sign descriptor and the parent tx
info the sweeper needs for package fee-rate calculation: the exact
baked-in parent fee (spent commitment output value minus the parent's
outputs) and the parent weight. The fee budget for the child is derived
from the value under protection (the second-level HTLC output) via the
same sweeper.budget.anchorcpfp(ratio) configuration used for commitment
anchor CPFP, plus the anchor value itself. The child is funded from
wallet inputs, so the budget can and usually must exceed the anchor's
own 330 sats. The deadline is the incoming HTLC's expiry on the timeout
path (matching the other timeout-path sweeps) and the HTLC's own expiry
on the success path.

The anchor is keyed to the broadcaster's to-local delay key, which is
derived directly from the second-level output's sweep sign descriptor
(delay base point + single tweak), keeping this path self-contained. No
anchor is attached when the parent tx has fewer than two outputs, i.e.
the channel did not use DeterministicHTLCs, or when the descriptor
lacks the key material; the parent then still publishes at its
baked-in floor fee.
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Nov 25, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
@GeorgeTsagk

Copy link
Copy Markdown
Collaborator Author

Update on the upgrade behavior with an in-flight commitment_signed: we fixed it instead of documenting it, so no operational guidance is needed.
commitment_signed now states the HTLC sighash type of the commitment it signs, so one that was signed before the upgrade and is retransmitted after it is verified as it was signed.

@yyforyongyu yyforyongyu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@yyforyongyu
yyforyongyu added this pull request to the merge queue Nov 25, 2026
Comment thread lnwallet/aux_signer.go
// message in a later connection, with different features negotiated,
// as a commitment_signed is retransmitted as it was first signed. So
// the type is stated on the message rather than derived on both ends.
commitSigHtlcSigHashType tlv.TlvType65638

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How was 65638 picked? It looks hand-chosen near the other aux types here (65543, 65544), but BOLT #1 (Type-Length-Value Format) says for custom records:

type identifiers greater than or equal to 2^16 are available for custom records.
SHOULD pick random type identifiers to avoid collision with other custom types.

and bLIP-0002 asks that TLV fields added to existing BOLT messages be listed in the table for that message (there's no commitment_signed table yet).

The even type and only sending it after negotiation look right to me (a peer that ignored the record would verify the HTLC sigs with the wrong sighash and dust layout). The concern is the number itself: the record shares CommitSig.CustomRecords with tapd's aux-sig records, and receivedSigHashDefault deletes this type before handing the rest to the aux signer. If tapd ever uses or reserves 65638 on commitment_signed, its record would be silently dropped or misread as the sighash flag, and we'd likely end up in a force close.

Could we either pick a random even type ≥ 2^16 (and note somewhere which types lnd claims in commitment_signed custom records), or register it in bLIP-0002 / the taproot-assets channel spec? Either way, it would be good to confirm on the tapd side that 65638 is free there.

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 25, 2026
@Roasbeef
Roasbeef merged commit edec785 into lightningnetwork:master Nov 25, 2026
42 checks passed
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in Taproot-Assets Project Board Nov 25, 2026
@github-project-automation github-project-automation Bot moved this from In review to Done in lnd v0.22 Nov 25, 2026
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Nov 26, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Nov 27, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Nov 30, 2026
Points the lnd module and its submodules at the companion series on the
GeorgeTsagk/lnd fork:

  1. lightningnetwork/lnd#11094, deterministic second-level HTLCs
  2. lightningnetwork/lnd#11111, revocation AuxSigs in RevokeAndAck
  3. lightningnetwork/lnd#11112, breach-to-confirmation revocation flow

The pin is at the tip of part 3, which contains all three. It also adapts
the call sites that the new aux interfaces touch.

This is temporary and has to be dropped once the lnd series lands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

custom chans no-changelog severity-critical Requires expert review - security/consensus critical

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants