Skip to content

Commit 5e31966

Browse files
committed
make clear that internal key in script spends can be used in tweaked key spends once IC supports tweaks
1 parent 1d4b8a7 commit 5e31966

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: rust/basic_bitcoin/src/basic_bitcoin/src/bitcoin_wallet/p2tr_script_spend.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,17 @@ pub fn public_key_to_p2tr_script_spend_address(
4141

4242
fn p2tr_scipt_spend_info(public_key: &[u8]) -> TaprootSpendInfo {
4343
let spend_script = p2tr_script(public_key);
44-
let dummy_random_secp256k1 = Secp256k1::new();
45-
let schnorr_public_key = XOnlyPublicKey::from(PublicKey::from_slice(&public_key).unwrap());
44+
let secp256k1_engine = Secp256k1::new();
45+
// This is the key used in the *tweaked* key path spending. Currently, this
46+
// use case is not supported on the IC. But, once the IC supports this use
47+
// case, the addresses constructed in this way will be able to use same key
48+
// in both script and *tweaked* key path spending.
49+
let internal_public_key = XOnlyPublicKey::from(PublicKey::from_slice(&public_key).unwrap());
4650

4751
TaprootBuilder::new()
4852
.add_leaf(0, spend_script.clone())
4953
.expect("adding leaf should work")
50-
.finalize(&dummy_random_secp256k1, schnorr_public_key)
54+
.finalize(&secp256k1_engine, internal_public_key)
5155
.expect("finalizing taproot builder should work")
5256
}
5357

0 commit comments

Comments
 (0)