Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
Fix Transaction.fromObject
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid committed Dec 1, 2015
1 parent 8f53fc8 commit 446760f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/transaction/transaction.js
Expand Up @@ -381,7 +381,7 @@ Transaction.prototype.fromObject = function fromObject(arg) {
this._changeScript = new Script(transaction.changeScript);
}
if (transaction.fee) {
this.fee(transaction.fee);
this._fee = transaction.fee;
}
this.nLockTime = transaction.nLockTime;
this.version = transaction.version;
Expand Down
6 changes: 4 additions & 2 deletions test/transaction/transaction.js
Expand Up @@ -79,10 +79,11 @@ describe('Transaction', function() {
a.should.deep.equal(b);
});

it('serialize to Object with signatures roundtrip', function() {
it('toObject/fromObject with signatures and custom fee', function() {
var tx = new Transaction()
.from(simpleUtxoWith100000Satoshis)
.to([{address: toAddress, satoshis: 50000}])
.fee(15000)
.change(changeAddress)
.sign(privateKey);

Expand All @@ -92,10 +93,11 @@ describe('Transaction', function() {
txData.should.equal(txData2);
});

it('serialize to Object with p2sh signatures roundtrip', function() {
it('toObject/fromObject with p2sh signatures and custom fee', function() {
var tx = new Transaction()
.from(p2shUtxoWith1BTC, [p2shPublicKey1, p2shPublicKey2, p2shPublicKey3], 2)
.to([{address: toAddress, satoshis: 50000}])
.fee(15000)
.change(changeAddress)
.sign(p2shPrivateKey1)
.sign(p2shPrivateKey2);
Expand Down

0 comments on commit 446760f

Please sign in to comment.