server: settle CLN hold invoices from on-chain HTLC preimage discovery

When a user emergency-exits an HTLC-recv VTXO on-chain, the preimage is revealed in the spending witness but previously went unnoticed by the server. This branch closes that gap:

HtlcSettler + htlc_settlement table — a new WAL + watch-notify layer. Producers call settle() to record a (payment_hash, preimage) pair; consumers subscribe via a watch channel and query by checkpoint for streaming.

extract_preimage_from_witness — new method on HashDelaySignClause that pulls the 32-byte preimage from a witness and validates it against the expected payment hash.

Frontier integration — when a ServerHtlcRecv VTXO is spent on-chain, the witness is inspected and any valid preimage is recorded via the settler.

CLN settlement subscriber — a background task that follows the settler's watch channel and settles CLN hold invoices as new preimages appear.

Bug fix — corrected a guard in update_lightning_invoice that used || instead of &&, causing updates to be skipped when only one of preimage/finalized was set.

See SEC-18.

Edited by Duncan Dean

Merge request reports

Loading