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

ElementsDaemon: Create/Use legacy wallet #577

Merged
merged 1 commit into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,20 @@ public BitcoindDaemon(DaemonRpcClient rpcClient) {
}

public void createOrLoadWallet(String walletName, Optional<String> passphrase) {
createOrLoadWallet(walletName, passphrase, false, false);
createOrLoadWallet(walletName, passphrase, true, false, false);
}

public void createOrLoadLegacyWallet(String walletName, Optional<String> passphrase) {
createOrLoadWallet(walletName, passphrase, false, false, false);
}

public void createOrLoadWatchOnlyWallet(String walletName) {
createOrLoadWallet(walletName, Optional.empty(), true, true);
createOrLoadWallet(walletName, Optional.empty(), true, true, true);
}

private void createOrLoadWallet(String walletName, Optional<String> passphrase, boolean disablePrivateKeys, boolean blank) {
private void createOrLoadWallet(String walletName, Optional<String> passphrase, boolean descriptors, boolean disablePrivateKeys, boolean blank) {
try {
createWallet(walletName, passphrase.orElse(""), disablePrivateKeys, blank);
createWallet(walletName, passphrase.orElse(""), descriptors, disablePrivateKeys, blank);
} catch (RpcCallFailureException e) {
if (doesWalletExist(e)) {
List<String> loadedWallets = listWallets();
Expand Down Expand Up @@ -146,9 +150,10 @@ private boolean doesWalletExist(RpcCallFailureException e) {
return e.getCause().getMessage().contains("Database already exists.");
}

private void createWallet(String walletName, String passphrase, boolean disablePrivateKeys, boolean blank) {
private void createWallet(String walletName, String passphrase, boolean descriptors, boolean disablePrivateKeys, boolean blank) {
var request = BitcoindCreateWalletRpcCall.Request.builder()
.walletName(walletName)
.descriptors(descriptors)
.disablePrivateKeys(disablePrivateKeys)
.blank(blank)
.passphrase(passphrase)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static class Request {
private String passphrase;
@JsonProperty("avoid_reuse")
private Boolean avoidReuse;
private final boolean descriptors = true;
private boolean descriptors;
}

public BitcoindCreateWalletRpcCall(Request request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ElementsdDaemon(DaemonRpcClient rpcClient) {
}

public void createOrLoadWallet(String walletName, Optional<String> passphrase) {
bitcoindDaemon.createOrLoadWallet(walletName, passphrase);
bitcoindDaemon.createOrLoadLegacyWallet(walletName, passphrase);
}

public ElementsdDecodeRawTransactionResponse decodeRawTransaction(String txInHex) {
Expand Down