fix npe cleaning up arbitrator's mailbox messages

This commit is contained in:
woodser 2024-01-12 21:27:18 -05:00
parent ad77912171
commit 022028bb41
2 changed files with 2 additions and 12 deletions

View File

@ -17,7 +17,6 @@
package haveno.core.trade; package haveno.core.trade;
import haveno.common.crypto.PubKeyRing;
import haveno.common.proto.network.NetworkEnvelope; import haveno.common.proto.network.NetworkEnvelope;
import haveno.core.trade.messages.TradeMessage; import haveno.core.trade.messages.TradeMessage;
import haveno.network.p2p.AckMessage; import haveno.network.p2p.AckMessage;
@ -116,15 +115,6 @@ public class CleanupMailboxMessagesService {
} }
private boolean isPubKeyValid(DecryptedMessageWithPubKey decryptedMessageWithPubKey, Trade trade) { 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 return trade.getProtocol().isPubKeyValid(decryptedMessageWithPubKey);
// 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;
} }
} }

View File

@ -776,7 +776,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
return peer.getPubKeyRing(); return peer.getPubKeyRing();
} }
private boolean isPubKeyValid(DecryptedMessageWithPubKey message) { public boolean isPubKeyValid(DecryptedMessageWithPubKey message) {
if (this instanceof ArbitratorProtocol) { if (this instanceof ArbitratorProtocol) {
// valid if traders unknown // valid if traders unknown