Add INVALID_SNAPSHOT_HEIGHT to AvailabilityResult.

Use AvailabilityResult.INVALID_SNAPSHOT_HEIGHT instead of AckMessage with error.
Show description in error popup instead of enum name.
Return PRICE_CHECK_FAILED instead of UNKNOWN_FAILURE at error at price check also for non api users.

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
HenrikJannsen 2022-12-18 13:13:36 -05:00 committed by Christoph Atteneder
parent 0b849800f9
commit 8eb555df8f
No known key found for this signature in database
GPG Key ID: CD5DC1C529CDFD3B
5 changed files with 38 additions and 41 deletions

View File

@ -673,22 +673,6 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
return;
}
if (BurningManService.isActivated()) {
try {
int takersBurningManSelectionHeight = request.getBurningManSelectionHeight();
checkArgument(takersBurningManSelectionHeight > 0, "takersBurningManSelectionHeight must not be 0");
int makersBurningManSelectionHeight = delayedPayoutTxReceiverService.getBurningManSelectionHeight();
checkArgument(takersBurningManSelectionHeight == makersBurningManSelectionHeight,
"takersBurningManSelectionHeight does no match makersBurningManSelectionHeight");
} catch (Throwable t) {
errorMessage = "Message validation failed. Error=" + t + ", Message=" + request;
log.warn(errorMessage);
sendAckMessage(request, peer, false, errorMessage);
return;
}
}
try {
Optional<OpenOffer> openOfferOptional = getOpenOfferById(request.offerId);
AvailabilityResult availabilityResult;
@ -721,11 +705,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
availabilityResult = AvailabilityResult.MARKET_PRICE_NOT_AVAILABLE;
} catch (Throwable e) {
log.warn("Trade price check failed. " + e.getMessage());
if (coreContext.isApiUser())
// Give api user something more than 'unknown_failure'.
availabilityResult = AvailabilityResult.PRICE_CHECK_FAILED;
else
availabilityResult = AvailabilityResult.UNKNOWN_FAILURE;
availabilityResult = AvailabilityResult.PRICE_CHECK_FAILED;
}
} else {
availabilityResult = AvailabilityResult.USER_IGNORED;
@ -747,6 +727,22 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
availabilityResult = AvailabilityResult.UNCONF_TX_LIMIT_HIT;
}
if (BurningManService.isActivated()) {
try {
int takersBurningManSelectionHeight = request.getBurningManSelectionHeight();
checkArgument(takersBurningManSelectionHeight > 0, "takersBurningManSelectionHeight must not be 0");
int makersBurningManSelectionHeight = delayedPayoutTxReceiverService.getBurningManSelectionHeight();
checkArgument(takersBurningManSelectionHeight == makersBurningManSelectionHeight,
"takersBurningManSelectionHeight does no match makersBurningManSelectionHeight. " +
"takersBurningManSelectionHeight=" + takersBurningManSelectionHeight + "; makersBurningManSelectionHeight=" + makersBurningManSelectionHeight);
} catch (Throwable t) {
errorMessage = "Message validation failed. Error=" + t + ", Message=" + request;
log.warn(errorMessage);
availabilityResult = AvailabilityResult.INVALID_SNAPSHOT_HEIGHT;
}
}
OfferAvailabilityResponse offerAvailabilityResponse = new OfferAvailabilityResponse(request.offerId,
availabilityResult,
arbitratorNodeAddress,

View File

@ -17,31 +17,31 @@
package bisq.core.offer.availability;
public enum AvailabilityResult {
UNKNOWN_FAILURE("cannot take offer for unknown reason"),
AVAILABLE("offer available"),
OFFER_TAKEN("offer taken"),
PRICE_OUT_OF_TOLERANCE("cannot take offer because taker's price is outside tolerance"),
MARKET_PRICE_NOT_AVAILABLE("cannot take offer because market price for calculating trade price is unavailable"),
@SuppressWarnings("unused") NO_ARBITRATORS("cannot take offer because no arbitrators are available"),
NO_MEDIATORS("cannot take offer because no mediators are available"),
USER_IGNORED("cannot take offer because user is ignored"),
@SuppressWarnings("unused") MISSING_MANDATORY_CAPABILITY("description not available"),
@SuppressWarnings("unused") NO_REFUND_AGENTS("cannot take offer because no refund agents are available"),
UNCONF_TX_LIMIT_HIT("cannot take offer because you have too many unconfirmed transactions at this moment"),
MAKER_DENIED_API_USER("cannot take offer because maker is api user"),
PRICE_CHECK_FAILED("cannot take offer because trade price check failed");
import lombok.Getter;
public enum AvailabilityResult {
UNKNOWN_FAILURE("Cannot take offer for unknown reason"),
AVAILABLE("Offer is available"),
OFFER_TAKEN("Offer is taken"),
PRICE_OUT_OF_TOLERANCE("Cannot take offer because taker's price is outside tolerance"),
MARKET_PRICE_NOT_AVAILABLE("Cannot take offer because market price for calculating trade price is unavailable"),
@SuppressWarnings("unused") NO_ARBITRATORS("Cannot take offer because no arbitrators are available"),
NO_MEDIATORS("Cannot take offer because no mediators are available"),
USER_IGNORED("Cannot take offer because user is ignored"),
@SuppressWarnings("unused") MISSING_MANDATORY_CAPABILITY("Missing mandatory capability"),
@SuppressWarnings("unused") NO_REFUND_AGENTS("Cannot take offer because no refund agents are available"),
UNCONF_TX_LIMIT_HIT("Cannot take offer because you have too many unconfirmed transactions at this moment"),
MAKER_DENIED_API_USER("Cannot take offer because maker is api user"),
PRICE_CHECK_FAILED("Cannot take offer because trade price check failed"),
INVALID_SNAPSHOT_HEIGHT("Cannot take offer because snapshot height does not match. Probably your DAO data are not synced.");
@Getter
private final String description;
AvailabilityResult(String description) {
this.description = description;
}
public String description() {
return description;
}
public static AvailabilityResult fromProto(protobuf.AvailabilityResult proto) {
return AvailabilityResult.valueOf(proto.name());
}

View File

@ -51,7 +51,7 @@ public class ProcessOfferAvailabilityResponse extends Task<OfferAvailabilityMode
if (offerAvailabilityResponse.getAvailabilityResult() != AvailabilityResult.AVAILABLE) {
offer.setState(Offer.State.NOT_AVAILABLE);
failed("Take offer attempt rejected because of: " + offerAvailabilityResponse.getAvailabilityResult());
failed(offerAvailabilityResponse.getAvailabilityResult().getDescription());
return;
}

View File

@ -134,7 +134,7 @@ public class GrpcErrorMessageHandler implements ErrorMessageHandler {
}
private String getAvailabilityResultDescription(AvailabilityResult proto) {
return bisq.core.offer.availability.AvailabilityResult.fromProto(proto).description();
return bisq.core.offer.availability.AvailabilityResult.fromProto(proto).getDescription();
}
private boolean takeOfferWasCalled() {

View File

@ -1053,6 +1053,7 @@ enum AvailabilityResult {
UNCONF_TX_LIMIT_HIT = 11;
MAKER_DENIED_API_USER = 12;
PRICE_CHECK_FAILED = 13;
INVALID_SNAPSHOT_HEIGHT = 14;
}
message PaymentAccountPayload {