bitcore-explorers icon indicating copy to clipboard operation
bitcore-explorers copied to clipboard

can't broadcast serialized transaction

Open maraoz opened this issue 10 years ago • 3 comments

the following code results in an error:

'use strict';

var bitcore = require('bitcore');
var explorers = require('bitcore-explorers');
var insight = new explorers.Insight();

var Transaction = bitcore.Transaction;

var tx = new Transaction('0100000001c54cd2b468b0a0e24f573ee10bedfd7500c7079bf98c1ec7d56b330147d6f188000000006b48304502210091126306c144d97b7c811f0d7db535ae8ce709739b87ed2afda23418429adcb602202fe57542741477f02d4d42d3050dc71975840dff74c20ebbfcc6ca1773a044fd012102b9740162829af19408920ad4111298b98795b911d37514d975ac1912578545fcffffffff02074c0f00000000001976a9145ffd525ef01e229497e56b189fdd2a42bd36ba6688ace96de605000000001976a9145ffd525ef01e229497e56b189fdd2a42bd36ba6688ac00000000');
console.log(tx);
insight.broadcast(tx, function(err, txid) {
  if (err) {
    throw err;
  }
  console.log(txid);
});

and...

$ node broadcast.js 
<Transaction: 0100000001c54cd2b468b0a0e24f573ee10bedfd7500c7079bf98c1ec7d56b330147d6f188000000006b48304502210091126306c144d97b7c811f0d7db535ae8ce709739b87ed2afda23418429adcb602202fe57542741477f02d4d42d3050dc71975840dff74c20ebbfcc6ca1773a044fd012102b9740162829af19408920ad4111298b98795b911d37514d975ac1912578545fcffffffff02074c0f00000000001976a9145ffd525ef01e229497e56b189fdd2a42bd36ba6688ace96de605000000001976a9145ffd525ef01e229497e56b189fdd2a42bd36ba6688ac00000000>

/home/maraoz/git/segments/node_modules/bitcore/lib/transaction/transaction.js:723
        throw new errors.Transaction.Input.MissingPreviousOutput();
              ^
No previous output information.

Should work for an already serialized transaction

maraoz avatar May 05 '15 22:05 maraoz

uncheckedSerialize()?

braydonf avatar May 05 '15 22:05 braydonf

I think the problem is with the checks done on checkedSerialize... It tries to calculate fees when it's not always possible.

maraoz avatar May 06 '15 15:05 maraoz

An immutable transaction https://github.com/bitpay/bitcore/issues/1210 I think would help in this case as well.

var tx = new ImmutableTransaction('0100000001c54...');

There wouldn't be any serialization checks, and getting the hash of the tx would be faster and better for syncing.

braydonf avatar May 06 '15 15:05 braydonf