Goal
This section shows step-by-step how you can build a fully operational Bitcoin non-custodial wallet using Bitnob’s RPC infrastructure and open Bitcoin libraries like BDK. We will integrate all previous sections into one coherent system architecture. You should come out of this section with a clear map to:- Build a secure self-custody wallet.
- Handle address generation, transaction monitoring, fee strategies, UTXO management.
- Prepare for future Bitcoin upgrades (Taproot, Silent Payments, Lightning).
- Scale cleanly without reinventing your backend.
Step-by-step practical workflow
-
Wallet and key generation
Client-side (on the user’s device):
- Generate a BIP39 seed phrase (12 or 24 words).
- Derive master private key (BIP32 HD Wallets).
- Derive public keys.
- Generate first Bitcoin addresses (external chain and internal chain for change addresses).
- BDK (Bitcoin Development Kit)
- bitcoinjs-lib
- Noble Bitcoin
Keys never leave the user’s device. Private keys are never sent to your server or to Bitnob. -
Display wallet dashboard
Query the blockchain using Bitnob APIs:
GET /api/balancesGET /api/transactions
-
Receiving bitcoin
- Derive a fresh external address.
- Show QR code + plain text Bitcoin address.
- When the address is used:
- Derive the next address.
- Rotate automatically.
- Generate addresses with
POST /api/addresses, so Bitnob watches them and sends webhooks. - When Bitnob detects a transaction:
- Send a webhook to your backend.
- Update user’s pending balance.
- Confirm balance after 1–3 confirmations.
-
Sending bitcoin
- Fetch available UTXOs (modeled internally or queried).
- Estimate fees by calling
estimatesmartfeethroughPOST /api/nodes. - Build transaction:
- Select UTXOs (smart coin selection).
- Create outputs.
- Create change outputs (new internal address).
- Sign transaction locally.
- Broadcast the signed transaction by calling
sendrawtransactionthroughPOST /api/nodes. - If needed:
- Mark transaction as RBF-replaceable (for fee bumping later).
-
Handling fees
- Always offer users 3 fee tiers: Fast, Normal, Economy.
- Allow Replace-by-Fee (RBF) if transaction gets stuck.
- Monitor mempool conditions to adapt fee suggestions dynamically.
-
Handling confirmations
Update user interface:
- Pending after 0 confirmations.
- Confirmed after 1–3 confirmations.
- Final after 6 confirmations (optional).
-
Wallet scaling best practices
- Consolidate small UTXOs during low-fee periods.
- Rotate addresses aggressively for privacy.
- Plan for Taproot (P2TR) address adoption.
- Build architecture modularly for Silent Payments, Lightning, Miniscript.
Key modules in your codebase
Final developer tips
- Seed management is sacred. Encrypt, protect, never expose.
- Change management is critical. Always return change to new internal addresses.
- Batching and consolidation matter, reduce long-term wallet fees.
- Address privacy matters, never reuse addresses.
- Plan for upgrades. Taproot, Lightning, Silent Payments, and Miniscript.
- User education is part of the product, backup, fees, confirmations, stuck transactions.