cormorant: set wallet to load on bitcoind startup, check if loaded first

This commit is contained in:
Craig Raw 2023-01-30 12:28:07 +02:00
parent f938506a3f
commit 9edeff9aab
2 changed files with 7 additions and 19 deletions

View file

@ -128,18 +128,11 @@ public class BitcoindClient {
legacyWalletExists = listWalletDirResult.wallets().stream().anyMatch(walletDirResult -> walletDirResult.name().equals(Bwt.DEFAULT_CORE_WALLET));
if(!exists) {
getBitcoindService().createWallet(CORE_WALLET_NAME, true, true, "", true, true, false, false);
getBitcoindService().createWallet(CORE_WALLET_NAME, true, true, "", true, true, true, false);
} else {
try {
getBitcoindService().loadWallet(CORE_WALLET_NAME, false);
} catch(JsonRpcException e) {
try {
getBitcoindService().unloadWallet(CORE_WALLET_NAME, false);
} catch(JsonRpcException ex) {
//ignore
}
getBitcoindService().loadWallet(CORE_WALLET_NAME, false);
List<String> wallets = getBitcoindService().listWallets();
if(!wallets.contains(CORE_WALLET_NAME)) {
getBitcoindService().loadWallet(CORE_WALLET_NAME, true);
}
}
@ -346,14 +339,6 @@ public class BitcoindClient {
}
public void stop() {
if(initialized) {
try {
getBitcoindService().unloadWallet(CORE_WALLET_NAME, false);
} catch(Exception e) {
log.info("Error unloading Core wallet " + CORE_WALLET_NAME, e);
}
}
timer.cancel();
stopped = true;
}

View file

@ -57,6 +57,9 @@ public interface BitcoindClientService {
@JsonRpcMethod("listwalletdir")
ListWalletDirResult listWalletDir();
@JsonRpcMethod("listwallets")
List<String> listWallets();
@JsonRpcMethod("createwallet")
CreateLoadWalletResult createWallet(@JsonRpcParam("wallet_name") String name, @JsonRpcParam("disable_private_keys") boolean disablePrivateKeys, @JsonRpcParam("blank") boolean blank,
@JsonRpcParam("passphrase") String passphrase, @JsonRpcParam("avoid_reuse") boolean avoidReuse, @JsonRpcParam("descriptors") boolean descriptors,