Add fee to serialization
This commit is contained in:
parent
ed393dcb91
commit
1f45e88268
@ -239,6 +239,7 @@ Transaction.prototype.toObject = function toObject() {
|
|||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
change: this._change ? this._change.toString() : undefined,
|
change: this._change ? this._change.toString() : undefined,
|
||||||
|
fee: this._fee ? this._fee : undefined,
|
||||||
version: this.version,
|
version: this.version,
|
||||||
inputs: inputs,
|
inputs: inputs,
|
||||||
outputs: outputs,
|
outputs: outputs,
|
||||||
@ -269,6 +270,9 @@ Transaction.prototype.fromObject = function(transaction) {
|
|||||||
if (transaction.change) {
|
if (transaction.change) {
|
||||||
this.change(transaction.change);
|
this.change(transaction.change);
|
||||||
}
|
}
|
||||||
|
if (transaction.fee) {
|
||||||
|
this.fee(transaction.fee);
|
||||||
|
}
|
||||||
this.nLockTime = transaction.nLockTime;
|
this.nLockTime = transaction.nLockTime;
|
||||||
this.version = transaction.version;
|
this.version = transaction.version;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -245,6 +245,14 @@ describe('Transaction', function() {
|
|||||||
return transaction.serialize(true);
|
return transaction.serialize(true);
|
||||||
}).to.not.throw();
|
}).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() {
|
describe('checked serialize', function() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user