Use new class based function checking instead of prototypal checking

This commit is contained in:
Sky Young 2019-07-25 09:01:30 -06:00
parent d1034b3a82
commit e334370777

View File

@ -3,7 +3,6 @@
var Message = require('../message');
var inherits = require('util').inherits;
var bitcore = require('flocore-lib');
var bcoin = require('fcoin');
var $ = bitcore.util.preconditions;
var _ = bitcore.deps._;
@ -29,8 +28,8 @@ function TransactionMessage(arg, options) {
inherits(TransactionMessage, Message);
TransactionMessage.prototype.setPayload = function(payload) {
if (this.Transaction.prototype.fromRaw) {
this.transaction = bcoin.tx.fromRaw(payload);
if (typeof this.Transaction.fromRaw === 'function') {
this.transaction = this.Transaction.fromRaw(payload);
} else if (this.Transaction.prototype.fromBuffer) {
this.transaction = new this.Transaction().fromBuffer(payload);
} else {
@ -39,7 +38,7 @@ TransactionMessage.prototype.setPayload = function(payload) {
};
TransactionMessage.prototype.getPayload = function() {
if (this.Transaction.prototype.toRaw) {
if (typeof this.Transaction.fromRaw === 'function') {
return this.transaction.toRaw();
}
return this.transaction.toBuffer();