> ## 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"}}`.

# Fees and confirmation strategy

> How the Bitcoin fee market prices blockspace, and the estimation, batching, RBF, and CPFP strategies that keep costs predictable.

## Introduction: Why fees matter

Unlike traditional payment networks where fees are often static or hidden, Bitcoin operates on a dynamic fee market:

Fees are determined by supply and demand for blockspace.

Users compete to have their transactions included in blocks.

Fees can fluctuate dramatically over short periods depending on network congestion.

> [!NOTE]
>
> In Bitcoin, you are not paying for the amount of bitcoin sent. You are paying for the size (in virtual bytes / vBytes) of your transaction.

Building a non-custodial Bitcoin wallet means you must account for fee dynamics at every step of your product design.

Poor fee handling destroys user experience during congestion periods.

## Core concepts in Bitcoin fee markets

| Terms | Description |
| - | - |
| Fee rate | Amount of satoshis paid per virtual byte sats/vByte. |
| Mempool | Waiting area for unconfirmed transactions. |
| Block target | Number of blocks in which the user hopes the transaction gets confirmed. |
| Replace-by-Fee (RBF) | A Bitcoin protocol feature that allows users to bump the fee of an unconfirmed transaction by creating a replacement transaction. |
| Child-Pays-For-Parent (CPFP) | A technique where a new transaction (child) spends from a stuck parent transaction with a high enough fee to "drag" both into confirmation. |

## How fee markets actually behave

| Situation | Fee Behavior |
| - | - |
| Low network activity | 1–2 sat/vByte transactions confirm within a few blocks. |
| Medium congestion | 10–20 sats/vByte becomes typical. |
| Major congestion (mempool backlog) | 50–200+ sats/vByte needed for fast confirmations. |
| Fee spikes (e.g., Ordinals, BRC-20 craze) | 500+ sats/vByte may be required for next-block confirmation. |

During fee spikes:

Cheap transactions get stuck for hours or days.

Users who don't understand fees will panic.

Wallets that handle fee strategies poorly will get bad reviews.

## Best practices for fee handling in non-Custodial wallets

1. Offer Fee Options: Fast, Normal, Economical

   At send time, allow users to select their preferred speed vs cost tradeoff.

   Example UI:

   | Option | Target Confirmation Time | Est. Fee Rate |
   | - | - | - |
   | Fast | Next block (\~10 min) | High fee |
   | Normal | 3–6 blocks (30–60 min) | Moderate fee |
   | Economy | 6+ blocks (1+ hour) | Low fee |

   > [!TIP]
   >
   > Use Bitnob's fee estimation API to fetch real-time fee recommendations.

2. Show Actual Fee Costs in Bitcoin and Fiat

   Do not just show users "10 sats/vByte". Instead, calculate:

* Estimated total transaction size in vBytes
* Total fee in satoshis
* Total fee in USD (or user's local currency)
* Example
* Transaction Size: 200 vBytes
* Fee Rate: 20 sats/vByte
* Estimated Total Fee: 4,000 sats (\~\$1.80)

  Show the estimated fee clearly before broadcasting.

3. Support Replace-by-Fee (RBF)

   If a user's transaction gets stuck:

   Allow them to bump the fee using Bitcoin's RBF feature.

   Present a "Speed up this transaction" option in the UI.

   Build your transaction building engine to mark transactions as RBF replaceable

   (sequence \< 0xffffffff - 1).

   This greatly improves user experience during fee spikes.

4. Consider Child-Pays-For-Parent (CPFP)

   In case the wallet spends from a stuck unconfirmed transaction:

   Automatically offer a CPFP option where a new transaction pays enough fee to pull both into confirmation.

   BDK and advanced libraries can help with CPFP constructions.

5. Warn About Low-Fee Transactions

If a user tries to send with a very low fee:

Show a warning:

"This transaction may take several hours or days to confirm due to low fees. Proceed anyway?"

Optionally, default users to Normal or Fast unless they explicitly choose Economy.

## UX design for Bitcoin fees

Designing around fees is not just a technical problem. It’s a UX problem.

| Ux Mistake | Correct Design |
| - | - |
| Hide fee settings entirely | Expose user-friendly fee options with clear descriptions |
| Show fee rates only in sats/vByte | Show estimated total fee in Bitcoin and fiat |
| Panic users with "Transaction stuck!" error | Offer "Speed Up" with RBF automatically |
| Force manual re-sending if fees are wrong | Allow easy bumping or CPFP flows |

Well-designed wallets like Muun, Phoenix, and BlueWallet handle fees gracefully.

## Fee behavior in real world wallets (lessons)

| Wallet | Fee Behavior |
| - | - |
| Muun Wallet | Dynamically calculates pre-built CPFP bundles under the hood for invisible confirmation guarantee. |
| BlueWallet | Lets users customize exact fee rates manually (advanced mode). |
| Phoenix Wallet | Internal "smart" fees and auto CPFP for Lightning channels. |
| CashApp | Offers "instant send" fee options backed by high fee prepayments. |

Depending on your user type (consumer, advanced), you can pick whether to auto-handle or expose fine-grained controls.

## Mempool monitoring (optional advanced strategy)

For large wallets:

Monitor Bitcoin mempool via Bitnob (or internal nodes).

Detect congestion.

Adjust fee recommendation presets dynamically.

**Example:** If mempool > 300 MB → Adjust Fast fee preset to +20% over normal.

If mempool \< 30 MB → Lower default fast fee by -10%.

This dynamic behavior shows professionalism and protects user funds.

## How Bitnob supports your fee strategy

Today:

Bitnob offers dynamic fee estimation API: low, medium, high fee targets.

Allows your wallet to fetch updated fee recommendations before every send.

Future:

Planned support for:

* Mempool event webhooks
* Fee market monitoring APIs
* Enhanced Replace-by-Fee (RBF) helper APIs
* CPFP construction templates

You can start simple now, and grow with Bitnob into advanced fee management over time.

## Final thoughts

Fees are not optional details in Bitcoin UX.

They are central to wallet experience and user satisfaction.

Wallets that hide fees, guess wrong, or fail to help users during congestion will quickly lose trust.

Wallets that respect users, explain fees well, and offer real control or intelligent defaults will dominate.

### Quick developer checklist

* Always fetch real-time fee estimates.
* Offer Fast, Normal, and Economy options at minimum.
* Display the total fee in both BTC and fiat terms.
* Support Replace-by-Fee (RBF) where possible.
* Plan CPFP flows internally for stuck transactions.
* Watch mempool activity to adapt your strategy.


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