Add fee to serialization

This commit is contained in:
Esteban Ordano 2015-02-04 12:45:02 -03:00
parent ed393dcb91
commit 1f45e88268
2 changed files with 12 additions and 0 deletions

View File

@ -239,6 +239,7 @@ Transaction.prototype.toObject = function toObject() {
});
return {
change: this._change ? this._change.toString() : undefined,
fee: this._fee ? this._fee : undefined,
version: this.version,
inputs: inputs,
outputs: outputs,
@ -269,6 +270,9 @@ Transaction.prototype.fromObject = function(transaction) {
if (transaction.change) {
this.change(transaction.change);
}
if (transaction.fee) {
this.fee(transaction.fee);
}
this.nLockTime = transaction.nLockTime;
this.version = transaction.version;
};

View File

@ -245,6 +245,14 @@ describe('Transaction', function() {
return transaction.serialize(true);
}).to.not.throw();
});
it('stores the fee set by the user', function() {
var fee = 1000000;
var serialized = new Transaction()
.fee(fee)
.toObject();
var deserialized = new Transaction(serialized);
expect(deserialized._fee).to.equal(fee);
});
});
describe('checked serialize', function() {