Skip to content

docs(bitcoin): expand Direct Bitcoin API section#169

Merged
marc0olo merged 1 commit into
mainfrom
docs/bitcoin-integration-improvements
Apr 29, 2026
Merged

docs(bitcoin): expand Direct Bitcoin API section#169
marc0olo merged 1 commit into
mainfrom
docs/bitcoin-integration-improvements

Conversation

@marc0olo
Copy link
Copy Markdown
Member

Summary

Resolves #159.

  • get_blockchain_info documented (fixes docs(bitcoin): document get_blockchain_info endpoint in bitcoin guide #159): new ### Blockchain info section with a response field table, Motoko and Rust tabs, cycle cost row in the existing table, and a link to the Rust example. Includes Cargo.toml snippet for ic-cdk-bitcoin-canister = "0.2".
  • ### Read UTXOs section added: Motoko and Rust tabs showing bitcoin_get_utxos with a pagination note explaining how to follow next_page.
  • ### Get fee percentiles section added: Motoko and Rust tabs, fallback for regtest (empty response), and MillisatoshiPerByte type note.
  • ### Developer workflow section added: numbered end-to-end steps (address generation → UTXOs → fee → build → sign → submit) plus a #### UTXO selection subsection covering greedy (standard payments) and single-UTXO (Ordinals/Runes/BRC-20) strategies with working Motoko and Rust implementations.
  • ### Common mistakes section added: five actionable items — UTXO pagination, immature/unconfirmed UTXOs, missing iterative fee calculation, dust change outputs, and concurrent UTXO spending.
  • ### Available endpoints expanded: added threshold signature methods and a forward-reference to cycle costs.
  • ### Bitcoin API canister IDs section added: table with mainnet and testnet/regtest canister IDs, extracted from the inline text.

Bug fixes (caught in review)

  • label looplabel done in Motoko UTXO selection: loop is a reserved keyword and would have caused a compile error.
  • UtxosFilterInRequest::PageUtxosFilter::Page in two prose locations: the type does not exist; UtxosFilter (from ic_cdk_bitcoin_canister) is correct.
  • #[update] + use ic_cdk::update;#[ic_cdk::update] in the blockchain info Rust tab: matches the style used in every other Rust tab.
  • get_network().into()get_network() in the UTXOs Rust tab: get_network() already returns Network; the .into() was a no-op.

Relation to issue #168

Issue #168 tracks adding mdBook region markers to the basic_bitcoin example source files so that docs can embed stable, line-number-independent code snippets directly from the examples repo. Until those markers land, the UTXO selection code in ### Developer workflow is written inline in the docs (adapted from common.rs). Once #168 is resolved, these snippets can be replaced with direct region embeds pointing at the upstream source — no content change required, only the embed syntax.

Sync recommendation

Informed by dfinity/examplesrust/basic_bitcoin/src/common.rs, rust/basic_bitcoin/src/service/get_utxos.rs, rust/basic_bitcoin/src/service/get_blockchain_info.rs, rust/basic_bitcoin/basic_bitcoin.did, motoko/basic_bitcoin/src/basic_bitcoin/src/BitcoinApi.mo; dfinity/cdk-rsic-cdk-bitcoin-canister 0.2; dfinity/icskillsskills/ckbtc/SKILL.md

Resolves #159. Substantial expansion of the Direct Bitcoin API section
to cover the full developer workflow and common pitfalls.
@marc0olo marc0olo merged commit 3789998 into main Apr 29, 2026
1 check passed
@marc0olo marc0olo deleted the docs/bitcoin-integration-improvements branch April 29, 2026 19:12
marc0olo added a commit that referenced this pull request Apr 29, 2026
…API sections (#170)

## Summary

### CLI copy-paste UX

The `### Interact with ckBTC using icp-cli` section previously had a
single monolithic code block with `YOUR-PRINCIPAL` literals that
required manual editing before every command. The section now:

- Exports `MY_PRINCIPAL` from the active identity in one setup block
(`icp identity get-principal`) so it never needs to be typed or edited.
- Splits each operation into its own copy-paste block with
`$MY_PRINCIPAL` interpolated via double-quote shell expansion.
- The transfer command includes `export
RECIPIENT="<paste-recipient-principal>"` at the top of the same block,
keeping it a single copy-paste operation while making the placeholder
explicit.

### Direct Bitcoin API section reordering

Previous order mixed monitoring utilities in with core read operations
and placed `### Blockchain info` immediately after `### Available
endpoints`, before the developer's first instinct (`get_balance`,
`get_utxos`). New order groups sections by purpose:

| Before | After |
|---|---|
| Bitcoin API canister IDs | Bitcoin API canister IDs |
| Available endpoints | Available endpoints |
| **Blockchain info** | **Read Bitcoin balance** |
| Read Bitcoin balance | **Read UTXOs** |
| Read UTXOs | **Get fee percentiles** |
| Get fee percentiles | **Blockchain info** |
| Developer workflow | Developer workflow |
| (UTXO selection as h4) | **UTXO selection (h3)** |
| Common mistakes | Common mistakes |
| Cycle costs | Cycle costs |

`Blockchain info` is a monitoring/diagnostics call — it belongs after
the core transaction-building reads, not before them.

### Developer workflow heading structure

`#### UTXO selection` was the only h4 in the entire file, sitting as a
lone child under `### Developer workflow`. This:

- Created a structurally awkward section (a heading with a single
subheading implies the parent section exists only to contain one thing).
- Buried the UTXO selection anchor below the fold of the workflow
section.

The fix promotes `#### UTXO selection` to `### UTXO selection` as a
sibling of `### Developer workflow`. The `### Developer workflow`
section now closes with the working-example links (which cover the full
flow, not just UTXO selection), and step 3 in the numbered list links
directly to `#utxo-selection` for readers who want to jump there.

### Em-dash cleanup

The previous PR (#169) introduced several em-dashes in new prose. All
instances outside code blocks are replaced with colons, semicolons, or
parentheses per the project's banned-terms rule.

## Sync recommendation

Informed by `dfinity/examples` — no source changes, documentation
improvements only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(bitcoin): document get_blockchain_info endpoint in bitcoin guide

1 participant