Skip to content

Commit bf36070

Browse files
authored
update motoko basic_bitcoin readme
1 parent eea5afe commit bf36070

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

Diff for: motoko/basic_bitcoin/README.md

+10-18
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,8 @@ Candid:
8585

8686
Your canister is live and ready to use! You can interact with it using either the command line or the Candid UI, which is the link you see in the output above.
8787

88-
In the output above, to see the Candid Web UI for your bitcoin canister, you would use the URL `https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.icp0.io/?id=<YOUR-CANISTER-ID>`. Here are the two methods you will see:
89-
90-
* `public_key`
91-
* `sign`
88+
In the output above, to see the Candid Web UI for your bitcoin canister, you would use the URL `https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.icp0.io/?id=<YOUR-CANISTER-ID>`. Candid
89+
Web UI will contain all methods implemented by the canister.
9290

9391
## Step 2: Generating a Bitcoin address
9492

@@ -99,7 +97,7 @@ if you are interested in a high-level comparison of different address types.
9997
These addresses can be generated from an ECDSA public key or a Schnorr
10098
([BIP340](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki))
10199
public key. The example code showcases how your canister can generate and spend
102-
from two types of addresses:
100+
from three types of addresses:
103101
1. A [P2PKH address](https://en.bitcoin.it/wiki/Transaction#Pay-to-PubkeyHash)
104102
using the
105103
[ecdsa_public_key](https://internetcomputer.org/docs/current/references/ic-interface-spec/#ic-method-ecdsa_public_key)
@@ -117,6 +115,11 @@ from two types of addresses:
117115
taproot multisigner addresses using specific multisignature schemes. However,
118116
the Schnorr API of the internet computer does not support Schnorr
119117
multisignatures.
118+
3. A [P2TR
119+
address](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki)
120+
where the funds can be spent using the provided public key with the script
121+
path, where the Merkelized Alternative Script Tree (MAST) consists of a
122+
single script allowing to spend funds by exactly one key.
120123

121124
Note that P2TR *key path* spending with a tweaked key is currently not available
122125
on the IC because the threshold Schnorr signing interface does not allow
@@ -128,7 +131,7 @@ post](https://bitcoin.stackexchange.com/a/111100) by Pieter Wuille.
128131

129132
On the Candid UI of your canister, click the "Call" button under
130133
`get_${type}_address` to generate a `${type}` Bitcoin address, where `${type}`
131-
is one of `[p2pkh, p2tr_raw_key_spend]`.
134+
is one of `[p2pkh, p2tr_raw_key_spend, p2tr_script_spend]`.
132135

133136
Or, if you prefer the command line:
134137

@@ -173,7 +176,7 @@ Checking the balance of a Bitcoin address relies on the [bitcoin_get_balance](ht
173176
## Step 5: Sending bitcoin
174177

175178
You can send bitcoin using the `send_from_${type}` endpoint on your canister, where
176-
`${type}` is on of `[p2pkh, p2tr_raw_key_spend]`.
179+
`${type}` is on of `[p2pkh, p2tr_raw_key_spend, p2tr_script_spend]`.
177180

178181
In the Candid UI, add a destination address and an amount to send. In the example
179182
below, we're sending 4'321 Satoshi (0.00004321 BTC) back to the testnet faucet.
@@ -226,15 +229,4 @@ For example, the following aspects are particularly relevant for this app:
226229
* [Certify query responses if they are relevant for security](https://internetcomputer.org/docs/current/references/security/general-security-best-practices#certify-query-responses-if-they-are-relevant-for-security), since the app e.g. offers a method to read balances.
227230
* [Use a decentralized governance system like SNS to make a canister have a decentralized controller](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview)
228231

229-
## Taproot transactions
230-
In addition to P2PKH transactions, this example now also suppots P2TR
231-
transactions, namely the so-called untweaked key path P2TR transactions, which
232-
is the most efficient way of performing a P2TR transaction. The limitation of
233-
this type of transactions is that it cannot be used in combination with scripts.
234-
IMPORTANT: Note that BIP341 advises against using taproot addresses that can be
235-
spent with an untweaked key. This precaution is to prevent attacks that can
236-
occur when creating taproot multisigner addresses using specific multisignature
237-
schemes. However, the Schnorr API of the internet computer does not support
238-
Schnorr multisignatures.
239-
240232
This implementation has only been tested locally with regtest.

0 commit comments

Comments
 (0)