arbitrator can resolve their disputes after unregistered
This commit is contained in:
parent
a35f38b76d
commit
8460346feb
@ -18,6 +18,7 @@
|
||||
package haveno.core.support.dispute;
|
||||
|
||||
import haveno.common.crypto.Hash;
|
||||
import haveno.common.crypto.PubKeyRing;
|
||||
import haveno.common.util.Utilities;
|
||||
import haveno.core.locale.Res;
|
||||
import haveno.core.support.dispute.agent.DisputeAgent;
|
||||
@ -59,20 +60,35 @@ public class DisputeSummaryVerification {
|
||||
}
|
||||
|
||||
public static void verifySignature(String input,
|
||||
ArbitratorManager arbitratorMediator) {
|
||||
ArbitratorManager arbitratorManager) {
|
||||
// get dispute agent
|
||||
DisputeAgent disputeAgent = null;
|
||||
try {
|
||||
String[] parts = input.split(SEPARATOR1);
|
||||
String textToSign = parts[0];
|
||||
String fullAddress = textToSign.split("\n")[1].split(": ")[1];
|
||||
NodeAddress nodeAddress = new NodeAddress(fullAddress);
|
||||
DisputeAgent disputeAgent = arbitratorMediator.getDisputeAgentByNodeAddress(nodeAddress).orElse(null);
|
||||
disputeAgent = arbitratorManager.getDisputeAgentByNodeAddress(nodeAddress).orElse(null);
|
||||
checkNotNull(disputeAgent, "Dispute agent is null");
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new IllegalArgumentException(Res.get("support.sigCheck.popup.invalidFormat"));
|
||||
}
|
||||
|
||||
// verify signature with pub key ring
|
||||
verifySignature(input, disputeAgent.getPubKeyRing());
|
||||
}
|
||||
|
||||
public static void verifySignature(String input,
|
||||
PubKeyRing agentPubKeyRing) {
|
||||
try {
|
||||
String[] parts = input.split(SEPARATOR1);
|
||||
String textToSign = parts[0];
|
||||
String sigString = parts[1].split(SEPARATOR2)[0];
|
||||
byte[] sig = Utilities.decodeFromHex(sigString);
|
||||
byte[] hash = Hash.getSha256Hash(textToSign);
|
||||
try {
|
||||
HavenoUtils.verifySignature(disputeAgent.getPubKeyRing(), hash, sig);
|
||||
HavenoUtils.verifySignature(agentPubKeyRing, hash, sig);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException(Res.get("support.sigCheck.popup.failed"));
|
||||
}
|
||||
|
@ -198,14 +198,6 @@ public final class ArbitrationManager extends DisputeManager<ArbitrationDisputeL
|
||||
|
||||
log.info("Processing {} for {} {}", disputeClosedMessage.getClass().getSimpleName(), trade.getClass().getSimpleName(), disputeResult.getTradeId());
|
||||
|
||||
// verify arbitrator signature
|
||||
String summaryText = chatMessage.getMessage();
|
||||
DisputeSummaryVerification.verifySignature(summaryText, arbitratorManager);
|
||||
|
||||
// save dispute closed message for reprocessing
|
||||
trade.getProcessModel().setDisputeClosedMessage(disputeClosedMessage);
|
||||
requestPersistence();
|
||||
|
||||
// get dispute
|
||||
Optional<Dispute> disputeOptional = findDispute(disputeResult);
|
||||
String uid = disputeClosedMessage.getUid();
|
||||
@ -225,7 +217,16 @@ public final class ArbitrationManager extends DisputeManager<ArbitrationDisputeL
|
||||
}
|
||||
dispute = disputeOptional.get();
|
||||
|
||||
// verify that arbitrator does not get DisputeClosedMessage
|
||||
// verify arbitrator signature
|
||||
String summaryText = chatMessage.getMessage();
|
||||
if (dispute != null) DisputeSummaryVerification.verifySignature(summaryText, dispute.getAgentPubKeyRing()); // use dispute's arbitrator pub key ring
|
||||
else DisputeSummaryVerification.verifySignature(summaryText, arbitratorManager); // verify using registered arbitrator (will fail is arbitrator is unregistered)
|
||||
|
||||
// save dispute closed message for reprocessing
|
||||
trade.getProcessModel().setDisputeClosedMessage(disputeClosedMessage);
|
||||
requestPersistence();
|
||||
|
||||
// verify arbitrator does not receive DisputeClosedMessage
|
||||
if (keyRing.getPubKeyRing().equals(dispute.getAgentPubKeyRing())) {
|
||||
log.error("Arbitrator received disputeResultMessage. That should never happen.");
|
||||
trade.getProcessModel().setDisputeClosedMessage(null); // don't reprocess
|
||||
|
Loading…
Reference in New Issue
Block a user