Skip to content

[3/3] aux revocation: breach-to-confirmation revocation flow - #11112

Open
GeorgeTsagk wants to merge 15 commits into
lightningnetwork:masterfrom
GeorgeTsagk:htlc-revocation-flow
Open

GeorgeTsagk wants to merge 15 commits into
lightningnetwork:masterfrom
GeorgeTsagk:htlc-revocation-flow

Conversation

@GeorgeTsagk

@GeorgeTsagk GeorgeTsagk commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

This is the final part of the HTLC revocation series for aux/custom (taproot asset) channels, stacked on #11094 and #11111. Only the last twelve commits are new here.

It connects the pieces from the previous two PRs into the end-to-end breach lifecycle: with deterministic second-level HTLCs (part 1) and the revocation AuxSigs handed over in RevokeAndAck (part 2), the breach machinery can now punish a revoked commitment on an asset channel no matter which path the cheater takes, while keeping the asset proof chain intact.

The commits are grouped into four arcs:

Breach context (lnwallet):

  • HTLC retributions carry their resolution blobs, the breach height, and a preserved resolution request template, so the aux resolver can be re-consulted later with full context.
  • FetchLeavesFromRevocation gains the channel state parameters needed to derive the revoked commitment's leaves.
  • Breached HTLCs get an AuxSigDesc populated from the revocation log, carrying the dual-path sigs from part 2.

Confirmed-only aux notification (sweep + contractcourt):

  • The aux sweeper is notified only once a justice transaction actually confirms, via AuxNotifyOpts (confirm height, input-proof lookup, independent skip flags), so the asset side never finalizes proofs for transactions that lost the pinning race. Tests included.

Justice machinery (contractcourt):

  • The breach arbiter handles second-level morphing: it locates the punishable output by script match (aux second-level txs bundle multiple HTLCs plus an anchor, so input index does not equal output index) and rebuilds justice inputs against current state.
  • Justice tx variants are tracked across rebuild cycles so a confirmed historic variant is still recognized.
  • Justice sweep outputs respect the dust limit when the asset output carries the real value.

Convergence:

  • Breach-time consumption of the revocation AuxSigs: whichever second-level path the cheater used, the stored signature for that path is applied.
  • Second-level output sweeps re-resolve the aux blob against the confirmed second-level transaction so proof chains stay intact (gated to custom channels).

As with the previous parts, every aux path is gated on the channel type carrying a tapscript root; lnd's own breach-retribution and force-close itests pass unchanged, and the full custom channel itest suite (force close, HTLC force close, MPP, group tranches, breach, coop close) passes against this tip together with the companion taproot-assets branch.

Previous PR: #11111

@GeorgeTsagk GeorgeTsagk self-assigned this Aug 21, 2026
@GeorgeTsagk
GeorgeTsagk force-pushed the htlc-revocation-flow branch from db471fa to af50f4a Compare August 24, 2026 14:56
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.
@github-actions github-actions Bot added the severity-critical Requires expert review - security/consensus critical label Aug 24, 2026
@github-actions

Copy link
Copy Markdown

🔴 PR Severity: CRITICAL

file classification | 39 files | 5928 lines changed (5604 additions, 324 deletions)

🔴 Critical (17 files)
  • channeldb/channel.go - channel state persistence
  • chanstate/open_channel.go - open channel state (closely tied to channeldb)
  • contractcourt/breach_arbitrator.go - breach handling, largest diff (+514/-40)
  • contractcourt/chain_arbitrator.go - on-chain dispute coordination
  • contractcourt/chain_watcher.go - on-chain dispute resolution
  • contractcourt/contract_resolver.go - new contract resolver logic (+312)
  • contractcourt/htlc_success_resolver.go - HTLC resolution on-chain
  • contractcourt/htlc_timeout_resolver.go - HTLC resolution on-chain
  • htlcswitch/link.go - HTLC forwarding state machine
  • lnwallet/aux_leaf_store.go - custom channel commitment auxiliary data
  • lnwallet/aux_resolutions.go - commitment tx signing/resolution
  • lnwallet/aux_signer.go - custom channel signing
  • lnwallet/chanfunding/coin_select.go - channel funding coin selection
  • lnwallet/channel.go - core channel/commitment logic, largest diff (+1694/-202)
  • lnwallet/commitment.go - commitment transaction construction
  • lnwallet/transactions.go - transaction signing/construction
  • lnwire/revoke_and_ack.go - wire protocol message (RevokeAndAck)
  • server.go - core server coordination
  • sweep/fee_bumper.go - fund recovery/fee bumping
  • sweep/interface.go - fund recovery interfaces
🟠 High (1 file)
  • lnrpc/walletrpc/walletkit_server.go - RPC/API surface
🟢 Low (test-only / docs, excluded from counts)
  • channeldb/channel_test.go, channeldb/db_test.go
  • contractcourt/breach_arbitrator_test.go, contractcourt/commit_sweep_resolver_test.go, contractcourt/contract_resolver_test.go
  • htlcswitch/mailbox_test.go, htlcswitch/mock.go
  • input/size_test.go
  • lnrpc/walletrpc/walletkit_server_test.go
  • lnwallet/aux_signer_test.go, lnwallet/chanfunding/coin_select_test.go, lnwallet/channel_test.go, lnwallet/mock.go, lnwallet/revocation_aux_sig_test.go, lnwallet/transactions_test.go
  • lnwire/revoke_and_ack_test.go
  • sweep/mock_test.go
  • docs/release-notes/release-notes-0.22.0.md

Analysis

This PR is a large, security-sensitive change touching several CRITICAL-tier subsystems simultaneously: contractcourt/* (breach arbitration and on-chain HTLC resolution), lnwallet/* (core commitment transaction and channel state logic, +1896 lines in lnwallet/channel.go alone), lnwire/* (RevokeAndAck wire message), htlcswitch/*, sweep/*, channeldb/*, and server.go. Even ignoring the file-count/line-count bump thresholds, the presence of multiple distinct critical packages (contractcourt, lnwallet, htlcswitch, sweep, channeldb) already places this at the highest severity tier. Excluding tests, mocks, and docs, the PR still touches ~21 non-test files and ~3.5k non-test lines, well past the >20 files / >500 lines bump thresholds — reinforcing the CRITICAL classification.

Given the scope (breach arbitration, commitment/resolution logic, and revocation wire messages), this warrants careful expert review of the channel state machine and on-chain resolution paths, particularly around the new/modified aux-signer and contract-resolver logic.


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

@GeorgeTsagk
GeorgeTsagk force-pushed the htlc-revocation-flow branch from af50f4a to 707dfdb Compare August 25, 2026 18:26
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
GeorgeTsagk force-pushed the htlc-revocation-flow branch from 707dfdb to c16f334 Compare August 26, 2026 14:18
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.
@GeorgeTsagk
GeorgeTsagk force-pushed the htlc-revocation-flow branch from c16f334 to e8d8da9 Compare August 28, 2026 10:00
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Aug 28, 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.
@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

3 similar comments
@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

@GeorgeTsagk
GeorgeTsagk force-pushed the htlc-revocation-flow branch 2 times, most recently from 0a43bf8 to a5cf89b Compare September 29, 2026 08:16
@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

@GeorgeTsagk
GeorgeTsagk force-pushed the htlc-revocation-flow branch from a5cf89b to 2069f10 Compare October 6, 2026 14:59
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request Oct 6, 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.
@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

3 similar comments
@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

@litbot-9000

Copy link
Copy Markdown
Collaborator

@gijswijs: review reminder
@ziggie1984: review reminder

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.
@GeorgeTsagk
GeorgeTsagk force-pushed the htlc-revocation-flow branch 2 times, most recently from dd1a9a4 to b1a6262 Compare November 25, 2026 12:11
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 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.
@litbot-9000

Copy link
Copy Markdown
Collaborator

@litbot-9000: review reminder

@GeorgeTsagk
GeorgeTsagk requested review from yyforyongyu and removed request for gijswijs November 27, 2026 10:17
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.
The RevokeAndAck message gains a CustomRecords field, encoded and
decoded with the standard ParseAndExtractCustomRecords/MergeAndEncode
helpers. The field is additive and backward-compatible on the wire:
peers that send no records produce byte-identical encodings to before
this change, and unknown odd records are tolerated on receive.

The following commits use this field to carry revocation AuxSigs for
aux/custom (taproot asset) channels; a vanilla lnd channel never
populates it.
When an aux/custom (taproot asset) channel revokes a commitment that
was built with DeterministicHTLCs, the revoking party now signs the
second-level HTLC virtual transaction of every non-dust HTLC on the
commitment being revoked, and ships the signatures to the peer inside
the RevokeAndAck message's custom records. This hands the honest party
the asset-level puzzle piece it needs at breach time: if the cheater
later broadcasts the revoked commitment and takes an HTLC to the second
level, the breached party holds the cheater's half of the asset witness
for that transition.

An HTLC has exactly one second-level path on the commitment of the
party that revokes it: the success tx for an HTLC it received, the
timeout tx for one it offered. That is the path that is signed.

Changes:

- Sender: signLocalHtlcAuxSigs derives the second-level tx of each
  non-dust HTLC on the revoked commitment and submits a sign job to the
  aux signer. The signatures are packed as one TLV stream per HTLC,
  tagged with the HTLC's index and direction. The index alone does not
  identify an HTLC: both parties count the HTLCs they offer from zero,
  so a commitment regularly carries an incoming and an outgoing HTLC
  with the same index. One entry is packed per non-dust HTLC even when
  the signer produces no signature for it (a BTC-only HTLC), in
  lockstep with the BTC-level signatures. A signing failure fails the
  revocation as a whole, before any state is advanced: the peer
  requires the sigs, so a sig-less RevokeAndAck would just fail the
  channel on their side.

- Receiver: ReceiveRevocation verifies the received aux sigs against
  the revoked commitment's key ring BEFORE the revocation is accepted
  and the tail advances, then injects the sigs into the remote
  commitment's HTLC custom records so they are persisted in the
  revocation log for breach-time consumption. Presence is enforced,
  mirroring the aux sig count check on CommitSig: an entry is required
  for every non-dust HTLC on the revoked commitment (a peer cannot
  strip our breach protection by withholding the records), and entries
  for unknown or dust HTLCs are rejected. A verify job is handed to the
  aux signer for every non-dust HTLC, with or without a sig, as only
  the aux signer knows whether the HTLC carries aux outputs and
  therefore owes one. Whatever the peer put under our storage record
  type on its own UpdateAddHTLC is dropped before the sigs are
  injected, so only verified sigs reach the revocation log.

- Decoding: the blob comes from the peer and is decoded accordingly.
  The declared entry count never sizes an allocation, every entry must
  consume exactly the length it declares, an HTLC may appear only once
  and nothing may follow the last entry.

- Retransmission: the packed sig blob is persisted in a new optional
  TLV field on the channel info, written atomically with the
  commitment advance in UpdateCommitment, and re-attached when the
  RevokeAndAck is retransmitted on channel reestablish. Only the
  latest revocation can ever be owed, so a single overwritten slot
  suffices. If the write fails the previous blob stays in memory.

- BaseAuxJob gains the WhoseCommit and HtlcTimeout fields needed to
  describe a sign job for our own commitment to the aux signer.

The gate is factored into a single predicate,
exchangesRevocationAuxSigs, used by both hooks and (defense in depth)
inside the sign and verify functions themselves. It requires an
explicit HasTapscriptRoot() on the channel type, and that the
commitment being revoked records SigHashDefault in its own blob. Both
peers hold that record for the same commitment, so they agree on which
revocations carry the signatures even while the sighash type used for
new commitments is changing. A vanilla lnd channel never signs,
attaches, reads, or verifies these records and its RevokeAndAck is
byte-identical to before this change.
Coverage for the revocation AuxSig exchange introduced in the previous
commits:

- lnwire codec: encode/decode round trips for RevokeAndAck with and
  without custom records, including a byte-for-byte assertion that the
  no-records encoding is identical to the legacy wire format.

- TLV blob: pack/unpack round trips, including the same HTLC index in
  both directions, and rejection of corrupt and hostile blobs:
  truncation, garbage, duplicate entries, trailing bytes, undeclared
  entries, lengths beyond the blob, cut-off records, missing or invalid
  index and direction records. A declared entry count in the billions
  must not make the decoder allocate for it.

- Custom-channel-only gating: a non-custom taproot channel with an aux
  signer that pushes SigHashDefault attaches nothing and ignores stray
  records. The gate follows the sighash recorded for the commitment
  being revoked, not the one new commitments use.

- Happy path over a funded tapscript-root channel pair: one sig for
  every non-dust HTLC, the dust decision made with the dust limit of
  the commitment's owner, the sig matched to the right verify job, and
  the verified sig persisted into the revocation log entry of the
  revoked commitment.

- Same HTLC index in both directions: each HTLC is signed once for its
  own path, gets its own entry, and keeps its own sig through
  verification and persistence.

- BTC-only HTLCs: sig-less lockstep entries are attached, and accepted
  once the aux signer has been asked about them.

- Rejection before the remote chain tail advances: unverifiable sigs,
  malformed blob, missing sig for a non-dust HTLC, a sig tagged with
  the wrong direction, withheld blob, a sig withheld from its entry,
  the sig of another HTLC, an extra entry for an unknown HTLC index or
  for the other direction, and entries for HTLCs that are dust for
  both parties or for the signer only.

- A custom record the peer planted under our storage type never
  reaches the revocation log.

- Sign-time failure: an aux signer error fails RevokeCurrentCommitment
  before any state advances, for both batch-level and per-job errors.

- Retransmission: after a restart, with the channel rebuilt from disk,
  a retransmitted RevokeAndAck carries the original aux sigs without
  signing again, and the peer verifies and accepts them.
…tput

convertToSecondLevelRevoke set the sign descriptor's TapTweak to a slice
over the breached output's own secondLevelTapTweak array. updateBreachInfo
compacts the breachedOutputs slice in place once an output has been swept,
so the struct values shift while the slice keeps pointing at the old slot,
which now holds another output's tweak. Every second-level justice sweep
built after that point is signed with the wrong tweak, fails script
validation, and the second-level HTLC output stays unswept until restart.

Copy the tweak into its own backing array instead. The test reproduces the
sequence: two HTLC outputs morph to the second level, the commitment output
is swept and removed, and the remaining outputs must still sign with their
own tweak.
Pass the breach height through the call chain from NewBreachRetribution
to createHtlcRetribution, and include it in the ResolutionReq for HTLC
outputs via CommitTxBlockHeight.

This is required for taproot-assets to properly reanchor asset proofs
when sweeping revoked HTLCs. The reanchorAssetOutputs function needs
the block height to fetch the block containing the breach commitment
transaction and construct valid proofs for the sweep.

Without this, the CommitTxBlockHeight defaults to 0, causing tapd to
look for the commitment tx in the genesis block and fail with:
"commit tx not found in block".

See: lightninglabs/taproot-assets@815021fd (tapchannel: add
reanchorAssetOutputs for proof reanchoring)
Second-level HTLC auxiliary leaves need to be computed at runtime from
the channel state, key ring, and commitment transaction, rather than
being stored in the commitment blob. Extend the FetchLeavesFromRevocation
interface method to accept these additional parameters so that
implementers can derive the leaves on the fly.
When an HTLC is taken to the second level — whether during a breach or
during a regular force close — the aux contract resolver needs to re-resolve
the contract with the actual second-level transaction once it confirms.

Preserve the original ResolutionReq as a template:
- in HtlcRetribution, so the breach arbiter can re-resolve with a
  different witness type
- on IncomingHtlcResolution / OutgoingHtlcResolution, so the htlc
  success and timeout resolvers can do the same once their pre-signed
  second-level tx confirms

Also add SecondLevelTx and SecondLevelTxBlockHeight fields to
ResolutionReq so the resolver can re-anchor proofs to the second-level
transaction rather than the commitment transaction. Populate HtlcAmt in
the resolution request so the resolver has the HTLC value available.

Add a NewSecondLevelResolveReq helper that reconstructs the
ResolutionReq at re-resolve time, re-deriving the commitment key ring
from RevocationProducer.AtIndex(LocalCommitment.CommitHeight) so the
plumbing does not have to round-trip the key ring through the
briefcase.
When constructing HtlcRetribution for a breached commitment, extract
the remote party's asset-level HTLC signature from the revocation
log's CustomBlob and populate AuxSigDesc on the ResolutionReq. This
allows the aux subsystem to construct valid asset witnesses for the
commitment → second-level proof transition, making breach-recovered
assets fully spendable.
Wire the revocation AuxSigs (delivered via RevokeAndAck and persisted in
the revocation log) into the breach retribution.

createHtlcRetribution extracts the remote party's revocation aux sig
from the custom records of the breached HTLC (auxSigDescFromHTLCBlob)
and hands it to the aux resolver via AuxSigDesc, so the resolver holds
the remote half of the asset witness for the second-level path the HTLC
has on the revoked commitment. Only the revocation sig qualifies. The
CommitSig aux sig that can sit in the same records covers the
second-level HTLC of our own commitment, which is a different
transaction, so a state that was revoked without revocation aux sigs
reports no sig at all.

The resolution request of a breached HTLC now states the direction of
the HTLC (HtlcIncoming). The witness type of a second-level revocation
covers both directions, and HTLC IDs are per-offerer counters that both
start at zero, so without it the aux resolver cannot tell an incoming
HTLC from an outgoing one with the same ID.

A failure of the aux resolver for one HTLC no longer fails the whole
retribution. Nothing retries a breach handoff that errors out, so one
HTLC the resolver cannot handle would leave the commitment outputs and
every other HTLC of the revoked state unpunished. The HTLC is instead
handed over without a blob and swept for its BTC value.
Teach the breach arbiter to handle the breach of an aux (custom) channel
whose HTLCs are taken to the second level, and to tell the aux sweeper
about the justice transaction that confirms.

Second-level outputs:

- findSecondLevelOutputIndex locates the second-level output of an aux
  channel HTLC by script match rather than by SpenderInputIndex, which
  diverges from the output index when the spending tx carries other
  inputs. Several HTLCs can share a second-level script, so outputs
  that already belong to another breached output are skipped, and the
  output at the index of the spending input is preferred. Regular
  channels keep using SpenderInputIndex.

- convertToSecondLevelRevoke re-resolves the aux blob against the
  confirmed second-level tx through the AuxContractResolver, using the
  resolution request template preserved at breach detection. Everything
  is worked out before the breached output is touched. If the output
  cannot be located, the breached output is dropped without being
  counted as claimed. If the aux resolver fails, the output is still
  converted and swept for its BTC value, without the blob that was
  resolved for the commitment output.

- With an aux output, the BTC sweep output of a justice tx is only
  added above the dust limit. Below it the remaining BTC goes to fees,
  and the reported fee is what the tx really pays. A justice tx whose
  inputs cannot fund the aux output is rejected. Without an aux output
  the tx is built exactly as before.

Aux sweeper notification:

Previously the breach arbiter called NotifyBroadcast on the aux sweeper
when the spendAll justice tx was first broadcast. That fires too early
and for one variant only: the aux sweeper imports proofs on broadcast,
but the variant that ends up confirming may be a different one, built
in a later rebuild cycle.

A justiceTxTracker now records every justice tx variant created for the
breach and reports the one that confirms, exactly once and with all of
its inputs, which it collects from the spends that report the tx. A
notification the aux sweeper fails to take is retried on every block,
and the breach is only cleaned up after it went through.

The notification options are carried by a new AuxNotifyOpts struct on
AuxSweeper.NotifyBroadcast: SkipBroadcast (the tx is already
confirmed), ConfirmHeight (a height hint for the confirmation) and
LookupInputProofs (the inputs include second-level outputs, whose
proofs were imported after their blob was resolved).

All of this is gated on aux resolution data being present, so the
breach of a regular channel is handled exactly as before. AuxResolver
is wired into BreachConfig from server.go.
The retribution store only persists what it takes to sweep the BTC of a
breached channel. For an aux channel that is not enough to pick a
breach up again after a restart:

- The aux resolution blobs of the breached HTLCs and their resolution
  request templates are built at breach detection from the revocation
  log, which is gone once the channel is closed. Without them an HTLC
  is swept without its aux value, and one that is taken to the second
  level is handled like the HTLC of a regular channel.

- The justice transactions built after a restart pay to a new address
  with a new fee. A justice tx that was broadcast before the restart
  and confirms afterwards is therefore not recognized, and the aux
  sweeper is never told about it.

Store the HTLC blobs in the taproot briefcase next to the commitment
blobs. Store the request templates, split into the part all HTLCs
share and the per-HTLC remainder, and the metadata of every justice tx
created for the breach in a new aux retribution bucket. The
retribution loop records its justice txs before publishing them and
seeds its tracker from the store. After a restart the spends are
replayed from the breach on, so the confirmed justice tx is reported
to the aux sweeper again, with the inputs as they are resolved then.

Nothing is written to the new bucket for regular channels.
Under DeterministicHTLCs the pre-signed second-level HTLC tx is
published verbatim by the sweeper, without going through the aux
sweeper's NotifyBroadcast hook, so the aux sweeper never imports the
second-level proof transition into its archive and the upcoming output
sweep would fail to fetch its input proof. Before offering the
second-level output to the sweeper, give the aux resolver a chance to
import the confirmed second-level tx into its proof archive by
re-resolving the contract against it.

The fast path clones the ResolveReq preserved on the htlcResolution at
force-close time and only swaps the second-level context
(SecondLevelInfo). The slow path (resolvers recovered from a briefcase
checkpoint, where the in-memory ResolveReq is gone) reconstructs the
request from historical channel state via NewSecondLevelResolveReq.

The whole path is gated on isSigHashDefault(): only a pre-signed
SigHashDefault second-level tx confirms exactly as we hold it. On an
aux channel whose second-level txs are signed with SINGLE|ANYONECANPAY
the sweeper rebuilds the tx, so the blob resolved at force close time
is kept, as before. The gate also guarantees that this never executes
for a non-custom channel, although the AuxResolver is a daemon-global
option that is present on every resolver.
The direct signing path was taught to apply the revocation (double) and
HTLC-index (single) tweaks together in 8125286, but the PSBT path used
by remote signers still returned after the first tweak unknown it
encountered, silently dropping the other one. A watch-only node with a
remote signer would then derive a wrong signing key for second-level
HTLC signing on aux channels, where both tweaks are attached. Mirror the
combined derivation (double first, then single) and cover all tweak
combinations and unknown orderings with a test.
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

severity-critical Requires expert review - security/consensus critical

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants