staticaddr/loopin: check deposits before htlc signing

Before we send HTLC signatures to the server, the server cannot publish
the HTLC transaction. After those signatures are handed over, the server
can publish an HTLC that spends the selected deposits even if it never
pays the swap invoice.

Defend against stale local deposit state by checking the wallet's current
txout view immediately before signing. A deposit can have been spent by a
known withdrawal, channel open, timeout sweep, replacement, or another
wallet transaction while the loop-in FSM is recovering or while earlier
state still marked it as selected.

Failing before signing leaves the server without spend authority over an
unavailable input. Include mempool spends in the check so wallet-known
unconfirmed spends are treated as unavailable too.
This commit is contained in:
Slyghtning 2026-07-02 10:48:13 +02:00
parent bd3882d5b0
commit 6582aa0807
No known key found for this signature in database
GPG key ID: F82D456EA023C9BF
4 changed files with 159 additions and 0 deletions

View file

@ -692,6 +692,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
Server: staticAddressClient,
QuoteGetter: swapClient.Server,
LndClient: d.lnd.Client,
TxOutChecker: loopin.NewLndTxOutChecker(d.lnd.Client),
InvoicesClient: d.lnd.Invoices,
NodePubkey: d.lnd.NodePubkey,
AddressManager: staticAddressManager,