BCH Send transaction failed: Missing inputs 25
BCH Send transaction failed: Missing inputs 25
I am using Bitcoin Cash JS to create a transaction, and my code is as follows:
let BITBOXCli = require('bitbox-cli/lib/bitbox-cli').default; const explorers = require('bitcore-explorers') const insight = new explorers.Insight('https://test-bch-insight.bitpay.com') let BITBOX = new BITBOXCli(); let txb = new BITBOX.TransactionBuilder('testnet'); var To = 'mkiuwbSQQVxMvvbBcYEKUdZgJfURhu3hrW' var from = 'mvStb7hPtDCL8dmyifPGcYTuToVzf7ajTb'; var bch = require('bitcoincashjs') var bchLib = require('@owstack/bch-lib') const buf = new Buffer('b27ab45d3e3d157e8b95f800347974f9991cf13ceb814e1992f40c5e4e6d5253', 'hex') const privateKey = new bch.PrivateKey(buf, bch.Networks.testnet) const address = privateKey.toAddress('testnet') insight.getUnspentUtxos(address.toString(), function (error, utxos) { if (error) { console.error(error) return } console.log(utxos) const utxo = { txid: utxos[0].txid, outputIndex: utxos[0].vout, script: utxos[0].scriptPubKey, satoshis: utxos[0].satoshis } const transaction = new bch.Transaction() .from(utxo) .to(To, 50000) .sign(0, privateKey) console.log(transaction.toString()) });
Now when I am running this code, I am able to get the raw transaction hash but I am not able to broadcast transaction and message is as follows:
Missing Inputs Error:-25
Any idea about this error? Or is there any other way to create BCH transaction?
https://ift.tt/2MWW3bW
Comments
Post a Comment