<p>I am facing same issue in bitcoinjs-lib Error: Redeem script for input #0 doesn't match the scriptPubKey in the prevout</p>
<p>psbt.addInput({
hash: &quot;155009fe07a45086066843faf90dcb5d541bf7d77d7e3dd0db7707e13947d314&quot;,
index: 1,
witnessUtxo: {
script: Buffer.from(&quot;a91473b7786d0ada73c9f0d90c42605c03ba3a76a88687&quot;, 'hex'), // this buffer is correct??
value: 86141,
},
redeemScript: Buffer.from(&quot;001473b7786d0ada73c9f0d90c42605c03ba3a76a886&quot;, 'hex'), // redeemscript is correct or not?, how to get redeemscript here?
});</p>
<p>please suggest how to correct it?</p>

CC BY-SA 4.0
2024-03-20T11:46:06.753Z
2024-03-20T11:46:06.753Z
ale021
<p>I'm trying to create a new bitcoin transaction using bitcoinjs-lib. Here is my transaction.</p>
<pre class="lang-json prettyprint-override"><code>{
  &quot;weight&quot; : 661,
  &quot;txid&quot; : &quot;4621e1e4e8ace541902aac5ad6cff164da6e55c1bb8af793fb65e76d5a98c841&quot;,
  &quot;status&quot; : {
    &quot;block_height&quot; : 800029,
    &quot;block_hash&quot; : &quot;000000000000000000045fd943ecff32113fbc9610570e8ef071deb3b92db312&quot;,
    &quot;confirmed&quot; : true,
    &quot;block_time&quot; : 1690187566
  },
  &quot;vin&quot; : [
    {
      &quot;inner_redeemscript_asm&quot; : &quot;OP_0 OP_PUSHBYTES_20 3d6f823b6cfc0e422f14d011c9401c3bed6dfde0&quot;,
      &quot;txid&quot; : &quot;edbcb7cdd428c4c251377a49ffc91b8eabef092200f10f88aea8452cea80293f&quot;,
      &quot;prevout&quot; : {
        &quot;scriptpubkey_type&quot; : &quot;p2sh&quot;,
        &quot;scriptpubkey_address&quot; : &quot;3QQBsz2wPqNeWyEY6vnRKoCuHcyBgx2ZpQ&quot;,
        &quot;value&quot; : 100000,
        &quot;scriptpubkey_asm&quot; : &quot;OP_HASH160 OP_PUSHBYTES_20 f91c21e619f4d51b2e58c3cfc0463057fc5e13a7 OP_EQUAL&quot;,
        &quot;scriptpubkey&quot; : &quot;a914f91c21e619f4d51b2e58c3cfc0463057fc5e13a787&quot;
      },
      &quot;scriptsig_asm&quot; : &quot;OP_PUSHBYTES_22 00143d6f823b6cfc0e422f14d011c9401c3bed6dfde0&quot;,
      &quot;is_coinbase&quot; : false,
      &quot;vout&quot; : 0,
      &quot;sequence&quot; : 4294967295,
      &quot;witness&quot; : [
        &quot;304402204d0ea4bc5a2ba018178daecdd55253fa6623e104aab5fd6e3198d9100f7f54c90220021255a9e25150da369cee1d279a3ed5e24a008c08c4c46c5338b397dd66bb8501&quot;,
        &quot;0243027fe517049903f9c8ad1302b3c11146acf6dbcb3f355f8b3c4f2b7182e1bc&quot;
      ],
      &quot;scriptsig&quot; : &quot;1600143d6f823b6cfc0e422f14d011c9401c3bed6dfde0&quot;
    }
  ],
  &quot;vout&quot; : [
    {
      &quot;scriptpubkey_type&quot; : &quot;p2sh&quot;,
      &quot;scriptpubkey_address&quot; : &quot;3PA2J9aN9N82q4YZyhBYHBcHpVvpGewvX2&quot;,
      &quot;value&quot; : 10000,
      &quot;scriptpubkey_asm&quot; : &quot;OP_HASH160 OP_PUSHBYTES_20 eb762ef1946c2d462764d30112ce27c531fdd603 OP_EQUAL&quot;,
      &quot;scriptpubkey&quot; : &quot;a914eb762ef1946c2d462764d30112ce27c531fdd60387&quot;
    },
    {
      &quot;scriptpubkey_type&quot; : &quot;p2sh&quot;,
      &quot;scriptpubkey_address&quot; : &quot;3QQBsz2wPqNeWyEY6vnRKoCuHcyBgx2ZpQ&quot;,
      &quot;value&quot; : 88008,
      &quot;scriptpubkey_asm&quot; : &quot;OP_HASH160 OP_PUSHBYTES_20 f91c21e619f4d51b2e58c3cfc0463057fc5e13a7 OP_EQUAL&quot;,
      &quot;scriptpubkey&quot; : &quot;a914f91c21e619f4d51b2e58c3cfc0463057fc5e13a787&quot;
    }
  ],
  &quot;size&quot; : 247,
  &quot;locktime&quot; : 0,
  &quot;version&quot; : 2,
  &quot;fee&quot; : 1992
}
</code></pre>
<p>I'm trying to send another transaction, but I'm getting this error.</p>
<pre><code>Error: Redeem script for input #0 doesn't match the scriptPubKey in the prevout
</code></pre>
<p>This is my code in Javascript using bitcoinjs-lib to create the input. I'm hardcoding the values for this example.</p>
<pre class="lang-js prettyprint-override"><code>const psbt = new bitcoin.Psbt({ network });

psbt.addInput({
    hash: &quot;4621e1e4e8ace541902aac5ad6cff164da6e55c1bb8af793fb65e76d5a98c841&quot;,
    index: 0,
    witnessUtxo: { 
        value: 10000, 
        script: Buffer.from(&quot;a914eb762ef1946c2d462764d30112ce27c531fdd60387&quot;, 'hex'),
    },
    redeemScript: Buffer.from(&quot;00143d6f823b6cfc0e422f14d011c9401c3bed6dfde0&quot;, 'hex'),
});
</code></pre>

<javascript><bitcoinjs>
Redeem script for input #0 doesn't match the scriptPubKey in the prevout
Berry Blue
# Redeem script for input #0 doesn't match the scriptPubKey in the prevout

(Asked by: username_0 on 2023-08-04)

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'),
});

**Tags:** javascript, bitcoinjs


---

## 1 answers

### Answer by username_1 on 2024-03-20. Score: -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?


---

