mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
retain messages from rpc errors when loading wallets with bwt
This commit is contained in:
parent
8ddac9acba
commit
ff43db0842
1 changed files with 13 additions and 4 deletions
|
@ -29,6 +29,8 @@ import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.locks.Condition;
|
import java.util.concurrent.locks.Condition;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ElectrumServer {
|
public class ElectrumServer {
|
||||||
|
@ -46,6 +48,8 @@ public class ElectrumServer {
|
||||||
|
|
||||||
private static String bwtElectrumServer;
|
private static String bwtElectrumServer;
|
||||||
|
|
||||||
|
private static final Pattern RPC_WALLET_LOADING_PATTERN = Pattern.compile(".*\"(Wallet loading failed:[^\"]*)\".*");
|
||||||
|
|
||||||
private static synchronized Transport getTransport() throws ServerException {
|
private static synchronized Transport getTransport() throws ServerException {
|
||||||
if(transport == null) {
|
if(transport == null) {
|
||||||
try {
|
try {
|
||||||
|
@ -824,12 +828,17 @@ public class ElectrumServer {
|
||||||
bwtStartCondition.await();
|
bwtStartCondition.await();
|
||||||
|
|
||||||
if(!bwt.isReady()) {
|
if(!bwt.isReady()) {
|
||||||
if(bwtStartException != null && bwtStartException.getMessage().contains("Wallet file not specified")) {
|
if(bwtStartException != null) {
|
||||||
|
Matcher walletLoadingMatcher = RPC_WALLET_LOADING_PATTERN.matcher(bwtStartException.getMessage());
|
||||||
|
if(bwtStartException.getMessage().contains("Wallet file not specified")) {
|
||||||
throw new ServerException("Bitcoin Core requires Multi-Wallet to be enabled in the Server Preferences");
|
throw new ServerException("Bitcoin Core requires Multi-Wallet to be enabled in the Server Preferences");
|
||||||
} else {
|
} else if(walletLoadingMatcher.matches() && walletLoadingMatcher.group(1) != null) {
|
||||||
throw new ServerException("Check if Bitcoin Core is running, and the authentication details are correct.");
|
throw new ServerException(walletLoadingMatcher.group(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw new ServerException("Check if Bitcoin Core is running, and the authentication details are correct.");
|
||||||
|
}
|
||||||
} catch(InterruptedException e) {
|
} catch(InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue