taproot – “Witness program hash mismatch” code -26 when broadcasting a transaction

on

|

views

and

comments


I am looking to broadcast a transaction to my RPC service:

curl https://my-quicknode-rpc-provider/ 
    -X POST 
    -H "Content material-Kind: software/json" 
    --data '{"way": "sendrawtransaction", "params": ["02000000000101cc0fc61320a04525c8dabf30241fe9a64b3f8c28ebf61a9700b8a57a76306bac0000000000ffffffff01ea100000000000002251208dace6f04076ca1ea4eb168dcdad6ad61f695ca1c16a3df6b9586cdca1c71db8034025871482b0c7bb14b8c72d5ac44ce069991505a1aeca1c4de5b8d1857831ca87e6f43a3e784c755595574c798892ecf58c7ae525bccba441cdf46862dd405bb47e208dace6f04076ca1ea4eb168dcdad6ad61f695ca1c16a3df6b9586cdca1c71db8ac0063036f7264010118746578742f706c61696e3b636861727365743d7574662d3800387b2270223a226272632d3230222c226f70223a227472616e73666572222c227469636b223a2270657065222c22616d74223a22313030227d6821c18dace6f04076ca1ea4eb168dcdad6ad61f695ca1c16a3df6b9586cdca1c71db800000000"]}'

however I stay getting this mistake reaction from the RPC:

{"consequence":null,"error":{"code":-26,"message":"non-mandatory-script-verify-flag (Witness program hash mismatch)"},"identification":null}

I have verified a couple of instances that I am signing with the proper personal key. On best of that, this happens when broadcasting to the community, no longer all the way through signing my PSBT inputs so I have been having hassle debugging.

For some context, I am looking to connect a Taproot script to my enter UTXO. Here’s a code snippet of what I am doing:

const hexData = Buffer.from(
  `{"p":"brc-20","op":"switch","tick":"${tick}","amt":"${quantity.toString()}"}`
).toString("hex");
const publicKeyHex = toXOnly(tweakedSigner.publicKey).toString("hex");
let inscribeLockScript = bitcoin.script.fromASM(
  `${publicKeyHex} OP_CHECKSIG OP_0 OP_IF ${Buffer.from("ord").toString(
    "hex"
  )} OP_1 ${Buffer.from("textual content/undeniable;charset=utf-8").toString(
    "hex"
  )} OP_0 ${splitByNChars(hexData, 1040).sign up for(" ")} OP_ENDIF`
);
inscribeLockScript = Buffer.from(
  inscribeLockScript.toString("hex").exchange("6f726451", "6f72640101"),
  "hex"
);

const scriptTree: Taptree = {
  output: inscribeLockScript,
};

const inscribeLockRedeem = {
  output: inscribeLockScript,
  redeemVersion: 192,
};

const inscribeP2tr = bitcoin.bills.p2tr({
  internalPubkey: toXOnly(tweakedSigner.publicKey),
  scriptTree,
  community: bitcoin.networks.bitcoin,
  redeem: inscribeLockRedeem,
});

const tapLeafScript =  Buffer.from(""),
  controlBlock: inscribeP2tr.witness![inscribeP2tr.witness!.length - 1],
;

psbt.addInput({
  hash: utxo.hash,
  index: utxo.index,
  witnessUtxo: {
    script: inscribeP2tr.output!,
    price: utxo.price,
  },
  tapInternalKey: toXOnly(tweakedSigner.publicKey),
  tapLeafScript: [tapLeafScript],
});

I am reasonably new to this so any lend a hand can be liked!

Share this
Tags

Must-read

Tesla Govt Says Repair For Vampire Drain In Sentry Mode Coming In Q2: ‘Energy Intake Wishes Development’ – Tesla (NASDAQ:TSLA)

Tesla Inc TSLA govt, Drew Baglino, on Thursday printed that the corporate is operating on liberating a device replace for decreasing energy intake...

Dividend Kings In Focal point: Phone & Information Techniques

Printed on February twenty second, 2024 through Bob Ciura The Dividend Kings consist of businesses that experience raised their dividends for a minimum of...

Tyler Perry Calls On Leisure Trade, Executive To Corral AI Prior to Everybody Is Out Of Trade

Tyler Perry has observed demonstrations of what AI can do. Whilst he's astonished, he’s additionally sounding an alarm. Perry is already balloting together...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here