diff --git a/lib/bcoin/txdb.js b/lib/bcoin/txdb.js index f0377b0f..914eab9b 100644 --- a/lib/bcoin/txdb.js +++ b/lib/bcoin/txdb.js @@ -288,16 +288,13 @@ TXDB.prototype.getTable = function getTable(address, callback) { */ TXDB.prototype._addOrphan = function _addOrphan(key, outpoint, callback) { - var self = this; var batch = this.batch(); - var p; + var p = new BufferWriter(); this.db.get('o/' + key, function(err, data) { if (err) return callback(err); - p = new BufferWriter(); - if (data) p.writeBytes(data); @@ -611,7 +608,6 @@ TXDB.prototype._resolveOrphans = function _resolveOrphans(tx, index, callback) { var self = this; var batch = this.batch(); var hash = tx.hash('hex'); - var output = tx.outputs[index]; var key = hash + '/' + index; var coin; @@ -650,7 +646,7 @@ TXDB.prototype._resolveOrphans = function _resolveOrphans(tx, index, callback) { self._lazyRemove(orphan, next); }, function(err) { if (err) - return next(err); + return callback(err); return callback(null, false); }); @@ -1067,7 +1063,6 @@ TXDB.prototype._confirm = function _confirm(tx, info, callback) { */ TXDB.prototype.remove = function remove(hash, callback, force) { - var self = this; var unlock = this._lock(remove, [hash, callback], force); if (!unlock) @@ -1211,16 +1206,13 @@ TXDB.prototype._remove = function remove(tx, info, callback) { TXDB.prototype.unconfirm = function unconfirm(hash, callback, force) { var self = this; - var unlock = this._lock(unconfirm, [tx, callback], force); + var unlock = this._lock(unconfirm, [hash, callback], force); if (!unlock) return; callback = utils.wrap(callback, unlock); - if (hash.hash) - hash = hash.hash('hex'); - this.getTX(hash, function(err, tx) { if (err) return callback(err); @@ -1237,15 +1229,16 @@ TXDB.prototype.unconfirm = function unconfirm(hash, callback, force) { self.start(); - self._unconfirm(tx, info, function(err, res1, res2) { + self._unconfirm(tx, info, function(err, result, info) { if (err) { self.drop(); return callback(err); } + self.commit(function(err) { if (err) return callback(err); - callback(null, res1, res2); + return callback(null, result, info); }); }); }); @@ -1697,7 +1690,6 @@ TXDB.prototype.getCoins = function getCoins(id, callback) { */ TXDB.prototype.fillHistory = function fillHistory(tx, callback) { - var self = this; var hash, index, coin, input; if (tx.isCoinbase()) { @@ -1876,7 +1868,7 @@ TXDB.prototype.getCoin = function getCoin(hash, index, callback) { } this.db.fetch('c/' + key, function(data) { - var coin = bcoin.coin.fromRaw(data); + coin = bcoin.coin.fromRaw(data); coin.hash = hash; coin.index = index; self.coinCache.set(key, data);