Fix transaction signature cache.

The Transaction#sign method would notice that a previous signature was still
valid and skip signing again. Great, except it would throw the old
signature away first, leaving no signature at all. Fixed.
This commit is contained in:
Stefan Thomas
2013-11-11 05:57:40 -08:00
parent 34ea528ade
commit e065238758

View File

@@ -227,11 +227,16 @@ Transaction.prototype.hash = function (prefix, as_uint256) {
Transaction.prototype.sign = function () {
var seed = Seed.from_json(this._secret);
var prev_sig = this.tx_json.TxnSignature;
delete this.tx_json.TxnSignature;
var hash = this.signing_hash();
if (hash === this._previous_signing_hash) return;
// If the hash is the same, we can re-use the previous signature
if (prev_sig && hash === this._previous_signing_hash) {
this.tx_json.TxnSignature = prev_sig;
return;
}
var key = seed.get_key(this.tx_json.Account);
var sig = key.sign(hash, 0);