Create transaction if not supplied in transaction message.

This commit is contained in:
Braydon Fuller 2015-04-01 11:42:51 -04:00
parent 101796f7e9
commit cf7d06baaa
3 changed files with 8 additions and 1 deletions

View File

@ -23,6 +23,9 @@ function TransactionMessage(arg, options) {
'An instance of Transaction or undefined is expected'
);
this.transaction = arg;
if (!this.transaction) {
this.transaction = new this.Transaction();
}
}
inherits(TransactionMessage, Message);

View File

@ -5,7 +5,6 @@ var inherits = require('util').inherits;
var bitcore = require('bitcore');
var BufferWriter = bitcore.encoding.BufferWriter;
var BufferReader = bitcore.encoding.BufferReader;
var _ = bitcore.deps._;
var BN = bitcore.crypto.BN;
var utils = require('../utils');

View File

@ -31,6 +31,11 @@ describe('Command Messages', function() {
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() {
var tx = new bitcore.Transaction();
var version = Number(tx.version);