Table of Contents

Class SwapPreimageReader

Namespace
NArk.ArkadeIntents.Lightning
Assembly
NArk.ArkadeIntents.dll

Reads a swap's preimage back out of whatever spent its lockup.

public static class SwapPreimageReader
Inheritance
SwapPreimageReader
Inherited Members

Remarks

A Lightning swap is filled only when a preimage proves it, and this is where that proof comes from. Nothing else in a spend distinguishes a fill from a refund: the covenant's non-interactive refund carries no timelock, so the counterparty can push it at any moment, and both leaves leave the same trace — an output that used to be there and now is not.

Every candidate is checked against the payment hash before it is believed. A witness of the right shape is not evidence; a preimage that hashes to the invoice's own hash is, and it is evidence nobody can forge, which is what makes this safe to act on without trusting the counterparty's account of what it did.

Methods

FindAsync(IClientTransport, OutPoint, string, string, CancellationToken)

Find the preimage in the transaction that spent lockup, if it revealed one.

public static Task<byte[]?> FindAsync(IClientTransport transport, OutPoint lockup, string spendingTxid, string paymentHashHex, CancellationToken cancellationToken = default)

Parameters

transport IClientTransport

Where to fetch the spending transaction from.

lockup OutPoint

The lockup outpoint the swap was funded at.

spendingTxid string

The transaction that spent it.

paymentHashHex string

The invoice's payment hash, big-endian hex.

cancellationToken CancellationToken

Cancels the fetch.

Returns

Task<byte[]>

The preimage, or null when the spend proved none.

Remarks

A null answer never means "refunded" on its own — an unreachable indexer and a transaction that genuinely carried no preimage are the same silence here, and both callers should treat the same way: the swap is not provably filled, which is all this can honestly say.