fix error in commit

This commit is contained in:
Matias Alejo Garcia 2014-03-15 22:00:58 -03:00
parent 530f05f876
commit 242f4381ae
1 changed files with 30 additions and 1 deletions

View File

@ -609,7 +609,36 @@ Transaction.prototype.fromObj = function fromObj(obj) {
txobj.ins = [];
txobj.outs = [];
var tx = new Transaction(txobj);
obj.inputs.forEach(function(inputobj) {
var txin = new TransactionIn();
txin.s = util.EMPTY_BUFFER;
txin.q = 0xffffffff;
var hash = new Buffer(inputobj.txid, 'hex');
hash = buffertools.reverse(hash);
var vout = parseInt(inputobj.vout);
var voutBuf = new Buffer(4);
voutBuf.writeUInt32LE(vout, 0);
txin.o = Buffer.concat([hash, voutBuf]);
txobj.ins.push(txin);
});
var keys = Object.keys(obj.outputs);
keys.forEach(function(addrStr) {
var addr = new Address(addrStr);
var script = Script.createPubKeyHashOut(addr.payload());
var valueNum = bignum(obj.outputs[addrStr]);
var value = util.bigIntToValue(valueNum);
var txout = new TransactionOut();
txout.v = value;
txout.s = script.getBuffer();
txobj.outs.push(txout);
});
this.lock_time = txobj.lock_time;
this.version = txobj.version;