sendNight

suspend fun sendNight(toAddress: String, amount: BigInteger, onProgress: (MidnightSdk.SendProgress) -> Unit? = null): MidnightSdk.SendResult

Send unshielded NIGHT from this wallet to toAddress (#240 — Send from the wallet pill).

Fee-bearing transfer: the NIGHT inputs are signed (BIP-340), and dust fees are built and paid automatically from the wallet's registered dust — the same submitWithFees path contract calls use. The wallet must have:

Inputs come from the SDK's already-derived state: NIGHT private key for the per-input signatures, dust seed for the fee, the live utxoManager for the spendable NIGHT UTXOs (kept current by the build-time subscription). On any failure after UTXOs are locked, the locks are released so the balance isn't stuck PENDING. On success/pending the wallet is refreshed so the pill reflects the new balance immediately.

Return

a typed SendResult — never throws for an expected failure (invalid address, insufficient funds, chain rejection); unexpected errors map to SendResult.Failed.

Parameters

toAddress

Recipient's unshielded Bech32m address; must be the same network (HRP) as this wallet.

amount

NIGHT to send, in the smallest unit (must be positive).

onProgress

Optional coarse progress callback for driving a UI spinner.