From 856957eee92c1f54bbc53a776584f265490e56c1 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 18 Dec 2016 03:35:16 -0800 Subject: [PATCH] peer: fix witness checking for inbound. --- lib/net/peer.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/net/peer.js b/lib/net/peer.js index 2e12a402..8ae197bf 100644 --- a/lib/net/peer.js +++ b/lib/net/peer.js @@ -1566,6 +1566,18 @@ Peer.prototype.handleVersion = co(function* handleVersion(version) { throw new Error('Peer does not support required protocol version.'); } + if (this.options.witness) { + this.haveWitness = version.hasWitness(); + if (!this.haveWitness && this.network.oldWitness) { + try { + yield this.request('havewitness'); + this.haveWitness = true; + } catch (err) { + ; + } + } + } + if (this.outbound) { if (!version.hasNetwork()) { this.ignore(); @@ -1587,22 +1599,9 @@ Peer.prototype.handleVersion = co(function* handleVersion(version) { } if (this.options.witness) { - this.haveWitness = version.hasWitness(); - if (!this.haveWitness) { - if (!this.network.oldWitness) { - this.ignore(); - throw new Error('Peer does not support segregated witness.'); - } - - try { - yield this.request('havewitness'); - } catch (err) { - this.ignore(); - throw new Error('Peer does not support segregated witness.'); - } - - this.haveWitness = true; + this.ignore(); + throw new Error('Peer does not support segregated witness.'); } } }