> ## Documentation Index
> Fetch the complete documentation index at: https://www.bitnob.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Bitnob has two APIs. The Business API (payouts, cards, trading, virtual accounts, stablecoin and bitcoin transfers) is at https://api.bitnob.com. The Enterprise API (non-custodial wallets) is at https://api.platform.bitnob.com.
> Business API auth: sign every request with HMAC-SHA256 and send four headers: `X-Auth-Client` (your client ID), `X-Auth-Timestamp` (Unix seconds), `X-Auth-Nonce` (16 random bytes, hex), and `X-Auth-Signature`, the hex HMAC-SHA256 of `CLIENT_ID:TIMESTAMP:NONCE:BODY` keyed with your client secret. BODY is the exact request body string you send, or an empty string. A missing header, a bad signature, or a timestamp more than about 5 minutes off returns `401`.
> Enterprise API auth: send your key in the `X-API-Key` header. Write requests such as creating a transaction also need an `Idempotency-Key` header, or they fail with `idempotency_key_required` before anything happens.
> Sandbox and production share the Business API base URL. The credentials you sign with select the environment, and `GET /api/whoami` returns it in `data.environment`. Use sandbox credentials in sample code and tests, and never put live credentials in code.
> Amounts are strings unless stated otherwise. Never parse them into floats. Balances, transactions, withdrawals (`POST /api/withdrawals`) and virtual accounts use integer strings in the smallest unit: satoshis for BTC, 6 decimals for USDT and USDC, kobo for NGN, and cents for KES and UGX (100 is 1 KES or 1 UGX). A mobile money collection takes `amount` as a JSON integer in cents.
> Payouts and trading use decimal strings in major units: a payout quote `amount` of `"1"` is 1 USDT, and a trading `quantity` of `"0.0001"` is 0.0001 BTC. Payout responses also carry `cent_amount`, the settlement amount in minor units.
> Card amounts are micro-units (1 USD = 1,000,000). Send them as JSON integers. Card responses return them as integer strings, and card webhooks as integers.
> Generate a unique `reference` for each money movement before the first attempt, and reuse it on retries. A reused reference returns `409` on payout quotes (`ALREADY_EXISTS`), withdrawals (`DUPLICATE_KEY_ERROR`) and card creation (`ALREADY_EXISTS`). It returns the existing record on NGN-pair trading orders, NGN virtual accounts and active mobile money collections. On a mobile money collection that has closed or failed it returns `409` `DUPLICATE_REFERENCE`. It isn't checked on crypto-pair trading orders, so look the order up with `GET /api/trading/orders/{reference}` before resending.
> Quotes expire at `expires_at`; read it from the response instead of assuming a window. An expired trading quote returns `422` `PRECONDITION_FAILED`, and an expired payout quote returns `400` `VALIDATION_ERROR`. Create a new quote rather than retrying. A payout quote can be initialized once, and a trading quote is consumed by the order that fills it.
> Webhooks: verify the `x-bitnob-signature` header, the hex HMAC-SHA512 of the raw request body keyed with your webhook secret, before parsing JSON. Compare in constant time and de-duplicate on `event_id`. A successful API response means accepted: confirm the outcome from the webhook, such as `payouts.withdrawal.success`.
> Errors return `status`, `code` and `detail`. Branch on `code`, never on `detail`. Since the November 5, 2026 response format change, each company gets either the current or the new error codes until its cutoff date, so handle both: `PROVIDER_ERROR` or `PROCESSING_ERROR`, and `BVN_PROVIDER_UNAVAILABLE` or `BVN_VERIFICATION_UNAVAILABLE`. A body that fails to parse returns `{"error": {"code": "BAD_REQUEST"}}`.

# Build self-custodial wallets

> Self-custodial wallets where users hold their own keys and Bitnob supplies only blockchain access.

Bitnob provides Bitcoin blockchain infrastructure for businesses that want to build fully non-custodial wallets.

## The model

Users generate and control their own private keys.

All transaction signing happens on user devices.

Bitnob provides address monitoring, transaction broadcasting, fee estimation, and blockchain queries.

Bitnob never touches private keys, unsigned transactions, or funds.

## Core concepts

| Concept | Description |
| - | - |
| Self-Custody | Users fully control their wallets and private keys. |
| Bitnob’s Role | Backend Bitcoin infrastructure (broadcasting, fee estimation, monitoring). No keys. No custody. |
| Signing Transactions | Must happen locally on the user’s device. |
| Address Types Supported | Legacy (P2PKH), Nested SegWit (P2SH), Native SegWit (P2WPKH), Taproot (P2TR). |

## Developer responsibilities

Generate Bitcoin wallets securely (BIP32, BIP39, BIP44 recommended).

Build full key management and signing flows into your app.

Query balances, broadcast transactions, and monitor addresses using Bitnob APIs.

Never send private keys or seed phrases over the network.

## Recommended development tools

You can use established open-source Bitcoin developer toolkits such as:

| Tool | Description |
| - | - |
| BDK (Bitcoin Development Kit) | A modern, production-grade toolkit for building Bitcoin wallets, developed by Spiral (backed by Block, Inc.). Supports key generation, descriptor wallets, transaction building and signing. |
| bitcoinjs-lib (JavaScript) | Lightweight Bitcoin library for address derivation, transaction signing, etc. |
| Noble Bitcoin Libraries (JavaScript) | Simple and audited libraries for Bitcoin cryptography. |
| btcd / lnd libraries (Go) | For backend-heavy Bitcoin apps (more advanced). |

> [!TIP]
>
> BDK is highly recommended if you are building serious mobile or cross-platform Bitcoin wallets. It handles key generation, descriptor wallets, UTXO management, fee calculation, and transaction signing efficiently.
>
> You can integrate BDK with Bitnob as your backend broadcast and monitoring layer.

BDK supports languages like:

* Rust (core)
* Swift (iOS apps)
* Kotlin (Android apps)

## Key APIs provided by Bitnob

| Action | Method | Endpoint |
| - | - | - |
| Watch address | POST | /api/noncustodial/bitcoin/address/watch |
| Watch multiple addresses | POST | /api/noncustodial/bitcoin/address/watch/bulk |
| Broadcast signed transaction | POST | /api/noncustodial/bitcoin/transaction/broadcast |
| Batch broadcast transactions | POST | /api/noncustodial/bitcoin/transaction/batch/broadcast |
| Estimate fees | GET | /api/noncustodial/bitcoin/fees/estimate |
| Fetch address balance | GET | /api/noncustodial/bitcoin/address/balance |
| Fetch address transactions | GET | /api/noncustodial/bitcoin/address/transactions |

## Putting it all together

This section walks through how you can build a real Bitcoin non-custodial wallet using Bitnob RPCs.

1. Step 1: Wallet Generation (Onboarding New User)

   Use BDK (or bitcoinjs-lib) on the client device.

   Generate a new BIP39 seed phrase.

   Derive master private and public keys.

   Generate the first Bitcoin address (SegWit or Taproot recommended).

   Offer the user a backup flow for the seed phrase.

   Example: Mobile app using BDK-Swift (iOS) or BDK-Kotlin (Android). Bitcoin address displayed as QR code.

2. Step 2: Display Wallet Dashboard

   Query address balances using Bitnob API.

   Display recent transaction history from Bitnob.

   Update balances automatically via webhook listening or scheduled polling.

3. Step 3: Receiving bitcoin

   Show fresh address (or rotate automatically after each payment).

   Monitor address with Bitnob's webhook service.

   Detect inbound payments and confirmations.

4. Step 4: Sending bitcoin

   Fetch UTXOs if needed.

   Use BDK or bitcoinjs-lib to build a transaction (inputs, outputs).

   Estimate fees dynamically with Bitnob's fee API.

   Sign transaction locally using the user's private key.

   Push signed transaction to Bitnob /transaction/broadcast.

5. Step 5: Wallet Operations

Periodically rotate addresses to preserve privacy.

Allow users to label transactions internally.

Show mempool status for pending transactions.

Support Replace-By-Fee (RBF) for speeding up transactions later (optional advanced feature).

## Real-World sample implementation outline

| Component | Tools/ Libraries | Purpose |
| - | - | - |
| Key Generation | BDK (Swift, Kotlin, Rust) / bitcoinjs-lib | Secure private key and address generation |
| Transaction Building | BDK, bitcoinjs-lib | Assemble and sign transactions on device |
| Blockchain Interface | Bitnob APIs | Fetch balances, broadcast transactions, monitor addresses |
| Webhooks | Bitnob Webhooks | Real-time transaction notifications |
| Backup & Recovery | Manual seed backup, optional cloud backup (encrypted) | Protect against device loss |

## Key benefits of this model

You control the user experience 100%.

Your users retain their privacy and custody.

You avoid needing to run and maintain Bitcoin full nodes.

You can scale globally with minimal blockchain overhead.

You are ready for advanced Bitcoin features like Taproot, Schnorr signatures, and Miniscript when needed.

## Example full system flow diagram

![Example Full System Flow Diagram](https://mintcdn.com/bitnob/SHTitgOAvySrbvsS/images/system-flow-diagram.webp?fit=max\&auto=format\&n=SHTitgOAvySrbvsS\&q=85\&s=36ef43e91c53ecb623b06029b812d12c)

Use BDK or similar libraries for secure wallet building: avoid reinventing cryptography.

Use Bitnob purely for node-level services, blockchain broadcast, monitoring, fee suggestion.

Prioritize user education on backups, security, and transaction confirmations.

Building non-custodial wallets is challenging, but with Bitnob's backend + open-source Bitcoin SDKs like BDK, it becomes achievable even for small teams.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.