bitcoinjs – Error validating transaction … Script was NOT verified successfully

1 Mins read

I’m getting this error below when trying to broadcast a transaction with the code below. I’m new to blockchain development and I’ve been trying to solve this but can’t seem to figure it out. I believe I’m inputting incorrect values, but I’m unsure which, could someone let me know? Let me know what other details you need.

Transaction Hex:

Error validating transaction: Error running script for input 0 referencing 677b6288cbb2a5056059b8b28858ac0415b031085b975c12c5774908311c65ed at 0: Script was NOT verified successfully..

const bitcoin = require('bitcoinjs-lib')
const network = bitcoin.networks.testnet
const keyPairAlice1 = bitcoin.ECPair.fromWIF('cMz5Wmw7ee7x57Tbm1W77Apf9AkE9uJy19fqaGVfBdnRoFDL9Bus', network) 
const p2wpkhAlice1 = bitcoin.payments.p2wpkh({pubkey: keyPairAlice1.publicKey, network}) 
const p2shAlice1 = bitcoin.payments.p2sh({redeem: p2wpkhAlice1, network}) 
const redeemScript = p2shAlice1.redeem.output.toString('hex')

const psbt = new bitcoin.Psbt({network})
    hash: '677b6288cbb2a5056059b8b28858ac0415b031085b975c12c5774908311c65ed',
    index: 0,
    witnessUtxo: {
        // Buffer.from('0014dd8ad4d50e55c26ce36be3eb3ec2bbf44615d9a4', 'hex'), 
        Buffer.from('a914' +
        bitcoin.crypto.hash160(Buffer.from('0014' + 'dd8ad4d50e55c26ce36be3eb3ec2bbf44615d9a4', 'hex')).toString('hex') +
        '87', 'hex'),
      value: 10000, 
    redeemScript: Buffer.from(redeemScript, 'hex')
    address: "2MuL1HGkV9hAmGwefCAr4fa2Kk63CHYFo6u",
    value: 9000,

psbt.signInput(0, keyPairAlice1)

console.log('Transaction hexadecimal:')

Source link

Related posts

6 Questions for Mati Greenspan of Quantum Economics – Cointelegraph Magazine

2 Mins read
We ask the buidlers in the blockchain and cryptocurrency sector for their thoughts on the industry… and we throw in a few…

Crypto Conference DeFiCon 2021 to Be Hosted on December 18-19 in Brooklyn, NYC – Press release Bitcoin News

1 Mins read
press release PRESS RELEASE. The next crypto conference lighting up the season is DeFiCon 2021, hosted on December 18-19 in Brooklyn, NYC….

China’s Hainan Province Ramps Up Crackdown on Crypto Mining Operations – Mining Bitcoin News

2 Mins read
The province of Hainan in South China has taken steps aimed at curbing crypto mining activities. Besides blacklisting the industry, local authorities…

Leave a Reply

Your email address will not be published. Required fields are marked *