From 022028bb41911589ef5cbb6c4c0b05f8195e168d Mon Sep 17 00:00:00 2001 From: woodser Date: Fri, 12 Jan 2024 21:27:18 -0500 Subject: [PATCH] fix npe cleaning up arbitrator's mailbox messages --- .../core/trade/CleanupMailboxMessagesService.java | 12 +----------- .../haveno/core/trade/protocol/TradeProtocol.java | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/haveno/core/trade/CleanupMailboxMessagesService.java b/core/src/main/java/haveno/core/trade/CleanupMailboxMessagesService.java index eab604b6..a013e832 100644 --- a/core/src/main/java/haveno/core/trade/CleanupMailboxMessagesService.java +++ b/core/src/main/java/haveno/core/trade/CleanupMailboxMessagesService.java @@ -17,7 +17,6 @@ package haveno.core.trade; -import haveno.common.crypto.PubKeyRing; import haveno.common.proto.network.NetworkEnvelope; import haveno.core.trade.messages.TradeMessage; import haveno.network.p2p.AckMessage; @@ -116,15 +115,6 @@ public class CleanupMailboxMessagesService { } private boolean isPubKeyValid(DecryptedMessageWithPubKey decryptedMessageWithPubKey, Trade trade) { - // We can only validate the peers pubKey if we have it already. If we are the taker we get it from the offer - // Otherwise it depends on the state of the trade protocol if we have received the peers pubKeyRing already. - PubKeyRing peersPubKeyRing = trade.getTradePeer().getPubKeyRing(); - boolean isValid = true; - if (peersPubKeyRing != null && - !decryptedMessageWithPubKey.getSignaturePubKey().equals(peersPubKeyRing.getSignaturePubKey())) { - isValid = false; - log.warn("SignaturePubKey in decryptedMessageWithPubKey does not match the SignaturePubKey we have set for our trading peer."); - } - return isValid; + return trade.getProtocol().isPubKeyValid(decryptedMessageWithPubKey); } } diff --git a/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java b/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java index a0e11c91..0fe0320b 100644 --- a/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java @@ -776,7 +776,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D return peer.getPubKeyRing(); } - private boolean isPubKeyValid(DecryptedMessageWithPubKey message) { + public boolean isPubKeyValid(DecryptedMessageWithPubKey message) { if (this instanceof ArbitratorProtocol) { // valid if traders unknown