mirror of
https://github.com/boldsuck/haveno.git
synced 2024-12-23 12:39:23 +00:00
arbitrator can resolve their disputes after unregistered
This commit is contained in:
parent
a35f38b76d
commit
8460346feb
2 changed files with 29 additions and 12 deletions
|
@ -18,6 +18,7 @@
|
||||||
package haveno.core.support.dispute;
|
package haveno.core.support.dispute;
|
||||||
|
|
||||||
import haveno.common.crypto.Hash;
|
import haveno.common.crypto.Hash;
|
||||||
|
import haveno.common.crypto.PubKeyRing;
|
||||||
import haveno.common.util.Utilities;
|
import haveno.common.util.Utilities;
|
||||||
import haveno.core.locale.Res;
|
import haveno.core.locale.Res;
|
||||||
import haveno.core.support.dispute.agent.DisputeAgent;
|
import haveno.core.support.dispute.agent.DisputeAgent;
|
||||||
|
@ -59,20 +60,35 @@ public class DisputeSummaryVerification {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void verifySignature(String input,
|
public static void verifySignature(String input,
|
||||||
ArbitratorManager arbitratorMediator) {
|
ArbitratorManager arbitratorManager) {
|
||||||
|
// get dispute agent
|
||||||
|
DisputeAgent disputeAgent = null;
|
||||||
try {
|
try {
|
||||||
String[] parts = input.split(SEPARATOR1);
|
String[] parts = input.split(SEPARATOR1);
|
||||||
String textToSign = parts[0];
|
String textToSign = parts[0];
|
||||||
String fullAddress = textToSign.split("\n")[1].split(": ")[1];
|
String fullAddress = textToSign.split("\n")[1].split(": ")[1];
|
||||||
NodeAddress nodeAddress = new NodeAddress(fullAddress);
|
NodeAddress nodeAddress = new NodeAddress(fullAddress);
|
||||||
DisputeAgent disputeAgent = arbitratorMediator.getDisputeAgentByNodeAddress(nodeAddress).orElse(null);
|
disputeAgent = arbitratorManager.getDisputeAgentByNodeAddress(nodeAddress).orElse(null);
|
||||||
checkNotNull(disputeAgent, "Dispute agent is 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];
|
String sigString = parts[1].split(SEPARATOR2)[0];
|
||||||
byte[] sig = Utilities.decodeFromHex(sigString);
|
byte[] sig = Utilities.decodeFromHex(sigString);
|
||||||
byte[] hash = Hash.getSha256Hash(textToSign);
|
byte[] hash = Hash.getSha256Hash(textToSign);
|
||||||
try {
|
try {
|
||||||
HavenoUtils.verifySignature(disputeAgent.getPubKeyRing(), hash, sig);
|
HavenoUtils.verifySignature(agentPubKeyRing, hash, sig);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalArgumentException(Res.get("support.sigCheck.popup.failed"));
|
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());
|
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
|
// get dispute
|
||||||
Optional<Dispute> disputeOptional = findDispute(disputeResult);
|
Optional<Dispute> disputeOptional = findDispute(disputeResult);
|
||||||
String uid = disputeClosedMessage.getUid();
|
String uid = disputeClosedMessage.getUid();
|
||||||
|
@ -225,7 +217,16 @@ public final class ArbitrationManager extends DisputeManager<ArbitrationDisputeL
|
||||||
}
|
}
|
||||||
dispute = disputeOptional.get();
|
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())) {
|
if (keyRing.getPubKeyRing().equals(dispute.getAgentPubKeyRing())) {
|
||||||
log.error("Arbitrator received disputeResultMessage. That should never happen.");
|
log.error("Arbitrator received disputeResultMessage. That should never happen.");
|
||||||
trade.getProcessModel().setDisputeClosedMessage(null); // don't reprocess
|
trade.getProcessModel().setDisputeClosedMessage(null); // don't reprocess
|
||||||
|
|
Loading…
Reference in a new issue