peer: fix witness checking for inbound.

This commit is contained in:
Christopher Jeffrey 2016-12-18 03:35:16 -08:00
parent 595ada8c86
commit 856957eee9
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

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