diff --git a/p2p/src/main/java/bisq/network/p2p/P2PService.java b/p2p/src/main/java/bisq/network/p2p/P2PService.java index 76396125462..509419bf24d 100644 --- a/p2p/src/main/java/bisq/network/p2p/P2PService.java +++ b/p2p/src/main/java/bisq/network/p2p/P2PService.java @@ -419,6 +419,7 @@ public void onMessage(NetworkEnvelope networkEnvelope, Connection connection) { connection.setPeerType(Connection.PeerType.DIRECT_MSG_PEER); try { DecryptedMessageWithPubKey decryptedMsg = encryptionService.decryptAndVerify(sealedMsg.getSealedAndSigned()); + connection.maybeHandleSupportedCapabilitiesMessage(decryptedMsg.getNetworkEnvelope()); connection.getPeersNodeAddressOptional().ifPresentOrElse(nodeAddress -> decryptedDirectMessageListeners.forEach(e -> e.onDirectMessage(decryptedMsg, nodeAddress)), () -> { diff --git a/p2p/src/main/java/bisq/network/p2p/network/Connection.java b/p2p/src/main/java/bisq/network/p2p/network/Connection.java index dca03c133de..c6d3277ee35 100644 --- a/p2p/src/main/java/bisq/network/p2p/network/Connection.java +++ b/p2p/src/main/java/bisq/network/p2p/network/Connection.java @@ -785,11 +785,9 @@ && reportInvalidRequest(RuleViolation.WRONG_NETWORK_ID)) { return; } - if (networkEnvelope instanceof SupportedCapabilitiesMessage) { - boolean causedShutDown = handleSupportedCapabilitiesMessage(networkEnvelope); - if (causedShutDown) { - return; - } + boolean causedShutDown = maybeHandleSupportedCapabilitiesMessage(networkEnvelope); + if (causedShutDown) { + return; } if (networkEnvelope instanceof CloseConnectionMessage) { @@ -865,7 +863,11 @@ && reportInvalidRequest(RuleViolation.WRONG_NETWORK_ID)) { } } - protected boolean handleSupportedCapabilitiesMessage(NetworkEnvelope networkEnvelope) { + public boolean maybeHandleSupportedCapabilitiesMessage(NetworkEnvelope networkEnvelope) { + if (!(networkEnvelope instanceof SupportedCapabilitiesMessage)) { + return false; + } + Capabilities supportedCapabilities = ((SupportedCapabilitiesMessage) networkEnvelope).getSupportedCapabilities(); if (supportedCapabilities == null || supportedCapabilities.isEmpty()) { return false;