diff --git a/lib/net/peer.js b/lib/net/peer.js index 1f5ca591..cc1b7a37 100644 --- a/lib/net/peer.js +++ b/lib/net/peer.js @@ -2124,7 +2124,9 @@ Peer.prototype._handleUnknown = function _handleUnknown(packet) { */ Peer.prototype._handleSendCmpct = function _handleSendCmpct(packet) { - if (packet.version > 2) { + var max = this.options.witness ? 2 : 1; + + if (packet.version > max) { // Ignore this.logger.info('Peer request compact blocks version %d (%s).', packet.version, this.hostname); @@ -2137,6 +2139,13 @@ Peer.prototype._handleSendCmpct = function _handleSendCmpct(packet) { return; } + // Core witness nodes send this twice + // with both version 1 and 2 (why + // would you even _want_ non-witness + // blocks if you use segwit??). + if (this.compactMode) + return; + this.logger.info('Peer initialized compact blocks (%s).', this.hostname); this.compactMode = packet;