Skip to content

Commit d25c78d

Browse files
committed
add and process finalized states for deposit txs and payout tx
1 parent 244a617 commit d25c78d

28 files changed

+197
-41
lines changed

core/src/main/java/haveno/core/api/model/TradeInfo.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public class TradeInfo implements Payload {
9696
private final boolean isPayoutPublished;
9797
private final boolean isPayoutConfirmed;
9898
private final boolean isPayoutUnlocked;
99+
private final boolean isPayoutFinalized;
99100
private final boolean isCompleted;
100101
private final String contractAsJson;
101102
private final ContractInfo contract;
@@ -140,6 +141,7 @@ public TradeInfo(TradeInfoV1Builder builder) {
140141
this.isPayoutPublished = builder.isPayoutPublished();
141142
this.isPayoutConfirmed = builder.isPayoutConfirmed();
142143
this.isPayoutUnlocked = builder.isPayoutUnlocked();
144+
this.isPayoutFinalized = builder.isPayoutFinalized();
143145
this.isCompleted = builder.isCompleted();
144146
this.contractAsJson = builder.getContractAsJson();
145147
this.contract = builder.getContract();
@@ -204,6 +206,7 @@ public static TradeInfo toTradeInfo(Trade trade) {
204206
.withIsPayoutPublished(trade.isPayoutPublished())
205207
.withIsPayoutConfirmed(trade.isPayoutConfirmed())
206208
.withIsPayoutUnlocked(trade.isPayoutUnlocked())
209+
.withIsPayoutFinalized(trade.isPayoutFinalized())
207210
.withIsCompleted(trade.isCompleted())
208211
.withContractAsJson(trade.getContractAsJson())
209212
.withContract(contractInfo)
@@ -258,6 +261,7 @@ public haveno.proto.grpc.TradeInfo toProtoMessage() {
258261
.setIsPayoutPublished(isPayoutPublished)
259262
.setIsPayoutConfirmed(isPayoutConfirmed)
260263
.setIsPayoutUnlocked(isPayoutUnlocked)
264+
.setIsPayoutFinalized(isPayoutFinalized)
261265
.setContractAsJson(contractAsJson == null ? "" : contractAsJson)
262266
.setContract(contract.toProtoMessage())
263267
.setStartTime(startTime)
@@ -305,6 +309,7 @@ public static TradeInfo fromProto(haveno.proto.grpc.TradeInfo proto) {
305309
.withIsPayoutPublished(proto.getIsPayoutPublished())
306310
.withIsPayoutConfirmed(proto.getIsPayoutConfirmed())
307311
.withIsPayoutUnlocked(proto.getIsPayoutUnlocked())
312+
.withIsPayoutFinalized(proto.getIsPayoutFinalized())
308313
.withContractAsJson(proto.getContractAsJson())
309314
.withContract((ContractInfo.fromProto(proto.getContract())))
310315
.withStartTime(proto.getStartTime())
@@ -350,6 +355,7 @@ public String toString() {
350355
", isPayoutPublished=" + isPayoutPublished + "\n" +
351356
", isPayoutConfirmed=" + isPayoutConfirmed + "\n" +
352357
", isPayoutUnlocked=" + isPayoutUnlocked + "\n" +
358+
", isPayoutFinalized=" + isPayoutFinalized + "\n" +
353359
", isCompleted=" + isCompleted + "\n" +
354360
", offer=" + offer + "\n" +
355361
", contractAsJson=" + contractAsJson + "\n" +

core/src/main/java/haveno/core/api/model/builder/TradeInfoV1Builder.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public final class TradeInfoV1Builder {
6969
private boolean isPayoutPublished;
7070
private boolean isPayoutConfirmed;
7171
private boolean isPayoutUnlocked;
72+
private boolean isPayoutFinalized;
7273
private boolean isCompleted;
7374
private String contractAsJson;
7475
private ContractInfo contract;
@@ -267,6 +268,11 @@ public TradeInfoV1Builder withIsPayoutUnlocked(boolean isPayoutUnlocked) {
267268
return this;
268269
}
269270

271+
public TradeInfoV1Builder withIsPayoutFinalized(boolean isPayoutFinalized) {
272+
this.isPayoutFinalized = isPayoutFinalized;
273+
return this;
274+
}
275+
270276
public TradeInfoV1Builder withIsCompleted(boolean isCompleted) {
271277
this.isCompleted = isCompleted;
272278
return this;

core/src/main/java/haveno/core/notifications/alerts/TradeEvents.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ private void setTradePhaseListener(Trade trade) {
7070
case DEPOSITS_PUBLISHED:
7171
break;
7272
case DEPOSITS_UNLOCKED:
73+
case DEPOSITS_FINALIZED:
7374
if (trade.getContract() != null && pubKeyRingProvider.get().equals(trade.getContract().getBuyerPubKeyRing()))
7475
msg = Res.get("account.notifications.trade.message.msg.conf", shortId);
7576
break;

core/src/main/java/haveno/core/trade/Trade.java

Lines changed: 91 additions & 28 deletions
Large diffs are not rendered by default.

core/src/main/java/haveno/core/trade/protocol/BuyerProtocol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public void onPaymentSent(ResultHandler resultHandler, ErrorMessageHandler error
126126
this.errorMessageHandler = errorMessageHandler;
127127
BuyerEvent event = BuyerEvent.PAYMENT_SENT;
128128
try {
129-
expect(anyPhase(Trade.Phase.DEPOSITS_UNLOCKED, Trade.Phase.PAYMENT_SENT)
129+
expect(anyPhase(Trade.Phase.DEPOSITS_UNLOCKED, Trade.Phase.DEPOSITS_FINALIZED, Trade.Phase.PAYMENT_SENT)
130130
.with(event)
131131
.preCondition(trade.confirmPermitted()))
132132
.setup(tasks(ApplyFilter.class,

core/src/main/java/haveno/core/trade/protocol/DisputeProtocol.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ protected void onMailboxMessage(TradeMessage message, NodeAddress peer) {
8080
// Trader has not yet received the peer's signature but has clicked the accept button.
8181
public void onAcceptMediationResult(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
8282
DisputeEvent event = DisputeEvent.MEDIATION_RESULT_ACCEPTED;
83-
expect(anyPhase(Trade.Phase.DEPOSITS_UNLOCKED,
83+
expect(anyPhase(
84+
Trade.Phase.DEPOSITS_UNLOCKED,
85+
Trade.Phase.DEPOSITS_FINALIZED,
8486
Trade.Phase.PAYMENT_SENT,
8587
Trade.Phase.PAYMENT_RECEIVED)
8688
.with(event)
@@ -107,7 +109,9 @@ public void onAcceptMediationResult(ResultHandler resultHandler, ErrorMessageHan
107109
// Trader has already received the peer's signature and has clicked the accept button as well.
108110
public void onFinalizeMediationResultPayout(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
109111
DisputeEvent event = DisputeEvent.MEDIATION_RESULT_ACCEPTED;
110-
expect(anyPhase(Trade.Phase.DEPOSITS_UNLOCKED,
112+
expect(anyPhase(
113+
Trade.Phase.DEPOSITS_UNLOCKED,
114+
Trade.Phase.DEPOSITS_FINALIZED,
111115
Trade.Phase.PAYMENT_SENT,
112116
Trade.Phase.PAYMENT_RECEIVED)
113117
.with(event)
@@ -135,7 +139,9 @@ public void onFinalizeMediationResultPayout(ResultHandler resultHandler, ErrorMe
135139
///////////////////////////////////////////////////////////////////////////////////////////
136140

137141
protected void handle(MediatedPayoutTxSignatureMessage message, NodeAddress peer) {
138-
expect(anyPhase(Trade.Phase.DEPOSITS_UNLOCKED,
142+
expect(anyPhase(
143+
Trade.Phase.DEPOSITS_UNLOCKED,
144+
Trade.Phase.DEPOSITS_FINALIZED,
139145
Trade.Phase.PAYMENT_SENT,
140146
Trade.Phase.PAYMENT_RECEIVED)
141147
.with(message)
@@ -145,7 +151,9 @@ protected void handle(MediatedPayoutTxSignatureMessage message, NodeAddress peer
145151
}
146152

147153
protected void handle(MediatedPayoutTxPublishedMessage message, NodeAddress peer) {
148-
expect(anyPhase(Trade.Phase.DEPOSITS_UNLOCKED,
154+
expect(anyPhase(
155+
Trade.Phase.DEPOSITS_UNLOCKED,
156+
Trade.Phase.DEPOSITS_FINALIZED,
149157
Trade.Phase.PAYMENT_SENT,
150158
Trade.Phase.PAYMENT_RECEIVED)
151159
.with(message)

core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ public synchronized void resetAddressEntriesForOpenOffer(String offerId) {
10771077
// swap trade payout to available if applicable
10781078
if (tradeManager == null) return;
10791079
Trade trade = tradeManager.getTrade(offerId);
1080-
if (trade == null || trade.isPayoutUnlocked()) swapAddressEntryToAvailable(offerId, XmrAddressEntry.Context.TRADE_PAYOUT);
1080+
if (trade == null || trade.isPayoutFinalized()) swapAddressEntryToAvailable(offerId, XmrAddressEntry.Context.TRADE_PAYOUT);
10811081
}
10821082

10831083
public synchronized void swapPayoutAddressEntryToAvailable(String offerId) {
@@ -1221,7 +1221,7 @@ public Stream<XmrAddressEntry> getAddressEntriesForAvailableBalanceStream() {
12211221
Stream<XmrAddressEntry> available = getFundedAvailableAddressEntries().stream();
12221222
available = Stream.concat(available, getAddressEntries(XmrAddressEntry.Context.ARBITRATOR).stream());
12231223
available = Stream.concat(available, getAddressEntries(XmrAddressEntry.Context.OFFER_FUNDING).stream().filter(entry -> !tradeManager.getOpenOfferManager().getOpenOffer(entry.getOfferId()).isPresent()));
1224-
available = Stream.concat(available, getAddressEntries(XmrAddressEntry.Context.TRADE_PAYOUT).stream().filter(entry -> tradeManager.getTrade(entry.getOfferId()) == null || tradeManager.getTrade(entry.getOfferId()).isPayoutUnlocked()));
1224+
available = Stream.concat(available, getAddressEntries(XmrAddressEntry.Context.TRADE_PAYOUT).stream().filter(entry -> tradeManager.getTrade(entry.getOfferId()) == null || tradeManager.getTrade(entry.getOfferId()).isPayoutFinalized()));
12251225
return available.filter(addressEntry -> getBalanceForSubaddress(addressEntry.getSubaddressIndex()).compareTo(BigInteger.ZERO) > 0);
12261226
}
12271227

core/src/main/resources/i18n/displayStrings.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ portfolio.pending.unconfirmedTooLong=Deposit transactions on trade {0} are still
660660
If the problem persists, contact Haveno support [HYPERLINK:https://matrix.to/#/#haveno:monero.social].
661661

662662
portfolio.pending.step1.waitForConf=Wait for blockchain confirmations
663+
portfolio.pending.step2_buyer.additionalConf=Deposits have reached 10 confirmations.\nFor extra security, we recommend waiting {0} confirmations before sending payment.\nProceed early at your own risk.
663664
portfolio.pending.step2_buyer.startPayment=Start payment
664665
portfolio.pending.step2_seller.waitPaymentSent=Wait until payment has been sent
665666
portfolio.pending.step3_buyer.waitPaymentArrived=Wait until payment arrived
@@ -2337,6 +2338,7 @@ notification.ticket.headline=Support ticket for trade with ID {0}
23372338
notification.trade.completed=The trade is now completed, and you can withdraw your funds.
23382339
notification.trade.accepted=Your offer has been accepted by a XMR {0}.
23392340
notification.trade.unlocked=Your trade has been confirmed.\nYou can start the payment now.
2341+
notification.trade.finalized=The trade has {0} confirmations.\nYou can start the payment now.
23402342
notification.trade.paymentSent=The XMR buyer has sent the payment.
23412343
notification.trade.selectTrade=Select trade
23422344
notification.trade.peerOpenedDispute=Your trading peer has opened a {0}.

core/src/main/resources/i18n/displayStrings_cs.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ portfolio.pending.unconfirmedTooLong=Vkladové transakce obchodu {0} jsou stále
625625
Pokud problém přetrvává, kontaktujte podporu Haveno [HYPERLINK:https://matrix.to/#/#haveno:monero.social].
626626

627627
portfolio.pending.step1.waitForConf=Počkejte na potvrzení na blockchainu
628+
portfolio.pending.step2_buyer.additionalConf=Vklady dosáhly 10 potvrzení.\nPro vyšší bezpečnost doporučujeme počkat na {0} potvrzení před odesláním platby.\nPokračujte dříve na vlastní riziko.
628629
portfolio.pending.step2_buyer.startPayment=Zahajte platbu
629630
portfolio.pending.step2_seller.waitPaymentSent=Počkejte, než začne platba
630631
portfolio.pending.step3_buyer.waitPaymentArrived=Počkejte, než dorazí platba

core/src/main/resources/i18n/displayStrings_de.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ portfolio.closedTrades.deviation.help=Prozentuale Preisabweichung vom Markt
577577
portfolio.pending.invalidTx=There is an issue with a missing or invalid transaction.\n\nPlease do NOT send the traditional or crypto payment.\n\nOpen a support ticket to get assistance from a Mediator.\n\nError message: {0}
578578

579579
portfolio.pending.step1.waitForConf=Auf Blockchain-Bestätigung warten
580+
portfolio.pending.step2_buyer.additionalConf=Einzahlungen haben 10 Bestätigungen erreicht.\nFür zusätzliche Sicherheit empfehlen wir, {0} Bestätigungen abzuwarten, bevor Sie die Zahlung senden.\nEin früheres Vorgehen erfolgt auf eigenes Risiko.
580581
portfolio.pending.step2_buyer.startPayment=Zahlung beginnen
581582
portfolio.pending.step2_seller.waitPaymentSent=Auf Zahlungsbeginn warten
582583
portfolio.pending.step3_buyer.waitPaymentArrived=Auf Zahlungseingang warten

0 commit comments

Comments
 (0)