Closed 0xfinetuned closed 8 months ago
If you would like to add additional arguments to the witness, you can do so like this:
txdata.vin[0].witness = [ 7, sig, script, cblock ]
The script interpreter should convert the 7 into the proper opcode (it should convert to OP_7).
The Signer.taproot.verify
method is unfortunately not capable of verifying arbitrary scripts, but you can verify the tx/signature and script/cblock separately.
The Tap.getPubKey
method will verify the cblock before returning it, but you can also verify it independently using Tap.checkPath
.
For verifying the signature, you can create the transaction hash using Signer.taproot.hash
, and then check if the signature (and pubkey) is valid for that hash.
I hope this helps!
Yuup that helped thank you soo much.
Although this didn't work:
txdata.vin[0].witness = [ 7, sig, script, cblock ]
Had to do this:
txdata.vin[0].witness = [ sig.hex, '07', script, cblock ]
There might be a bug in the script interpreter
I should have mentioned that the order of the arguments in the witness will depend on the order that the script consumes them.
I want to create a specific transaction using tapscript similar to the ones shown in this example and I can't figure out how to put a 7 before the sig inside the witness. Can you please help ?
`const test = async () => { // Switch this to true to enable console output. const VERBOSE = true