Skip to content

Commit 957c976

Browse files
authored
docs(chain-fusion): diagram styling, KYT flows, and Bitcoin canister corrections (#176)
## Summary Follow-up to #174. Changes that were not pushed before that PR was merged. **PlantUML diagram styling (`plugins/remark-plantuml.mjs`, `src/styles/custom.css`):** - Wrap each diagram in `<figure class="plantuml-diagram">` for CSS targeting - Elevated background (`--icp-bg-elev`) and `border-radius: 6px` as visual container (no explicit border needed) - Dark mode: `filter: invert(1) hue-rotate(180deg)` on the image preserves hue relationships while flipping luminance - Darken actor border, lifeline, participant border, and note border from hairline (`#e5ddcf`) to muted (`#6b6660`) so all structural lines remain legible after dark mode inversion **Bitcoin canister corrections (`bitcoin.mdx`, `dogecoin.md`):** - Replace "management canister" with "Bitcoin canister" for `bitcoin_*` API calls - The management canister Bitcoin API is deprecated; documented in `management-canister.md` - All remaining "management canister" references correctly describe `sign_with_ecdsa` / `sign_with_schnorr`, which do stay on the management canister **ckBTC flow diagrams (`bitcoin.mdx`):** - Deposit diagram: add Bitcoin Checker (KYT), ckBTC Ledger participant, and 4-confirmation note - Withdrawal diagram: add Bitcoin Checker for destination address KYT check and async note for batched Bitcoin submission - Prose updated: names the 4-confirmation threshold, 100-satoshi KYT fee per UTXO, quarantine behaviour for failed UTXOs, and `retrieve_btc_status_v2` for withdrawal tracking **Confirmation count (`bitcoin.mdx`, `chain-key-tokens.mdx`):** - Update ckBTC minimum confirmations from 6 to 4 in the diagram note, deposit flow prose, and the `chain-key-tokens.mdx` callout (distinct from the table/description already updated in #173) ## Sync recommendation `informed by dfinity/ic rs/bitcoin/ckbtc/minter/README.adoc; dfinity/bitcoin-canister INTERFACE_SPECIFICATION.md; wiki.internetcomputer.org/wiki/Chain-key_Bitcoin`
1 parent da006d4 commit 957c976

5 files changed

Lines changed: 55 additions & 22 deletions

File tree

docs/guides/chain-fusion/bitcoin.mdx

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ICP provides a protocol-level integration with the Bitcoin network. Canisters ca
1212
There are two approaches to working with Bitcoin on ICP:
1313

1414
- **ckBTC (chain-key Bitcoin)**: a 1:1 BTC-backed token native to ICP. Transfers settle in 1-2 seconds with a 10 satoshi fee. Best for most applications that need to accept, hold, or transfer Bitcoin value.
15-
- **Direct Bitcoin API**: call the management canister to read UTXOs, get balances, and submit raw Bitcoin transactions. Best for advanced use cases that need full control over Bitcoin transactions (custom scripts, Ordinals, Runes, BRC-20).
15+
- **Direct Bitcoin API**: call the Bitcoin canister to read UTXOs, get balances, and submit raw Bitcoin transactions. Best for advanced use cases that need full control over Bitcoin transactions (custom scripts, Ordinals, Runes, BRC-20).
1616

1717
This guide covers both approaches.
1818

@@ -34,19 +34,25 @@ ckBTC is the recommended path for most developers. The ckBTC minter canister hol
3434
```plantuml
3535
actor User
3636
participant "ckBTC Minter" as Minter
37+
participant "Bitcoin Checker" as KYT
38+
participant "ckBTC Ledger" as Ledger
3739
participant "Bitcoin Network" as BTC
3840
39-
User -> Minter: get_btc_address(account)
41+
User -> Minter: get_btc_address(owner, subaccount)
4042
Minter --> User: btc_address
4143
User -> BTC: send BTC to btc_address
42-
User -> Minter: update_balance(account)
43-
Minter --> User: ckBTC minted to ICRC-1 account
44+
note right of BTC: 4 confirmations required
45+
User -> Minter: update_balance(owner, subaccount)
46+
Minter -> KYT: check UTXO
47+
KYT --> Minter: ok
48+
Minter -> Ledger: mint ckBTC (amount - kyt_fee)
49+
Minter --> User: MintedUtxos
4450
```
4551

46-
1. Call `get_btc_address` on the minter with the user's principal and subaccount. This returns a unique Bitcoin address controlled by the minter.
47-
2. The user sends BTC to that address using any Bitcoin wallet.
48-
3. Wait for Bitcoin confirmations (the minter requires confirmations before minting).
49-
4. Call `update_balance` on the minter with the same principal and subaccount. The minter checks for new UTXOs and mints equivalent ckBTC to the user's ICRC-1 account.
52+
1. Call `get_btc_address` on the minter with the user's principal and subaccount. This returns a unique Bitcoin address controlled by the minter via threshold ECDSA.
53+
2. Send BTC to that address from any Bitcoin wallet.
54+
3. Wait for 4 Bitcoin confirmations (mainnet). The minter will not process UTXOs until the required number of confirmations is reached.
55+
4. Call `update_balance` on the minter. The minter checks for new UTXOs, runs a KYT (Know-Your-Transaction) compliance check via the Bitcoin Checker canister, and mints ckBTC to the user's ICRC-1 account. A KYT fee of 100 satoshis is deducted per UTXO. UTXOs that fail the KYT check are quarantined and not minted.
5056

5157
<Tabs syncKey="lang">
5258
<TabItem label="Motoko">
@@ -243,15 +249,20 @@ async fn transfer(to: Principal, amount: Nat) -> Result<Nat, TransferError> {
243249
actor User
244250
participant "ckBTC Ledger" as Ledger
245251
participant "ckBTC Minter" as Minter
252+
participant "Bitcoin Checker" as KYT
246253
participant "Bitcoin Network" as BTC
247254
248255
User -> Ledger: icrc2_approve(spender=minter, amount)
249256
User -> Minter: retrieve_btc_with_approval(btc_address, amount)
257+
Minter -> KYT: check destination address
258+
KYT --> Minter: ok
250259
Minter -> Ledger: icrc2_transfer_from(user, minter, amount)
251-
Minter -> BTC: send BTC to btc_address
260+
Minter --> User: block_index
261+
note right of Minter: processed asynchronously
262+
Minter -> BTC: submit signed transaction
252263
```
253264

254-
Withdrawal is a two-step process: approve the minter to spend your ckBTC, then call `retrieve_btc_with_approval`. The minimum withdrawal is 50,000 satoshis (0.0005 BTC).
265+
Withdrawal is a two-step process: approve the minter to spend your ckBTC, then call `retrieve_btc_with_approval`. Before burning ckBTC, the minter runs a KYT check on the destination Bitcoin address. The Bitcoin transaction is submitted asynchronously — the minter batches pending requests to optimize miner fees. Track status with `retrieve_btc_status_v2(block_index)`. The minimum withdrawal is 50,000 satoshis (0.0005 BTC).
255266

256267
<Tabs syncKey="lang">
257268
<TabItem label="Motoko">
@@ -493,7 +504,7 @@ For a complete working example with all type definitions and error handling, see
493504

494505
## Direct Bitcoin API
495506

496-
For use cases that require full control over Bitcoin transactions (custom scripts, Ordinals, Runes, BRC-20), you can call the Bitcoin API directly through the management canister. This involves generating addresses with threshold ECDSA or Schnorr signatures, building raw transactions, and submitting them to the Bitcoin network.
507+
For use cases that require full control over Bitcoin transactions (custom scripts, Ordinals, Runes, BRC-20), you can call the Bitcoin canister directly. This involves generating addresses with threshold ECDSA or Schnorr signatures, building raw transactions, and submitting them to the Bitcoin network.
497508

498509
### Bitcoin API canister IDs
499510

@@ -1165,7 +1176,7 @@ docker stop bitcoind && docker rm bitcoind
11651176
- [Chain-key cryptography](../../concepts/chain-key-cryptography.md): learn how threshold ECDSA and Schnorr signatures work
11661177
- [Chain-key tokens](../digital-assets/chain-key-tokens.md): explore ckBTC, ckETH, and other chain-key tokens
11671178
- [Ethereum integration](ethereum.md): apply similar patterns for Ethereum
1168-
- [Management canister reference](../../reference/management-canister.md): full API reference for `bitcoin_get_utxos`, `sign_with_ecdsa`, and other management canister methods
1179+
- [Management canister reference](../../reference/management-canister.md): full API reference for `sign_with_ecdsa`, `sign_with_schnorr`, and other management canister methods (note: the `bitcoin_*` methods in the management canister are deprecated; use the Bitcoin canister directly)
11691180
- [Bitcoin canister API specification](https://github.com/dfinity/bitcoin-canister/blob/master/INTERFACE_SPECIFICATION.md): detailed API documentation
11701181
- [Bitcoin integration (Learn Hub)](https://learn.internetcomputer.org/hc/en-us/articles/34211154520084): protocol-level details of how ICP connects to Bitcoin
11711182

docs/guides/chain-fusion/dogecoin.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ICP canisters can interact directly with the Dogecoin network without bridges or
1414
- **Dogecoin canister**: a system canister controlled by the NNS that exposes an API for querying Dogecoin network state (UTXOs, balances, block information) and submitting signed transactions.
1515
- **Threshold ECDSA**: canisters request threshold ECDSA signatures from the management canister to sign Dogecoin transactions. The private key is never reconstructed; it exists only as secret shares distributed across subnet nodes.
1616

17-
This is the same model as the [Bitcoin integration](bitcoin.md), using a UTXO-based transaction model and secp256k1 ECDSA signatures. The main difference is that Dogecoin transactions are submitted through the Dogecoin canister rather than the Bitcoin management canister API.
17+
This is the same model as the [Bitcoin integration](bitcoin.md), using a UTXO-based transaction model and secp256k1 ECDSA signatures. The main difference is that Dogecoin transactions are submitted through the Dogecoin canister rather than the Bitcoin canister.
1818

1919
## How it works
2020

@@ -118,7 +118,7 @@ For a complete, working implementation covering all steps (including deriving a
118118

119119
The [Bitcoin integration guide](bitcoin.md) covers the same conceptual steps with complete inline code. Because Dogecoin is a fork of Bitcoin and shares the same UTXO model and secp256k1 ECDSA signatures, the patterns translate directly with these differences:
120120

121-
- Use the Dogecoin canister for UTXO queries and transaction submission (not the management canister's `bitcoin_*` API)
121+
- Use the Dogecoin canister for UTXO queries and transaction submission (not the Bitcoin canister's `bitcoin_*` API)
122122
- Use Dogecoin's P2PKH address format (mainnet addresses start with `D`)
123123
- Dogecoin uses koinus instead of satoshis (1 DOGE = 100,000,000 koinus)
124124
- Dogecoin uses a different fee rate: use `dogecoin_get_current_fee_percentiles` to get current rates
@@ -131,13 +131,13 @@ The key differences in implementation:
131131

132132
| | Bitcoin | Dogecoin |
133133
|---|---|---|
134-
| API | Management canister (`bitcoin_*` methods) | Dogecoin canister |
134+
| API | Bitcoin canister (`bitcoin_*` methods) | Dogecoin canister |
135135
| Chain-key token | ckBTC | ckDOGE |
136136
| Address prefix | `1`, `3`, `bc1` (mainnet) | `D` (mainnet) |
137137
| Unit | satoshi | koinu |
138138
| Status | Stable | Beta |
139139

140-
Developers familiar with the Bitcoin integration will find the Dogecoin integration conceptually identical. The primary practical difference is calling the Dogecoin canister rather than the management canister's Bitcoin API.
140+
Developers familiar with the Bitcoin integration will find the Dogecoin integration conceptually identical. The primary practical difference is calling the Dogecoin canister rather than the Bitcoin canister.
141141

142142
## NNS governance
143143

docs/guides/digital-assets/chain-key-tokens.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The deposit flow has two steps:
3434
1. **Get a deposit address**: call `get_btc_address` on the ckBTC minter with the owner principal and an optional subaccount. The minter returns a unique Bitcoin address.
3535
2. **Mint ckBTC**: after BTC is sent to that address, call `update_balance` on the minter. The minter checks for new UTXOs and mints ckBTC to the corresponding ICRC-1 account.
3636

37-
The minter requires a minimum number of Bitcoin confirmations before minting (currently 6 on mainnet). `update_balance` returns `NoNewUtxos` if confirmations have not yet been reached: your app should poll or prompt the user to wait.
37+
The minter requires a minimum number of Bitcoin confirmations before minting (currently 4 on mainnet). `update_balance` returns `NoNewUtxos` if confirmations have not yet been reached: your app should poll or prompt the user to wait.
3838

3939
<Tabs syncKey="lang">
4040
<TabItem label="Motoko">

plugins/remark-plantuml.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ skinparam defaultFontSize 13
2626
skinparam defaultFontColor #1a1714
2727
skinparam sequenceArrowThickness 1.5
2828
skinparam sequenceArrowColor #cc5a2b
29-
skinparam SequenceLifeLineBorderColor #e5ddcf
29+
skinparam SequenceLifeLineBorderColor #6b6660
3030
skinparam ParticipantBackgroundColor #fdfaf3
31-
skinparam ParticipantBorderColor #e5ddcf
31+
skinparam ParticipantBorderColor #6b6660
3232
skinparam ParticipantFontColor #1a1714
3333
skinparam ActorBackgroundColor #fdfaf3
34-
skinparam ActorBorderColor #e5ddcf
34+
skinparam ActorBorderColor #6b6660
3535
skinparam ActorFontColor #1a1714
3636
skinparam NoteBackgroundColor #f2d7c7
37-
skinparam NoteBorderColor #e5ddcf
37+
skinparam NoteBorderColor #6b6660
3838
skinparam NoteFontColor #1a1714
3939
`;
4040

@@ -53,7 +53,7 @@ export default function remarkPlantUML() {
5353
const url = toUrl(node.value);
5454
parent.children[index] = {
5555
type: "html",
56-
value: `<img src="${url}" alt="PlantUML diagram" />`,
56+
value: `<figure class="plantuml-diagram"><img src="${url}" alt="PlantUML diagram" /></figure>`,
5757
};
5858
});
5959
};

src/styles/custom.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,28 @@ h1, h2, h3, h4, h5, h6 {
307307
color: var(--sl-color-white);
308308
}
309309

310+
/* ── PlantUML diagrams ────────────────────────────────────── */
311+
312+
.plantuml-diagram {
313+
display: block;
314+
margin: 1.5rem 0;
315+
background: var(--icp-bg-elev);
316+
border-radius: 6px;
317+
padding: 1.5rem;
318+
text-align: center;
319+
}
320+
321+
.plantuml-diagram img {
322+
max-width: 100%;
323+
height: auto;
324+
display: block;
325+
margin: 0 auto;
326+
}
327+
328+
[data-theme='dark'] .plantuml-diagram img {
329+
filter: invert(1) hue-rotate(180deg);
330+
}
331+
310332
/* ── Agent signaling ──────────────────────────────────────── */
311333

312334
/* Visually hidden but present in DOM for HTML-to-markdown converters.

0 commit comments

Comments
 (0)