Browse Source

Fix Transaction.fromObject

patch-2
Kirill Fomichev 9 years ago
parent
commit
446760fec7
  1. 2
      lib/transaction/transaction.js
  2. 6
      test/transaction/transaction.js

2
lib/transaction/transaction.js

@ -381,7 +381,7 @@ Transaction.prototype.fromObject = function fromObject(arg) {
this._changeScript = new Script(transaction.changeScript); this._changeScript = new Script(transaction.changeScript);
} }
if (transaction.fee) { if (transaction.fee) {
this.fee(transaction.fee); this._fee = transaction.fee;
} }
this.nLockTime = transaction.nLockTime; this.nLockTime = transaction.nLockTime;
this.version = transaction.version; this.version = transaction.version;

6
test/transaction/transaction.js

@ -79,10 +79,11 @@ describe('Transaction', function() {
a.should.deep.equal(b); 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() var tx = new Transaction()
.from(simpleUtxoWith100000Satoshis) .from(simpleUtxoWith100000Satoshis)
.to([{address: toAddress, satoshis: 50000}]) .to([{address: toAddress, satoshis: 50000}])
.fee(15000)
.change(changeAddress) .change(changeAddress)
.sign(privateKey); .sign(privateKey);
@ -92,10 +93,11 @@ describe('Transaction', function() {
txData.should.equal(txData2); 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() var tx = new Transaction()
.from(p2shUtxoWith1BTC, [p2shPublicKey1, p2shPublicKey2, p2shPublicKey3], 2) .from(p2shUtxoWith1BTC, [p2shPublicKey1, p2shPublicKey2, p2shPublicKey3], 2)
.to([{address: toAddress, satoshis: 50000}]) .to([{address: toAddress, satoshis: 50000}])
.fee(15000)
.change(changeAddress) .change(changeAddress)
.sign(p2shPrivateKey1) .sign(p2shPrivateKey1)
.sign(p2shPrivateKey2); .sign(p2shPrivateKey2);

Loading…
Cancel
Save