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 handling of mediationResultState to isFundsLockedIn #3726

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
37 changes: 31 additions & 6 deletions core/src/main/java/bisq/core/trade/Trade.java
Original file line number Diff line number Diff line change
Expand Up @@ -911,12 +911,37 @@ public boolean isDepositPublished() {
}

public boolean isFundsLockedIn() {
return isDepositPublished() &&
!isPayoutPublished() &&
disputeState != DisputeState.DISPUTE_CLOSED &&
disputeState != DisputeState.REFUND_REQUESTED &&
disputeState != DisputeState.REFUND_REQUEST_STARTED_BY_PEER &&
disputeState != DisputeState.REFUND_REQUEST_CLOSED;
// If no deposit tx was published we have no funds locked in
if (!isDepositPublished()) {
return false;
}

// If we have the payout tx published (non disputed case) we have no funds locked in. Here we might have more
// complex cases where users open a mediation but continue the trade to finalize it without mediated payout.
// The trade state handles that but does not handle mediated payouts or refund agents payouts.
if (isPayoutPublished()) {
return false;
}

// Legacy arbitration is not handled anymore as not used anymore.

// In mediation case we check for the mediationResultState. As there are multiple sub-states we use ordinal.
if (disputeState == DisputeState.MEDIATION_CLOSED) {
if (mediationResultState != null &&
mediationResultState.ordinal() >= MediationResultState.PAYOUT_TX_PUBLISHED.ordinal()) {
return false;
}
}

// In refund agent case the funds are spent anyway with the time locked payout. We do not consider that as
// locked in funds.
if (disputeState == DisputeState.REFUND_REQUESTED ||
disputeState == DisputeState.REFUND_REQUEST_STARTED_BY_PEER ||
disputeState == DisputeState.REFUND_REQUEST_CLOSED) {
return false;
}

return true;
}

public boolean isDepositConfirmed() {
Expand Down