Skip to main content
In this tutorial you send BTC from your Bitnob account to any valid destination: a traditional on-chain address, or a Lightning invoice. Both draw on the same BTC wallet, so you do not manage separate balances or move funds between wallets to pick a rail. This flow suits a withdrawal feature, a payout system that pays to Bitcoin wallets, or merchant rails that accept both destination types.

Prerequisites

  • A verified Bitnob account.
  • API credentials, and a working signed request. See Quickstart.
  • BTC in your Bitnob wallet, funded on-chain or over Lightning.
  • A destination: a BTC address or a BOLT11 invoice.
Bitnob creates the BTC wallet for you. You do not need to create one manually.

The two rails

Funds come from the same wallet either way.
1

Collect the input

From your interface or backend, gather the amount, the destination, and your own reference for tracking. The destination format decides the rail: an address means on-chain, a string beginning lnbc (lntb in sandbox) means Lightning.Validate the destination before you call the API. A malformed address is the most common cause of a failed send, and it is cheaper to catch client-side.
2

Send on-chain

The response confirms the withdrawal was accepted, not that it confirmed on-chain. Wait for the transfer.success webhook before telling the user it is done.
3

Or send over Lightning

Because the invoice carries the amount, you do not pass one. If the invoice is valid and the node is reachable, the payment completes and is confirmed in the response. preimage is the cryptographic proof of payment: store it.
To read an invoice before paying it, for example to show the user the amount and fee, call Decode BOLT11 or Preview payment.
4

Confirm the outcome

On success you get a transaction id and your reference back, and the wallet balance updates. Resolve either identifier later with Get transaction by id or reference, and check the balance with Get balances.Record the reference and the returned transaction id against the user in your own database. If you are moving user funds, log the destination too, for audit.

When it fails

Handle all outcome messaging through webhooks rather than the synchronous response, and make the handler idempotent. See Confirmations and webhook events.

Next

Confirmations and webhook events

When a payment is safe to treat as final.

Fees and confirmation strategy

Choosing a fee rate, and rescuing a stuck transaction.

Issue addresses and invoices

The inbound direction.

Custody models

Who holds the keys, and what that changes.