My code is as follows for a simple script to generate raw transactions.
var path = require('path').dirname(require.main.filename)
var bitcore = require('bitcore-lib')
var fs = require('fs')
var UnspentOutput = bitcore.Transaction.UnspentOutput
const blockchain = require('blockchain.info')
var json = fs.readFileSync(path + '/' + '1MPP77eCzAsCKMjtWzdcNw4XMUxb5ePBeA.json');
obj = JSON.parse(json)
var address = "1C3xRrMetAdz2VSnbuDTnwHj3Dyeo9auk2"
var amount = 1000000 //satoshis
var privkeySet = bitcore.PrivateKey.fromWIF(obj["priv"]);
var cAddr = "1MPP77eCzAsCKMjtWzdcNw4XMUxb5ePBeA"
blockchain.blockexplorer.getUnspentOutputs(cAddr).then(outputs => {
var utxo = new UnspentOutput({
"txid" : outputs['unspent_outputs'][0]['tx_hash'],
"vout" : outputs['unspent_outputs'][0]['tx_output_n'],
"address" : cAddr,
"script" : outputs['unspent_outputs'][0]['script'],
"satoshis" : outputs['unspent_outputs'][0]['value']
})
var utxos = [utxo]
var tx = new bitcore.Transaction()
.from(utxos)
.to(address, amount)
.change(cAddr)
.fee(10000)
.sign(privkeySet);
console.log("transaction = " + tx.verify());
console.log("Signature = " + tx.isFullySigned());
console.log(tx)
});
However, when I broadcast the raw transaction via blockchain.info, I get the following...
Missing parents for 62ce2eacfb96368dc7751e023d0890eae2e700c46dce1bd91192be27db6e97e7 while inserting: [872f22da56a21f500b87db1a6361ca228cca6b75913faeb4cb9ce2d19133a185]
Both verify
and isFullySigned
return true. The raw transaction is as follows...
010000000185a13391d1e29ccbb4ae3f91756bca8c22ca61631adb870b501fa256da222f87000000006b483045022100d713fbef655d7962731cc672b84a29db25fb274494a783f0d6507a683fd91301022044881127ec59d291d7f0dcf12bc7163be5bcf0d64808d5e8f5fac897e0c40d9401210327efda0447312e9bf7daff4788aa721302cc14778bcbdfb4e679229e985357b9ffffffff0240420f00000000001976a91479387c223f297cad674c523bd44403c1caf666ca88ac7ae90300000000001976a914df9e1e985d57beaafa44c6cafe712f05cddc2db188ac00000000
Absolutely no idea what's going wrong. Transaction is signing, the unspent output is good, etc. Any help is appreciated, thanks!
via Zenzile
No comments:
Post a Comment