Extended Public Keys¶
Extended public keys (xpubs) are the foundation of HD (Hierarchical Deterministic) wallet monitoring. This guide explains how they work and how Vigil uses them.
What is an Extended Public Key?¶
An extended public key contains:
- A public key
- A chain code (for deriving child keys)
- Depth and index information
- Parent fingerprint
This allows deriving an unlimited number of child public keys and addresses without exposing private keys.
In practice, wallets derive as many addresses as needed over time.
Key Types and Prefixes¶
Mainnet¶
| Prefix | BIP | Script Type | Address Format |
|---|---|---|---|
xpub |
BIP-44 | P2PKH | 1... (Legacy) |
ypub |
BIP-49 | P2SH-P2WPKH | 3... (Nested SegWit) |
zpub |
BIP-84 | P2WPKH | bc1q... (Native SegWit) |
Testnet¶
| Prefix | BIP | Script Type | Address Format |
|---|---|---|---|
tpub |
BIP-44 | P2PKH | m.../n... |
upub |
BIP-49 | P2SH-P2WPKH | 2... |
vpub |
BIP-84 | P2WPKH | tb1q... |
Prefix Conventions
These prefixes are conventions, not protocol rules. The prefix indicates the intended address type, but the actual script depends on how addresses are derived.
Derivation Paths¶
Standard BIP Paths¶
| BIP | Path | Purpose |
|---|---|---|
| BIP-44 | m/44'/0'/0' |
Legacy P2PKH |
| BIP-49 | m/49'/0'/0' |
Nested SegWit |
| BIP-84 | m/84'/0'/0' |
Native SegWit |
| BIP-86 | m/86'/0'/0' |
Taproot |
Path Components¶
| Component | Meaning |
|---|---|
m |
Master key |
purpose' |
BIP number (44, 49, 84, 86) |
coin_type' |
0 = Bitcoin, 1 = Testnet |
account' |
Account number (0, 1, 2, ...) |
change |
0 = external, 1 = internal (change) |
address_index |
Address number within chain |
Hardened vs Normal Derivation¶
'orhindicates hardened derivation (e.g.,84')- Hardened derivation requires the private key
- Normal derivation can use only the public key
Why This Matters
Vigil receives your xpub at the account level (e.g., m/84'/0'/0'). We can derive all addresses below this point (change and address_index) using only the public key.
Address Derivation¶
From an xpub, Vigil derives addresses in two chains:
External Chain (Receiving)¶
xpub → /0/0 → Address 1 (first receiving address)
xpub → /0/1 → Address 2
xpub → /0/2 → Address 3
...
Internal Chain (Change)¶
Gap Limit¶
The gap limit determines how many consecutive unused addresses Vigil scans.
How It Works¶
Address 0: Used ✓
Address 1: Used ✓
Address 2: Unused
Address 3: Unused
...
Address 21: Unused (gap limit = 20)
Address 22: Stop scanning
If address 22 actually exists but isn't found, you need to increase the gap limit.
Recommended Settings¶
| Use Case | Gap Limit |
|---|---|
| Personal wallet | 20 (default) |
| Merchant receiving | 50-100 |
| Exchange/High volume | 500+ |
Exporting Your xpub¶
Hardware Wallets¶
- Advanced → Export Wallet
- Choose Generic JSON or Electrum
- Find the xpub in the exported file
- Open Ledger Live
- Go to your Bitcoin account
- Click Account settings (wrench icon)
- Click "Advanced" → "Export xpub"
- Open Trezor Suite
- Go to your Bitcoin account
- Click "Show Full Account Public Key"
Software Wallets¶
Security Considerations¶
xpub Privacy
An xpub reveals all addresses in a wallet. Anyone with your xpub can:
- See all your transactions
- Calculate your total balance
- Track your future activity
Do not share your xpub publicly.
What an xpub Cannot Do¶
- ❌ Spend your funds
- ❌ Sign transactions
- ❌ Access your private keys
Best Practices¶
- Use account-level xpubs - Don't export master keys
- One xpub per service - If compromised, only that view is affected
- Verify service trustworthiness - Only share with trusted services
Next: Network Support →