Create transaction if not supplied in transaction message.
This commit is contained in:
parent
101796f7e9
commit
cf7d06baaa
@ -23,6 +23,9 @@ function TransactionMessage(arg, options) {
|
|||||||
'An instance of Transaction or undefined is expected'
|
'An instance of Transaction or undefined is expected'
|
||||||
);
|
);
|
||||||
this.transaction = arg;
|
this.transaction = arg;
|
||||||
|
if (!this.transaction) {
|
||||||
|
this.transaction = new this.Transaction();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
inherits(TransactionMessage, Message);
|
inherits(TransactionMessage, Message);
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,6 @@ var inherits = require('util').inherits;
|
|||||||
var bitcore = require('bitcore');
|
var bitcore = require('bitcore');
|
||||||
var BufferWriter = bitcore.encoding.BufferWriter;
|
var BufferWriter = bitcore.encoding.BufferWriter;
|
||||||
var BufferReader = bitcore.encoding.BufferReader;
|
var BufferReader = bitcore.encoding.BufferReader;
|
||||||
var _ = bitcore.deps._;
|
|
||||||
var BN = bitcore.crypto.BN;
|
var BN = bitcore.crypto.BN;
|
||||||
|
|
||||||
var utils = require('../utils');
|
var utils = require('../utils');
|
||||||
|
|||||||
@ -31,6 +31,11 @@ describe('Command Messages', function() {
|
|||||||
message.transaction.should.be.instanceof(bitcore.Transaction);
|
message.transaction.should.be.instanceof(bitcore.Transaction);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should create a transaction instance', function() {
|
||||||
|
var message = messages.Transaction();
|
||||||
|
message.transaction.should.be.instanceof(bitcore.Transaction);
|
||||||
|
});
|
||||||
|
|
||||||
it('version should remain the same', function() {
|
it('version should remain the same', function() {
|
||||||
var tx = new bitcore.Transaction();
|
var tx = new bitcore.Transaction();
|
||||||
var version = Number(tx.version);
|
var version = Number(tx.version);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user