peer: fix witness checking for inbound.
This commit is contained in:
parent
595ada8c86
commit
856957eee9
@ -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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user