From d7db03daa3c8e5f9155b0a5d0c245a81045debc6 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 23 Jun 2016 12:06:54 -0700 Subject: [PATCH] fix wallet hashes. do not request mempool on main. --- lib/bcoin/pool.js | 12 ++++++++++-- lib/bcoin/wallet.js | 26 +++++++++++++------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/lib/bcoin/pool.js b/lib/bcoin/pool.js index 6d5c2d13..32ceae95 100644 --- a/lib/bcoin/pool.js +++ b/lib/bcoin/pool.js @@ -311,8 +311,10 @@ Pool.prototype._init = function _init() { if (!self.synced) { // Ask loader for a mempool snapshot. - if (self.peers.load) - self.peers.load.sendMempool(); + if (self.network.requestMempool) { + if (self.peers.load) + self.peers.load.sendMempool(); + } // Ask all peers for their latest blocks. self.sync(); @@ -1283,6 +1285,12 @@ Pool.prototype._addPeer = function _addPeer() { }); }; +/** + * Remove a peer from any list. Drop all load requests. + * @private + * @param {Peer} peer + */ + Pool.prototype._removePeer = function _removePeer(peer) { utils.binaryRemove(this.peers.pending, peer, compare); utils.binaryRemove(this.peers.regular, peer, compare); diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index c4b94120..d7c45787 100644 --- a/lib/bcoin/wallet.js +++ b/lib/bcoin/wallet.js @@ -695,7 +695,8 @@ Wallet.prototype.deriveInputs = function deriveInputs(tx, callback) { Wallet.prototype.getInputPaths = function getInputPaths(tx, callback) { var self = this; var paths = []; - var hashes; + var hashes = []; + var hash; function done() { utils.forEachSerial(hashes, function(hash, next, i) { @@ -718,7 +719,9 @@ Wallet.prototype.getInputPaths = function getInputPaths(tx, callback) { if (tx instanceof bcoin.input) { if (!tx.coin) return callback(new Error('Not all coins available.')); - hashes = [tx.coin.getHash('hex')]; + hash = tx.coin.getHash('hex') + if (hash) + hashes.push(hash); return done(); } @@ -743,12 +746,16 @@ Wallet.prototype.getInputPaths = function getInputPaths(tx, callback) { Wallet.prototype.getOutputPaths = function getOutputPaths(tx, callback) { var self = this; var paths = []; - var hashes; + var hashes = []; + var hash; - if (tx instanceof bcoin.output) - hashes = [tx.getHash('hex')]; - else + if (tx instanceof bcoin.output) { + hash = tx.getHash('hex'); + if (hash) + hashes.push(hash); + } else { hashes = tx.getOutputHashes('hex'); + } utils.forEachSerial(hashes, function(hash, next, i) { self.getPath(hash, function(err, path) { @@ -975,13 +982,6 @@ Wallet.prototype.sign = function sign(tx, options, callback) { var total = 0; var i, address, key, master; - if (Array.isArray(tx)) { - utils.forEachSerial(tx, function(tx, next) { - self.sign(tx, options, next); - }, callback); - return; - } - if (typeof options === 'function') { callback = options; options = {};