Sunday, December 22, 2024

javascript – Redeem script for enter #0 would not match the scriptPubKey within the prevout

I am making an attempt to create a brand new bitcoin transaction utilizing bitcoinjs-lib. Right here is my transaction.

{
  "weight" : 661,
  "txid" : "4621e1e4e8ace541902aac5ad6cff164da6e55c1bb8af793fb65e76d5a98c841",
  "standing" : {
    "block_height" : 800029,
    "block_hash" : "000000000000000000045fd943ecff32113fbc9610570e8ef071deb3b92db312",
    "confirmed" : true,
    "block_time" : 1690187566
  },
  "vin" : [
    {
      "inner_redeemscript_asm" : "OP_0 OP_PUSHBYTES_20 3d6f823b6cfc0e422f14d011c9401c3bed6dfde0",
      "txid" : "edbcb7cdd428c4c251377a49ffc91b8eabef092200f10f88aea8452cea80293f",
      "prevout" : {
        "scriptpubkey_type" : "p2sh",
        "scriptpubkey_address" : "3QQBsz2wPqNeWyEY6vnRKoCuHcyBgx2ZpQ",
        "value" : 100000,
        "scriptpubkey_asm" : "OP_HASH160 OP_PUSHBYTES_20 f91c21e619f4d51b2e58c3cfc0463057fc5e13a7 OP_EQUAL",
        "scriptpubkey" : "a914f91c21e619f4d51b2e58c3cfc0463057fc5e13a787"
      },
      "scriptsig_asm" : "OP_PUSHBYTES_22 00143d6f823b6cfc0e422f14d011c9401c3bed6dfde0",
      "is_coinbase" : false,
      "vout" : 0,
      "sequence" : 4294967295,
      "witness" : [
        "304402204d0ea4bc5a2ba018178daecdd55253fa6623e104aab5fd6e3198d9100f7f54c90220021255a9e25150da369cee1d279a3ed5e24a008c08c4c46c5338b397dd66bb8501",
        "0243027fe517049903f9c8ad1302b3c11146acf6dbcb3f355f8b3c4f2b7182e1bc"
      ],
      "scriptsig" : "1600143d6f823b6cfc0e422f14d011c9401c3bed6dfde0"
    }
  ],
  "vout" : [
    {
      "scriptpubkey_type" : "p2sh",
      "scriptpubkey_address" : "3PA2J9aN9N82q4YZyhBYHBcHpVvpGewvX2",
      "value" : 10000,
      "scriptpubkey_asm" : "OP_HASH160 OP_PUSHBYTES_20 eb762ef1946c2d462764d30112ce27c531fdd603 OP_EQUAL",
      "scriptpubkey" : "a914eb762ef1946c2d462764d30112ce27c531fdd60387"
    },
    {
      "scriptpubkey_type" : "p2sh",
      "scriptpubkey_address" : "3QQBsz2wPqNeWyEY6vnRKoCuHcyBgx2ZpQ",
      "value" : 88008,
      "scriptpubkey_asm" : "OP_HASH160 OP_PUSHBYTES_20 f91c21e619f4d51b2e58c3cfc0463057fc5e13a7 OP_EQUAL",
      "scriptpubkey" : "a914f91c21e619f4d51b2e58c3cfc0463057fc5e13a787"
    }
  ],
  "measurement" : 247,
  "locktime" : 0,
  "model" : 2,
  "payment" : 1992
}

I am making an attempt to ship one other transaction, however I am getting this error.

Error: Redeem script for enter #0 would not match the scriptPubKey within the prevout

That is my code in Javascript utilizing bitcoinjs-lib to create the enter. I am hardcoding the values for this instance.

const psbt = new bitcoin.Psbt({ community });

psbt.addInput({
    hash: "4621e1e4e8ace541902aac5ad6cff164da6e55c1bb8af793fb65e76d5a98c841",
    index: 0,
    witnessUtxo: { 
        worth: 10000, 
        script: Buffer.from("a914eb762ef1946c2d462764d30112ce27c531fdd60387", 'hex'),
    },
    redeemScript: Buffer.from("00143d6f823b6cfc0e422f14d011c9401c3bed6dfde0", 'hex'),
});

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles