cmdruid / tapscript

A humble library for working with Tapscript and Bitcoin Transactions.
https://www.npmjs.com/package/@cmdcode/tapscript
Creative Commons Zero v1.0 Universal
188 stars 49 forks source link

How can I decode script from tpubkey #7

Closed sondotpin closed 1 year ago

sondotpin commented 1 year ago
const script  = [ pubkey, 'OP_CHECKSIG', 'OP_0', 'OP_IF', marker, '01', mimetype, 'OP_0', imgdata, 'OP_ENDIF' ]

const tapleaf = Tap.encodeScript(script)

const [ tpubkey, cblock ] = Tap.getPubKey(pubkey, { target: tapleaf })

How can I decode script from tpubkey

cmdruid commented 1 year ago

It is not possible to decode the script. The key has a cryptographic commitment to the script, but it does not contain the script itself.

sondotpin commented 1 year ago

so how can the indexer work if they can not decode the script?

cmdruid commented 1 year ago

You have to publish the script in a transaction. The indexer only looks at scripts which are published. The key and address itself does not contain the content of the script.