diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index ffb0ddc0..4fd5c496 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -560,7 +560,7 @@ script.execute = function execute(s, stack, tx, index, recurse) { n = new bn(0); switch (o) { case 'add': - n = n1.add(b2); + n = n1.add(n2); break; case 'sub': n = n1.sub(n2); diff --git a/lib/bcoin/tx.js b/lib/bcoin/tx.js index 2bc8a4bd..b304506a 100644 --- a/lib/bcoin/tx.js +++ b/lib/bcoin/tx.js @@ -852,10 +852,10 @@ TX.prototype.getConfirmations = function getConfirmations(chain) { if (!chain) return 0; - top = chain.index.heights[chain.index.heights.length - 1]; + top = chain.getHeight(chain.index.hashes[chain.index.hashes.length - 1]); height = this.getHeight(chain); - if (height === -1) + if (top === -1 || height === -1) return 0; return top - height + 1;