0

I'm trying to create a new bitcoin transaction using bitcoinjs-lib. Here is my transaction.

{
  "weight" : 661,
  "txid" : "4621e1e4e8ace541902aac5ad6cff164da6e55c1bb8af793fb65e76d5a98c841",
  "status" : {
    "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"
    }
  ],
  "size" : 247,
  "locktime" : 0,
  "version" : 2,
  "fee" : 1992
}

I'm trying to send another transaction, but I'm getting this error.

Error: Redeem script for input #0 doesn't match the scriptPubKey in the prevout

This is my code in Javascript using bitcoinjs-lib to create the input. I'm hardcoding the values for this example.

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

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

1 Answer 1

-1

I am facing same issue in bitcoinjs-lib Error: Redeem script for input #0 doesn't match the scriptPubKey in the prevout

psbt.addInput({ hash: "155009fe07a45086066843faf90dcb5d541bf7d77d7e3dd0db7707e13947d314", index: 1, witnessUtxo: { script: Buffer.from("a91473b7786d0ada73c9f0d90c42605c03ba3a76a88687", 'hex'), // this buffer is correct?? value: 86141, }, redeemScript: Buffer.from("001473b7786d0ada73c9f0d90c42605c03ba3a76a886", 'hex'), // redeemscript is correct or not?, how to get redeemscript here? });

please suggest how to correct it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.