> For the complete documentation index, see [llms.txt](https://docs-unified.crypto-chief.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-unified.crypto-chief.com/guides/xpub-wallets.md). Agents can also search and read this documentation through its [MCP server](https://docs-unified.crypto-chief.com/~gitbook/mcp).

# Xpub Wallets

## Xpub Wallets

An HD wallet derives a new receiving address for every payment. With its extended public key, the Unified API reads the whole account — balance, used addresses, transfers, spendable outputs — without tracking each address yourself. Xpubs work on the Bitcoin-family networks: `BTC_MAINNET`, `BTC_TESTNET_4`, `LITECOIN_MAINNET`, `DOGECOIN_MAINNET`, `BITCOIN_CASH_MAINNET`.

An extended public key reveals every address of the account and its whole history. Treat it as confidential, like the account statement it is.

### Balance and addresses

```bash
curl -s "https://api-unified.crypto-chief.com/v1/xpubs/zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs?network=BTC_MAINNET&include=addresses" \
  -H "X-API-Key: $CC_API_KEY"
```

`balance` is the confirmed balance of the account, `unconfirmed` the change pending in the mempool. `addresses[]` lists the used addresses with their derivation `path` — `m/84'/0'/0'/0/n` for receiving, `…/1/n` for change — so you can tell which customer's address a payment went to.

### Incoming payments

```bash
curl -s "https://api-unified.crypto-chief.com/v1/xpubs/zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs/transfers?network=BTC_MAINNET&direction=in&min_stage=final&order=asc" \
  -H "X-API-Key: $CC_API_KEY"
```

Each transfer is one output paid to one of the account's addresses: `to` is that address, `utxo.output_index` the output. Change returning to the account's own change addresses appears as `self` when the inputs are the account's too; filter `direction=in` for payments from others. Credit by `(network, id)`, never by transaction hash — one transaction can pay two of your addresses.

### Spending

`GET /v1/xpubs/{xpub}/utxos` lists the outputs the account can spend, with `script_hex` and confirmations, to build a transaction in your own signer. [Broadcast](https://docs-unified.crypto-chief.com/api-reference/transactions.md#broadcast-a-transaction) the signed result and follow it with [`/status`](https://docs-unified.crypto-chief.com/guides/payment-status.md).

### Live payments

EventStream does not subscribe to xpubs. To receive payments to an xpub wallet as webhooks:

1. List the derived addresses with `include=addresses`, plus the next unused ones your wallet will hand out (your gap limit).
2. Put them in an EventStream watchlist and subscribe to `transfer.native` with `directions: ["in"]`.
3. Add each new address to the watchlist before you hand it out.
4. For the history before the subscription, read `GET /v1/xpubs/{xpub}/transfers` — its ids are the stream's `occurrence_id`s — and merge both as in [Deposit Reconciliation with EventStream](https://docs-unified.crypto-chief.com/guides/deposit-reconciliation.md).
