Skip to content

Commit

Permalink
Move WalletService into Bisq 2 specific code
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed Sep 20, 2024
1 parent 21e2b57 commit 0914966
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions apps/desktop/desktop-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dependencies {

implementation("network:network")
implementation("bitcoind:core")
implementation("wallets:wallet")
// implementation("wallets:electrum")
// implementation("wallets:bitcoind")

Expand Down
1 change: 1 addition & 0 deletions apps/desktop/desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies {
implementation("network:network-identity")

implementation("bitcoind:core")
implementation("wallets:wallet")
// implementation("wallets:electrum")
// implementation("wallets:bitcoind")

Expand Down
1 change: 1 addition & 0 deletions apps/rest-api-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies {
implementation("network:network-common")
implementation("network:network")
implementation("bitcoind:core")
implementation("wallets:wallet")

implementation(libs.typesafe.config)
implementation(libs.bundles.glassfish.jersey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import bisq.support.SupportService;
import bisq.trade.TradeService;
import bisq.user.UserService;
import bisq.wallets.core.BitcoinWalletSelection;
import bisq.wallets.core.WalletService;
import bisq.wallets.core.BitcoinWalletSelection;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

Expand Down
1 change: 1 addition & 0 deletions bisq-easy/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies {
implementation("network:network")
implementation("network:network-identity")
implementation("bitcoind:core")
implementation("wallets:wallet")
// implementation("wallets:electrum")
// implementation("wallets:bitcoind")

Expand Down
1 change: 1 addition & 0 deletions wallets/electrum/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies {
api("bitcoind:core")
implementation("bitcoind:json-rpc")
implementation("bitcoind:regtest")
implementation("wallets:wallet")

implementation(project(":process"))
implementation(libs.typesafe.config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import bisq.common.observable.Observable;
import bisq.common.observable.collection.ObservableSet;
import bisq.common.util.NetworkUtils;
import bisq.wallets.bitcoind.RpcConfig;
import bisq.wallets.core.WalletService;
import bisq.wallets.core.model.Transaction;
import bisq.wallets.core.model.TransactionInfo;
import bisq.wallets.core.model.Utxo;
import bisq.wallets.electrum.notifications.ElectrumNotifyApi;
import bisq.wallets.electrum.notifications.ElectrumNotifyWebServer;
import bisq.wallets.electrum.rpc.ElectrumProcessConfig;
import bisq.wallets.json_rpc.RpcConfig;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

Expand Down Expand Up @@ -97,7 +97,14 @@ public ElectrumWalletService(Config config, Path bisqDataDir) {
@Override
public CompletableFuture<Boolean> initialize() {
log.info("initialize");
return initializeWallet(processConfig.getElectrumConfig().toRpcConfig(), Optional.empty());
bisq.wallets.json_rpc.RpcConfig jsonRpcConfig = processConfig.getElectrumConfig().toRpcConfig();
bisq.wallets.bitcoind.RpcConfig rpcConfig = RpcConfig.builder()
.hostname(jsonRpcConfig.getHostname())
.port(jsonRpcConfig.getPort())
.user(jsonRpcConfig.getUser())
.password(jsonRpcConfig.getPassword())
.build();
return initializeWallet(rpcConfig, Optional.empty());
}

@Override
Expand All @@ -115,8 +122,10 @@ public CompletableFuture<Boolean> shutdown() {
// WalletService
///////////////////////////////////////////////////////////////////////////////////////////////////


@Override
public CompletableFuture<Boolean> initializeWallet(RpcConfig rpcConfig, Optional<String> walletPassphrase) {
public CompletableFuture<Boolean> initializeWallet(bisq.wallets.bitcoind.RpcConfig rpcConfig,
Optional<String> walletPassphrase) {
return CompletableFuture.supplyAsync(() -> {
long ts = System.currentTimeMillis();
electrumProcess.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,8 @@ public CompletableFuture<Boolean> shutdown() {


@Override
public CompletableFuture<Boolean> initializeWallet(bisq.wallets.json_rpc.RpcConfig jsonRpcConfig,
public CompletableFuture<Boolean> initializeWallet(RpcConfig rpcConfig,
Optional<String> walletPassphrase) {
RpcConfig rpcConfig = RpcConfig.builder()
.hostname(jsonRpcConfig.getHostname())
.port(jsonRpcConfig.getPort())
.user(jsonRpcConfig.getUser())
.password(jsonRpcConfig.getPassword())
.build();

if (wallet.isEmpty()) {
boolean isSuccess = verifyRpcConfigAndCreateWallet(Optional.of(rpcConfig));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import bisq.common.monetary.Coin;
import bisq.common.observable.Observable;
import bisq.common.observable.collection.ObservableSet;
import bisq.wallets.bitcoind.RpcConfig;
import bisq.wallets.core.model.Transaction;
import bisq.wallets.core.model.TransactionInfo;
import bisq.wallets.core.model.Utxo;
import bisq.wallets.json_rpc.RpcConfig;

import java.util.List;
import java.util.Optional;
Expand Down

0 comments on commit 0914966

Please sign in to comment.