Table of Contents

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

long

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

htlc OnchainHtlc

The HTLC being claimed.

inputs IReadOnlyList<BoardingUtxo>

The outputs at its address to sweep. All of them, not the largest.

preimage byte[]

The secret the claim leaf gates on.

payoutAddress BitcoinAddress

Where the sweep pays.

feeRate FeeRate

What to pay for the weight.

signAsync Func<uint256, Task<SecpSchnorrSignature>>

Produces a BIP-340 signature over a sighash.

cancellationToken CancellationToken

Cancels between signatures.

Returns

Task<Transaction>

The signed transaction, ready to broadcast.

Exceptions

ArgumentException

preimage is 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

htlc OnchainHtlc
inputCount int
payoutAddress BitcoinAddress

Returns

int

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.