Created
October 23, 2024 01:44
-
-
Save Yapcheekian/d3076997c7c238f47b23565e67bd0f88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const internal_priv = ECPair.fromPrivateKey( | |
Buffer.from( | |
"1229101a0fcf2104e8808dab35661134aa5903867d44deb73ce1c7e4eb925be8", | |
"hex", | |
), | |
); | |
const pub_key = toXOnly(internal_priv.publicKey); | |
const coldReserveScriptText1 = `${bitcoin.script.number | |
.encode(144) | |
.toString("hex")} OP_CHECKSEQUENCEVERIFY OP_DROP 9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be OP_CHECKSIG`; | |
const coldReserveScript1 = bitcoin.script.fromASM(coldReserveScriptText1); | |
const coldReserveScriptText2 = `OP_SHA256 6c60f404f8167a38fc70eaf8aa17ac351023bef86bcb9d1086a19afe95bd5333 OP_EQUALVERIFY 4edfcf9dfe6c0b5c83d1ab3f78d1b39a46ebac6798e08e19761f5ed89ec83c10 OP_CHECKSIG`; | |
const coldReserveScript2 = bitcoin.script.fromASM(coldReserveScriptText2); | |
const coldReserveScriptTree = [ | |
{ | |
output: coldReserveScript1, | |
}, | |
{ | |
output: coldReserveScript2, | |
}, | |
]; | |
const { | |
address: _coldReserveAddress, | |
pubkey: _coldReservePubkey, | |
hash: _coldReserveHash, | |
} = bitcoin.payments.p2tr({ | |
internalPubkey: pub_key, | |
scriptTree: coldReserveScriptTree, | |
}); | |
let tapTweak = `0x${_coldReserveHash.toString("hex")}`; | |
console.log(tapTweak); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment