bitpay / bitcore-lib-cash

Other
32 stars 42 forks source link

Address has mismatched network type #32

Closed cancerts closed 5 years ago

cancerts commented 5 years ago

this is my code

const bch = require('bitcore-lib-cash'); var privateKey = new bitcore.PrivateKey('L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy'); var utxo = { "txId" : "115e8f72f39fad874cfab0deed11a80f24f967a84079fb56ddf53ea02e308986", "outputIndex" : 0, "address" : "17XBj6iFEsf8kzDMGQk5ghZipxX49VXuaV", "script" : "76a91447862fe165e6121af80d5dde1ecb478ed170565b88ac", "satoshis" : 50000 };

var transaction = new bitcore.Transaction() .from(utxo) .addData('bitcore rocks') // Add OP_RETURN data .sign(privateKey); console.log(transaction.toString())

but i get the error Address has mismatched network type

cancerts commented 5 years ago

and how i make a two output

var transaction = new bitcore.Transaction() .from(utxo, publicKeys, 2) .to('16XBj6iFEsf8kzDMGQk5ghZipxX49VXuaV', 20000) .to('17XBj6iFEsf8kzDMGQk5ghZipxX49VXuaV', 10000) .sign(privateKeys);

is don,t work like this

matiu commented 5 years ago

you need to use cashaddr format.

https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/cashaddr.md