From c358a1b59e15e13ce575be76a27e973b49475701 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 18 Dec 2016 02:54:01 -0800 Subject: [PATCH] mtx: coin selection - handle reorgd coinbases. --- lib/primitives/mtx.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/primitives/mtx.js b/lib/primitives/mtx.js index fab2e7d1..3c37dd27 100644 --- a/lib/primitives/mtx.js +++ b/lib/primitives/mtx.js @@ -1562,6 +1562,14 @@ CoinSelector.prototype.isSpendable = function isSpendable(coin) { if (this.height === -1) return true; + if (coin.coinbase) { + if (coin.height === -1) + return false; + + if (this.height + 1 < coin.height + maturity) + return false; + } + if (this.confirmations > 0) { if (coin.height === -1) return this.confirmations <= 0; @@ -1577,11 +1585,6 @@ CoinSelector.prototype.isSpendable = function isSpendable(coin) { return false; } - if (coin.coinbase) { - if (this.height + 1 < coin.height + maturity) - return false; - } - return true; };