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

Allow user to initiate arbitration once locktime has expired #5681

Merged
merged 1 commit into from Sep 6, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,13 @@ private void doOpenDispute(boolean isSupportTicket, Transaction depositTx) {
}
Trade.DisputeState disputeState = trade.getDisputeState();
DisputeManager<? extends DisputeList<Dispute>> disputeManager;
boolean useMediation;
boolean useRefundAgent;
long remainingLockTime = trade.getDelayedPayoutTx().getLockTime() - btcWalletService.getBestChainHeight();
// In case we re-open a dispute we allow Trade.DisputeState.MEDIATION_REQUESTED
useMediation = disputeState == Trade.DisputeState.NO_DISPUTE || disputeState == Trade.DisputeState.MEDIATION_REQUESTED;
boolean useMediation = disputeState == Trade.DisputeState.NO_DISPUTE ||
(disputeState == Trade.DisputeState.MEDIATION_REQUESTED && remainingLockTime > 0);
// In case we re-open a dispute we allow Trade.DisputeState.REFUND_REQUESTED
useRefundAgent = disputeState == Trade.DisputeState.MEDIATION_CLOSED || disputeState == Trade.DisputeState.REFUND_REQUESTED;
boolean useRefundAgent = disputeState == Trade.DisputeState.MEDIATION_CLOSED ||
disputeState == Trade.DisputeState.REFUND_REQUESTED || remainingLockTime <= 0;

AtomicReference<String> donationAddressString = new AtomicReference<>("");
Transaction delayedPayoutTx = trade.getDelayedPayoutTx();
Expand Down Expand Up @@ -579,12 +580,9 @@ private void doOpenDispute(boolean isSupportTicket, Transaction depositTx) {
return;
}

long lockTime = delayedPayoutTx.getLockTime();
int bestChainHeight = btcWalletService.getBestChainHeight();
long remaining = lockTime - bestChainHeight;
if (remaining > 0) {
if (remainingLockTime > 0) {
new Popup().instruction(Res.get("portfolio.pending.timeLockNotOver",
FormattingUtils.getDateFromBlockHeight(remaining), remaining))
FormattingUtils.getDateFromBlockHeight(remainingLockTime), remainingLockTime))
.show();
return;
}
Expand Down Expand Up @@ -621,7 +619,7 @@ private void doOpenDispute(boolean isSupportTicket, Transaction depositTx) {
mediationManager.findDispute(tradeId)
.ifPresent(mediatorsDispute -> {
DisputeResult mediatorsDisputeResult = mediatorsDispute.getDisputeResultProperty().get();
ChatMessage mediatorsResultMessage = mediatorsDisputeResult.getChatMessage();
ChatMessage mediatorsResultMessage = mediatorsDisputeResult == null ? null : mediatorsDisputeResult.getChatMessage();
if (mediatorsResultMessage != null) {
String mediatorAddress = Res.get("support.mediatorsAddress",
mediatorsDispute.getContract().getRefundAgentNodeAddress().getFullAddress());
Expand Down