Skip to content

Commit

Permalink
More of funky comparisons, now for TX
Browse files Browse the repository at this point in the history
  • Loading branch information
ukstv committed Apr 18, 2019
1 parent 01a7c8b commit 903d70d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions lib/funky.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
const MTX = require('bcoin/lib/primitives/mtx');
const TX = require('bcoin/lib/primitives/tx');
const CoinView = require('bcoin/lib/coins/coinview');

export function isTX(obj) {
return TX.isTX(obj) || (obj.constructor.toString() == TX.toString()) || isMTX(obj)
}

export function isMTX(obj) {
return MTX.isMTX(obj) || (obj.constructor.toString() == MTX.toString())
}
Expand Down
10 changes: 5 additions & 5 deletions lib/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class LedgerBTCApp {

async getTrustedInput(tx, inputIndex) {
assert(this.device);
assert(TX.isTX(tx));
assert(funky.isTX(tx));

const messages = utilTX.splitTransaction(tx);

Expand Down Expand Up @@ -121,7 +121,7 @@ class LedgerBTCApp {

async hashTransactionStart(tx, view, tis, isNew, hasWitness) {
assert(this.device);
assert(TX.isTX(tx), 'tx must be instanceof TX');
assert(funky.isTX(tx), 'tx must be instanceof TX');
assert(funky.isCoinView(view), 'view must be instanceof CoinView');
assert(typeof tis === 'object', 'Trusted input map not found.');

Expand Down Expand Up @@ -269,7 +269,7 @@ class LedgerBTCApp {

async hashTransactionStartSegwit(tx, view, key, prev) {
assert(this.device);
assert(TX.isTX(tx));
assert(funky.isTX(tx));

const newTX = new TX();
newTX.inject(tx);
Expand Down Expand Up @@ -305,7 +305,7 @@ class LedgerBTCApp {

async hashOutputFinalize(tx) {
assert(this.device);
assert(funky.isMTX(tx));
assert(funky.isTX(tx));

let size = encoding.sizeVarint(tx.outputs.length);

Expand Down Expand Up @@ -347,7 +347,7 @@ class LedgerBTCApp {

async hashSign(tx, path, type) {
assert(this.device);
assert(TX.isTX(tx));
assert(funky.isTX(tx));

if (typeof path === 'string')
path = util.parsePath(path, true);
Expand Down

0 comments on commit 903d70d

Please sign in to comment.