Spending
Automatic Coin Selection
The simplest way to send — the SDK selects coins automatically:
var txId = await spendingService.Spend(
walletId,
[new ArkTxOut(ArkTxOutType.Vtxo, Money.Satoshis(50_000), recipientAddress)],
cancellationToken);
The DefaultCoinSelector uses a greedy algorithm that:
- Sorts coins by amount (descending)
- Selects until target is met
- Handles sub-dust change as OP_RETURN outputs
- Falls back to adding more coins if change is sub-dust and OP_RETURN limit is reached
Manual Coin Selection
For full control, specify inputs explicitly:
var coins = await spendingService.GetAvailableCoins(walletId, ct);
var selected = coins.Where(c => c.Amount > Money.Satoshis(10_000)).ToArray();
var txId = await spendingService.Spend(
walletId,
selected,
[new ArkTxOut(ArkTxOutType.Vtxo, Money.Satoshis(50_000), recipientAddress)],
cancellationToken);
Sub-Dust Outputs
Outputs below the dust threshold are converted to OP_RETURN outputs. The server configures the maximum number of OP_RETURN outputs per transaction (default: 3).
Collaborative Exit (On-Chain Withdrawal)
To move funds from Arkade back to on-chain Bitcoin:
var txId = await spendingService.Spend(
walletId,
[new ArkTxOut(ArkTxOutType.Onchain, Money.Satoshis(100_000), onchainAddress)],
cancellationToken);