0

The example code for psbt.addOutput() with address '1KRMKfeZcmosxALVYESdPNez1AP1mEtywp' works as expected. But if I change this to an testnet address I get this error: ' has no matching script'. I expect I need to specify testnet somewhere, but do not know where.

    const psbt = new bitcoin.Psbt();
    psbt.addInput({
        hash: 'b881ecef041a7396f3c225644507955732ae98d4a736de7b9ac235c69e1eb182',  
        nonWitnessUtxo: Buffer.from(
        '020000000001012aa24043833303b066cf10...1a1800',
        'hex',
       ),

    });

    psbt.addOutput({
      //address: '1KRMKfeZcmosxALVYESdPNez1AP1mEtywp', <- works
      address: 'mhm89vYkAjmU3MWUtyCUcsYYUvkgXT1FAw',
      value: 7240446,     //was 7250446

    });
1
  • 1
    Ok found it: const psbt = new bitcoin.Psbt({ network: testnet })
    – NoudS
    Commented Sep 27, 2019 at 12:07

1 Answer 1

1

you need to be passing the network parameter as the tuple and thus you forgot to put the {} on them . the link on github repo (https://github.com/bitcoinjs/bip174) explains the proposition in correct way.

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.