Bitcoin
javascript – Enabled script for input #0 does not match scriptPubKey from previous output – Stack Overflow
I’m trying to create a new Bitcoin transaction using bitcoinjs-lib. Here’s my deal.
"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 and I’m getting this error.
Error: Redeem script for input #0 doesn't match the scriptPubKey in the prevout
This is code in Javascript that uses bitcoinjs-lib to generate input. I’m hardcoding the values in 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'),
);