-
-
Save ChristianOConnor/fa07462990a74606f486f97031783e50 to your computer and use it in GitHub Desktop.
Make private key into tweaked oridinal tapscript address (Javascript)
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
import { Address, Tap } from '@cmdcode/tapscript' | |
import { Buff } from '@cmdcode/buff-utils' | |
import { keys } from '@cmdcode/crypto-tools' | |
async function main() { | |
const secret = "5b10712a7799e29441f6c27918ff27af8a8f3707da14afd352730a99fb417033" | |
const inscription = Buff.encode('gywJYnla8SOO5PrmVIXlcgXwAbOWlgPgDXjjAOY') | |
const marker = Buff.encode('ord') | |
const mimetype = Buff.encode('text/plain') | |
const seckey = keys.get_seckey(secret) | |
const pubkey = keys.get_pubkey(seckey, true) | |
const script = [ pubkey, 'OP_CHECKSIG', 'OP_0', 'OP_IF', marker, '01', mimetype, 'OP_0', inscription, 'OP_ENDIF' ] | |
const tapleaf = Tap.encodeScript(script) | |
const [ tpubkey, cblock ] = Tap.getPubKey(pubkey, { target: tapleaf }) | |
const address = Address.p2tr.fromPubKey(tpubkey, 'testnet') | |
return { address } | |
} | |
main().then(console.log).catch(console.error) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment