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
transportIClientTransportWhere to fetch the spending transaction from.
lockupOutPointThe lockup outpoint the swap was funded at.
spendingTxidstringThe transaction that spent it.
paymentHashHexstringThe invoice's payment hash, big-endian hex.
cancellationTokenCancellationTokenCancels the fetch.
Returns
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.