Choose between an on-chain payment and an offboard
Both forfeit VTXOs to deliver an on-chain output to one address. Pick the one that matches what the user asks for:
An offboard of the entire balance also takes the VTXOs in
needs_refresh_sat, which an Ark payment cannot spend (balances covers that field). Neither call needs an on-chain balance, since the fee comes out of the Ark balance.
Estimate the fee before the user confirms
The Ark server sets the on-chain payment fee. It depends on the amount, the remaining lifetime of the VTXOs, the current feerate, and the destination’s address type. Ask Bark for an estimate:- Bark SDK
- Bark CLI
- Barkd
estimateSendOnchainFee(address, amountSats)prices an on-chain payment.estimateOffboardAllFee(address)prices an offboard of the entire balance.estimateOffboardFee(address, vtxoIds)prices an offboard of chosen VTXOs.
grossAmountSats, feeSats, netAmountSats, and vtxosSpent.- Show the total next to the fee: For an on-chain payment, the gross amount leaves the Ark balance and the recipient receives the net amount. For an offboard, the net amount arrives on-chain.
- Estimate again when the confirmation screen opens: Bark computes the fee again when the send starts, so the movement can show a different fee from an older estimate.
- Disable the send action when
vtxos_spentis empty: Bark cannot make that on-chain payment. This happens when the Ark balance does not cover it, or when it needs more VTXOs than the Ark server allows in one transaction. - Refuse dust before the call: Bark rejects an on-chain payment below the dust limit of the destination’s address type, 330 sats for a taproot address. Refuse an offboard when the estimate’s net amount is below that limit.
Send the payment or start the offboard
- Bark SDK
- Bark CLI
- Barkd
sendOnchain(address, amountSats)pays an address.offboardAll(address)moves the entire Ark balance.offboardVtxos(vtxoIds, address)moves chosen VTXOs.
txid of the transaction and a movementId.max_offboard_inputs in bark ark-info). When an offboard of the entire balance would take more VTXOs than that cap, offboard chosen VTXOs in batches instead.
Track the transaction until it confirms
Drive the screen from the movement that the call returns:- Balance: Until Bark broadcasts the transaction, the sats sit in
pending_offboard_sat. At broadcast, the sent amount and the fee leave the Ark balance. - Status: The movement stays
pendinguntil the transaction has enough confirmations, then turnssuccessful. Show it as confirming, with the transaction ID fromoffboard_txidin itsmetadata. - Confirmations: Bark waits for
offboardRequiredConfirmationsconfirmations (offboard_required_confirmationsin Rust andconfig.toml). The default is 2 on mainnet and 0 on other networks. At 0, the movement turnssuccessfulonce Bark sees the transaction in the mempool. - Sync: Bark checks the transaction during a sync. The bark library’s background daemon syncs on its own. Without it, call
sync(). On the CLI, run a command that syncs, such asbark balance. - Offboard to Bark’s on-chain wallet: Sync the on-chain wallet as soon as the call returns, so the amount shows as unconfirmed on-chain bitcoin.
Check for a running attempt before a retry
After an error from the call, an attempt can still be running. Sync the wallet, then check in this order:pending_offboard_satis above 0: Bark still holds VTXOs for an attempt and continues it on each sync. Do not send again.- A movement of kind
send_onchainoroffboard, created since the call, ispendingorsuccessful: The transaction is on the network. Do not send again. - Neither applies: No attempt is running. A
failedmovement means that no forfeit took effect and Bark broadcast nothing. Estimate the fee again, then retry.
pending_offboard_sat stays above 0 through several syncs, read Bark’s log for the reason.
A broadcast transaction can also go missing from both the chain and the mempool. Bark broadcasts it again during offboard_lost_tx_grace_period_secs (in Rust and config.toml), one hour by default. After that the movement stays pending and the VTXOs stay locked, because the Ark server can still broadcast the transaction. Show the transaction ID so the user can follow it on a block explorer.
How Bark Wallet does it
How Bark Wallet does it
- On-chain payment: For an on-chain destination, Bark Wallet shows the estimated fee under the amount and a “Pay from” selector that defaults to the Ark balance.
- History: The on-chain payment appears in the history with its status.
- Offboard: The VTXOs page offers an “Offboard” action on the selected VTXOs. It pays an address the user pastes, or the wallet app’s own on-chain wallet with “Use my Bark on-chain wallet”.
- Fee: Bark Wallet deducts the fee from the offboarded amount.