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.'); } } }