Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add penalty calculation to dispute agent UI #5834

Merged
merged 1 commit into from Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions core/src/main/java/bisq/core/support/dispute/DisputeResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ public enum Reason {
PEER_WAS_LATE
}

public enum PayoutSuggestion {
UNKNOWN,
BUYER_GETS_TRADE_AMOUNT,
BUYER_GETS_TRADE_AMOUNT_PLUS_COMPENSATION,
BUYER_GETS_TRADE_AMOUNT_MINUS_PENALTY,
SELLER_GETS_TRADE_AMOUNT,
SELLER_GETS_TRADE_AMOUNT_PLUS_COMPENSATION,
SELLER_GETS_TRADE_AMOUNT_MINUS_PENALTY,
CUSTOM_PAYOUT
}

private final String tradeId;
private final int traderId;
@Setter
Expand All @@ -91,6 +102,10 @@ public enum Reason {
private long closeDate;
@Setter
private boolean isLoserPublisher;
@Setter
private String payoutAdjustmentPercent = "";
@Setter
private PayoutSuggestion payoutSuggestion;

public DisputeResult(String tradeId, int traderId) {
this.tradeId = tradeId;
Expand All @@ -111,7 +126,9 @@ public DisputeResult(String tradeId,
long sellerPayoutAmount,
@Nullable byte[] arbitratorPubKey,
long closeDate,
boolean isLoserPublisher) {
boolean isLoserPublisher,
String payoutAdjustmentPercent,
PayoutSuggestion payoutSuggestion) {
this.tradeId = tradeId;
this.traderId = traderId;
this.winner = winner;
Expand All @@ -127,6 +144,8 @@ public DisputeResult(String tradeId,
this.arbitratorPubKey = arbitratorPubKey;
this.closeDate = closeDate;
this.isLoserPublisher = isLoserPublisher;
this.payoutAdjustmentPercent = payoutAdjustmentPercent;
this.payoutSuggestion = payoutSuggestion;
}


Expand All @@ -149,7 +168,9 @@ public static DisputeResult fromProto(protobuf.DisputeResult proto) {
proto.getSellerPayoutAmount(),
proto.getArbitratorPubKey().toByteArray(),
proto.getCloseDate(),
proto.getIsLoserPublisher());
proto.getIsLoserPublisher(),
proto.getPayoutAdjustmentPercent(),
ProtoUtil.enumFromProto(DisputeResult.PayoutSuggestion.class, proto.getPayoutSuggestion().name()));
}

@Override
Expand All @@ -165,13 +186,15 @@ public protobuf.DisputeResult toProtoMessage() {
.setBuyerPayoutAmount(buyerPayoutAmount)
.setSellerPayoutAmount(sellerPayoutAmount)
.setCloseDate(closeDate)
.setIsLoserPublisher(isLoserPublisher);
.setIsLoserPublisher(isLoserPublisher)
.setPayoutAdjustmentPercent(payoutAdjustmentPercent);

Optional.ofNullable(arbitratorSignature).ifPresent(arbitratorSignature -> builder.setArbitratorSignature(ByteString.copyFrom(arbitratorSignature)));
Optional.ofNullable(arbitratorPubKey).ifPresent(arbitratorPubKey -> builder.setArbitratorPubKey(ByteString.copyFrom(arbitratorPubKey)));
Optional.ofNullable(winner).ifPresent(result -> builder.setWinner(protobuf.DisputeResult.Winner.valueOf(winner.name())));
Optional.ofNullable(chatMessage).ifPresent(chatMessage ->
builder.setChatMessage(chatMessage.toProtoNetworkEnvelope().getChatMessage()));
Optional.ofNullable(payoutSuggestion).ifPresent(result -> builder.setPayoutSuggestion(protobuf.DisputeResult.PayoutSuggestion.valueOf(payoutSuggestion.name())));

return builder.build();
}
Expand Down Expand Up @@ -254,6 +277,8 @@ public String toString() {
",\n arbitratorPubKey=" + Utilities.bytesAsHexString(arbitratorPubKey) +
",\n closeDate=" + closeDate +
",\n isLoserPublisher=" + isLoserPublisher +
",\n payoutAdjustmentPercent=" + payoutAdjustmentPercent +
",\n payoutSuggestion=" + payoutSuggestion +
"\n}";
}
}
2 changes: 2 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2656,6 +2656,8 @@ disputeSummaryWindow.title=Summary
disputeSummaryWindow.openDate=Ticket opening date
disputeSummaryWindow.role=Trader's role
disputeSummaryWindow.payout=Trade amount payout
disputeSummaryWindow.payout.getsCompensation=BTC {0} gets trade amount plus compensation
disputeSummaryWindow.payout.getsPenalty=BTC {0} gets trade amount minus penalty
disputeSummaryWindow.payout.getsTradeAmount=BTC {0} gets trade amount payout
disputeSummaryWindow.payout.getsAll=Max. payout to BTC {0}
disputeSummaryWindow.payout.custom=Custom payout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import org.junit.Test;

import static bisq.core.payment.payload.PaymentMethod.getPaymentMethodById;
import static bisq.core.support.dispute.DisputeResult.PayoutSuggestion.UNKNOWN;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -213,7 +214,7 @@ public void testArbitratorSignWitness() {
0,
null,
now - 1,
false));
false, "", UNKNOWN));

// Filtermanager says nothing is filtered
when(filterManager.isNodeAddressBanned(any())).thenReturn(false);
Expand Down
Loading