fix lossing signatured after from-toObj roundtrip
This commit is contained in:
parent
cbfd30af16
commit
1c6ec69c48
|
@ -445,7 +445,7 @@ TransactionBuilder._mapKeys = function(keys) {
|
||||||
}
|
}
|
||||||
var addr = wk.storeObj().addr;
|
var addr = wk.storeObj().addr;
|
||||||
walletKeyMap[addr] = wk;
|
walletKeyMap[addr] = wk;
|
||||||
|
|
||||||
}
|
}
|
||||||
return walletKeyMap;
|
return walletKeyMap;
|
||||||
};
|
};
|
||||||
|
@ -766,7 +766,7 @@ TransactionBuilder.prototype.sign = function(keys) {
|
||||||
ins = tx.ins,
|
ins = tx.ins,
|
||||||
l = ins.length,
|
l = ins.length,
|
||||||
walletKeyMap = TransactionBuilder._mapKeys(keys);
|
walletKeyMap = TransactionBuilder._mapKeys(keys);
|
||||||
|
|
||||||
|
|
||||||
for (var i = 0; i < l; i++) {
|
for (var i = 0; i < l; i++) {
|
||||||
var input = this.inputMap[i];
|
var input = this.inputMap[i];
|
||||||
|
@ -834,6 +834,17 @@ TransactionBuilder.prototype.toObj = function() {
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TransactionBuilder.prototype._setScriptSig = function(inScriptSig) {
|
||||||
|
this.vanilla.scriptSig = inScriptSig;
|
||||||
|
|
||||||
|
for (var i in inScriptSig) {
|
||||||
|
this.tx.ins[i].s = new Buffer(inScriptSig[i], 'hex');
|
||||||
|
var scriptSig = new Script(this.tx.ins[i].s);
|
||||||
|
if (scriptSig.finishedMultiSig() !== false)
|
||||||
|
this.inputsSigned++;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// fromObj
|
// fromObj
|
||||||
// -------
|
// -------
|
||||||
// Returns a TransactionBuilder instance given
|
// Returns a TransactionBuilder instance given
|
||||||
|
@ -855,12 +866,8 @@ TransactionBuilder.fromObj = function(data) {
|
||||||
if (data.outs) {
|
if (data.outs) {
|
||||||
b.setOutputs(data.outs);
|
b.setOutputs(data.outs);
|
||||||
|
|
||||||
for (var i in data.scriptSig) {
|
if (data.scriptSig) {
|
||||||
b.tx.ins[i].s = new Buffer(data.scriptSig[i], 'hex');
|
b._setScriptSig(data.scriptSig);
|
||||||
|
|
||||||
var scriptSig = new Script(b.tx.ins[i].s);
|
|
||||||
if (scriptSig.finishedMultiSig() !== false)
|
|
||||||
b.inputsSigned++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -919,6 +919,15 @@ describe('TransactionBuilder', function() {
|
||||||
util.valueToBigInt(tx.outs[1].v).cmp(2990000).should.equal(0);
|
util.valueToBigInt(tx.outs[1].v).cmp(2990000).should.equal(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('#clone roundtrip, signed', function() {
|
||||||
|
var b = getBuilder3();
|
||||||
|
b.sign(testdata.dataUnspentSign.keyStrings);
|
||||||
|
b.isFullySigned().should.equal(true);
|
||||||
|
|
||||||
|
var b2 = b.clone().clone().clone();
|
||||||
|
b2.isFullySigned().should.equal(true);
|
||||||
|
});
|
||||||
|
|
||||||
it('#toObj #fromObj roundtrip, step signatures p2sh/p2pubkeyhash', function() {
|
it('#toObj #fromObj roundtrip, step signatures p2sh/p2pubkeyhash', function() {
|
||||||
var b = getP2shBuilder(1);
|
var b = getP2shBuilder(1);
|
||||||
|
|
||||||
|
@ -1204,8 +1213,5 @@ describe('TransactionBuilder', function() {
|
||||||
b2.merge(b)
|
b2.merge(b)
|
||||||
}).should.throw('incompatible');
|
}).should.throw('incompatible');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue