diff --git a/lib/blockchain/chaindb.js b/lib/blockchain/chaindb.js index cd5f1615..34e89f23 100644 --- a/lib/blockchain/chaindb.js +++ b/lib/blockchain/chaindb.js @@ -945,7 +945,7 @@ ChainDB.prototype.getRawBlock = co(function* getRawBlock(block) { ChainDB.prototype.getFullBlock = co(function* getFullBlock(hash) { var block = yield this.getBlock(hash); - var i, j, view, undo, tx, input; + var i, j, view, undo, tx, input, hash, coins; if (!block) return; @@ -958,8 +958,22 @@ ChainDB.prototype.getFullBlock = co(function* getFullBlock(hash) { for (i = block.txs.length - 1; i > 0; i--) { tx = block.txs[i]; + for (j = tx.inputs.length - 1; j >= 0; j--) { input = tx.inputs[j]; + hash = input.prevout.hash; + + if (!view.has(hash)) { + assert(!undo.isEmpty()); + + if (undo.top().height === -1) { + coins = new Coins(); + coins.hash = hash; + coins.coinbase = false; + view.add(coins); + } + } + input.coin = undo.apply(view, input.prevout); } }