Why do I get: Error: <address> has no matching Script

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

    });

NoudS

Posted 2019-09-27T12:01:43.070

Reputation: 1

Ok found it: const psbt = new bitcoin.Psbt({ network: testnet })NoudS 2019-09-27T12:07:07.993

Answers

0

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.

dhruv malik

Posted 2019-09-27T12:01:43.070

Reputation: 1