Class OnchainClaimBuilder
- Namespace
- NArk.ArkadeIntents.Onchain
- Assembly
- NArk.ArkadeIntents.dll
Builds the Bitcoin-L1 transaction that claims an HTLC by publishing its preimage.
public static class OnchainClaimBuilder
- Inheritance
-
OnchainClaimBuilder
- Inherited Members
Remarks
Signing is a delegate rather than a wallet, so the transaction this produces can be checked against a recomputed sighash without one. That check is the point: everything else about a script-path spend is shaped correctly long before it is spendable, and a wrong sighash, leaf hash or witness order all produce a transaction that looks right and the network rejects.
Fields
DustSats
The smallest payout worth broadcasting, in sats.
public const long DustSats = 330
Field Value
Methods
BuildAsync(OnchainHtlc, IReadOnlyList<BoardingUtxo>, byte[], BitcoinAddress, FeeRate, Func<uint256, Task<SecpSchnorrSignature>>, CancellationToken)
Build and sign the claim.
public static Task<Transaction> BuildAsync(OnchainHtlc htlc, IReadOnlyList<BoardingUtxo> inputs, byte[] preimage, BitcoinAddress payoutAddress, FeeRate feeRate, Func<uint256, Task<SecpSchnorrSignature>> signAsync, CancellationToken cancellationToken = default)
Parameters
htlcOnchainHtlcThe HTLC being claimed.
inputsIReadOnlyList<BoardingUtxo>The outputs at its address to sweep. All of them, not the largest.
preimagebyte[]The secret the claim leaf gates on.
payoutAddressBitcoinAddressWhere the sweep pays.
feeRateFeeRateWhat to pay for the weight.
signAsyncFunc<uint256, Task<SecpSchnorrSignature>>Produces a BIP-340 signature over a sighash.
cancellationTokenCancellationTokenCancels between signatures.
Returns
- Task<Transaction>
The signed transaction, ready to broadcast.
Exceptions
- ArgumentException
preimageis not this HTLC's.- InvalidOperationException
The fee leaves nothing worth paying out.
VirtualSize(OnchainHtlc, int, BitcoinAddress)
The signed transaction's virtual size, in vbytes.
public static int VirtualSize(OnchainHtlc htlc, int inputCount, BitcoinAddress payoutAddress)
Parameters
htlcOnchainHtlcinputCountintpayoutAddressBitcoinAddress
Returns
Remarks
Computed from the parts rather than measured, because the fee has to be known before the signatures exist. Every witness item is counted at the size it will actually be: a 64-byte BIP-340 signature, a 32-byte preimage, and the leaf and control block this HTLC already carries — none of which is an estimate.