mandatory-script-verify-flag-failed (Invalid Schnorr signature) error when creating a child inscription in a Taproot transaction
I am trying to create a child inscription in a Taproot transaction but I am encountering the following error:
sendrawtransaction RPC error: {"code":-26,"message":"mandatory-script-verify-flag-failed (Invalid Schnorr signature)"}
I have checked all the data, including the transaction structure, signature, and Taproot script, but the error persists.
The input refers to the parent UTXO:
{
"txid": "02cde20c6db772c9ddced410c52cb2bdcbf476016fa398cfa1ac5207f1ff462f",
"vout": 0,
"value": 546,
"scriptPk": "5120932a0391d2ec13cb8f303ded9297ece089f739b3ced40bc98eebdd277fdb9c9d",
"address": "tb1pjv4q8ywjasfuhres8hke99lvuzylwwdnem2qhjvwa0wjwl7mnjwsdqu3e0"
}
The output sends 546 satoshis to the recipient address. The Taproot script for the child inscription includes:
The parent inscription data (inscriptionId). Metadata for the child inscription.
const childOrdinalStacks = [
publicKey,
bitcoin.opcodes.OP_CHECKSIG,
bitcoin.opcodes.OP_FALSE,
bitcoin.opcodes.OP_IF,
Buffer.from("ord", "utf8"),
1, 1,
Buffer.from("text/plain;charset=utf-8", "utf8"),
1, 2,
pointerBuffer1,
1, 3,
Buffer.from(parentInscriptionId, "hex"),
1, 5,
cbor.encode(childMetadata),
1, 7,
Buffer.from("parcel.bitmap", "utf8"),
bitcoin.opcodes.OP_0,
];
raw tx hash
020000000001022f46fff10752aca1cf98a36f0176f4cbbdb22cc510d4ceddc972b76d0ce2cd020000000000ffffffffc14499f6058bc6c6d5eed11c699c80007199690c12bee4a54fd46d5a9f5193e00100000000ffffffff022202000000000000225120932a0391d2ec13cb8f303ded9297ece089f739b3ced40bc98eebdd277fdb9c9d2202000000000000225120932a0391d2ec13cb8f303ded9297ece089f739b3ced40bc98eebdd277fdb9c9d01406fcbc5b6b63cb67c2289a5b4df1f3e1971b26ad4310b644da9a5a8488247f6ae44b50d7be59eecd8c58a268ce74eeb490b31bfda28cfeee6c101a914b54d613e03400058e04b9c6438f33f9a3541fe8d2a5c229794a00eb6c005aaedeb1b4622ca9c0c902d714b550e0b352578c761ac3853a5766078d7cded283f15070ef53b6c1ee8206705021108c86f6f7249e85d233414afa8eeaadaea2bad863b2ccce504126879ac0063036f7264010118746578742f706c61696e3b636861727365743d7574662d3801020222020103202f46fff10752aca1cf98a36f0176f4cbbdb22cc510d4ceddc972b76d0ce2cd02010528a264747970656b54657374204e46542023316b6465736372697074696f6e6954657374205465737401070d70617263656c2e6269746d6170003f68747470733a2f2f617277656176652e6e65742f4933326c517668673341514c583444632d334e48557773434e366e75382d6c78477352634e7765336372346821c06705021108c86f6f7249e85d233414afa8eeaadaea2bad863b2ccce50412687900000000
I am using tweakSigner to sign the input:
const signer = tweakSigner(wallet);
psbt.signInput(0, signer);
psbt.signInput(1, wallet.keyPair);
export function tweakSigner(wallet: Wallet, opts: any = {}) {
let privateKey: any = wallet.keyPair.privateKey;
if (!privateKey) {
throw new Error('Private key is required for tweaking signer!');
}
if (wallet.keyPair.publicKey[0] === 3) {
privateKey = ecc.privateNegate(privateKey);
}
const tweakedPrivateKey = ecc.privateAdd(privateKey, tapTweakHash(wallet.internalPubkey, opts.tweakHash));
if (!tweakedPrivateKey) {
throw new Error('Invalid tweaked private key!');
}
return ECPair.fromPrivateKey(Buffer.from(tweakedPrivateKey), {
network: wallet.network,
});
}
function tapTweakHash(pubKey: Buffer, h: Buffer | undefined): Buffer {
return bitcoin.crypto.taggedHash(
"TapTweak",
Buffer.concat(h ? [pubKey, h] : [pubKey])
);
}
from Recent Questions - Bitcoin Stack Exchange https://ift.tt/uDYMgT3
via IFTTT