mirror of
https://github.com/bisq-network/bisq-api-reference.git
synced 2026-05-20 12:24:14 +00:00
Treat some wallet-is-locked errors as trivial
This commit is contained in:
parent
897401ba0e
commit
9307c08d4d
@ -345,6 +345,19 @@ public abstract class AbstractBot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if gRPC StatusRuntimeException indicates wallet is locked. Sometimes this is a trivial error.
|
||||||
|
*
|
||||||
|
* @param grpcException a StatusRuntimeException
|
||||||
|
* @return true if gRPC StatusRuntimeException indicates wallet is locked
|
||||||
|
*/
|
||||||
|
protected boolean walletIsLocked(StatusRuntimeException grpcException) {
|
||||||
|
var errorMsg = toCleanErrorMessage.apply(grpcException).toLowerCase();
|
||||||
|
return (exceptionHasStatus.test(grpcException, FAILED_PRECONDITION)
|
||||||
|
&& errorMsg.contains("wallet")
|
||||||
|
&& errorMsg.contains("locked"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to unlock the wallet for 1 second using the given password, and shut down the bot if the
|
* Attempt to unlock the wallet for 1 second using the given password, and shut down the bot if the
|
||||||
* password check fails for any reason.
|
* password check fails for any reason.
|
||||||
@ -575,6 +588,22 @@ public abstract class AbstractBot {
|
|||||||
BotUtils.printTradesSummary(category, trades);
|
BotUtils.printTradesSummary(category, trades);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print the completed trades since midnight today, if the wallet is unlocked, else log an error message.
|
||||||
|
*/
|
||||||
|
protected void printTradesSummaryForTodayIfWalletIsUnlocked() {
|
||||||
|
try {
|
||||||
|
log.info("Here are today's completed trades:");
|
||||||
|
printTradesSummaryForToday(CLOSED);
|
||||||
|
} catch (StatusRuntimeException grpcException) {
|
||||||
|
if (walletIsLocked(grpcException)) {
|
||||||
|
log.error("Cannot retrieve trades while API daemon's wallet is locked.");
|
||||||
|
} else {
|
||||||
|
throw grpcException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print list of today's trade summaries to stdout.
|
* Print list of today's trade summaries to stdout.
|
||||||
*
|
*
|
||||||
@ -813,9 +842,7 @@ public abstract class AbstractBot {
|
|||||||
* @param maxTakeOffers the max number of offers that can be taken during bot run
|
* @param maxTakeOffers the max number of offers that can be taken during bot run
|
||||||
*/
|
*/
|
||||||
protected void maybeShutdownAfterSuccessfulTradeCreation(int numOffersTaken, int maxTakeOffers) {
|
protected void maybeShutdownAfterSuccessfulTradeCreation(int numOffersTaken, int maxTakeOffers) {
|
||||||
log.info("Here are today's completed trades:");
|
printTradesSummaryForTodayIfWalletIsUnlocked();
|
||||||
printTradesSummaryForToday(CLOSED);
|
|
||||||
|
|
||||||
if (!isDryRun) {
|
if (!isDryRun) {
|
||||||
// If the bot is not in dryrun mode, lock the wallet. If dryrun=true, leave the wallet unlocked until the
|
// If the bot is not in dryrun mode, lock the wallet. If dryrun=true, leave the wallet unlocked until the
|
||||||
// timeout expires, so the user can look at data in the daemon with the CLI (a convenience in dev/test).
|
// timeout expires, so the user can look at data in the daemon with the CLI (a convenience in dev/test).
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user