bitpay / bitcore-lib

A pure and powerful JavaScript Bitcoin library
https://bitcore.io/
Other
613 stars 1.03k forks source link

Missing inputs. Code:-25 When boardcast transaction to network #280

Closed dovancao closed 5 years ago

dovancao commented 5 years ago

Hi everyone. I tried used bitcore-lib to generate signed Transaction then I will use blockdozer.com to boardcast it. But I always got this error when I tried boardcast my transaction This is my hex string transaction:

01000000011232bce447f617d876c20fe56e917f5601a4128682f6ba65e28bb60c7258a2f8000000006b483045022100cb30ae41493e4b56cb4799a2bfafde303ba0e56d9e0e8da9d90d9a41af2cec0b02204b3789b564c782ba0f3163d238c5983b763f95176a07b4eced031c0e0368b7ac412102d060bcaf666b4fc128258c51aebd9c319042a815b67651b7e7f4631757c5466affffffff01204e0000000000001976a9147a82c82a4b5e3e6db526f2f9ef20ff125561bb9088ac00000000

This was my error when I had tried to boardcast it:

An error occured:
Missing inputs. Code:-25

This is my code:

const bch = require('bitcore-lib-cash');
let utxo = {
  "txId" : "f8a258720cb68be265baf6828612a401567f916ee50fc276d817f647e4bc3212",
  "vout" : 0,
  "address" : "n282sbTawPEUSqZ5Se8W3z8MWKAV3vcr7K",
  "scriptPubKey" : bch.Script.buildPublicKeyHashOut("n282sbTawPEUSqZ5Se8W3z8MWKAV3vcr7K").toString(),
  "amount" : 0.0009887
};

// notice that the change address is the same as the address in the utxo
let transaction = new bch.Transaction()
  .from(utxo)
  .to('mrgjQLqBZih9ETT7R4hwXpXujCXuwojurS', 20000)
  .fee(1000)
  .change('n282sbTawPEUSqZ5Se8W3z8MWKAV3vcr7K')
  .sign('7e0b3ee8e73563eea616b2084c53fa1cc8cc0ca9882298607d46956dff434856');

console.log(transaction.toString());

Thank you for your help

matiu commented 5 years ago

From your UTXOs, there is no transaction "f8a258720cb68be265baf6828612a401567f916ee50fc276d817f647e4bc3212"

on bitcoin cash.

Are you trying to use BTC or BCH?