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

Downgrade bitcoind to Java 11 #2846

Merged
merged 3 commits into from
Sep 22, 2024
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void sendBtcAndListTxs() throws MalformedURLException, InterruptedExcepti
List<BitcoindListTransactionsResponse.Entry> txs = receiverBackend.listTransactions(10);
assertEquals(3, txs.size());

BitcoindListTransactionsResponse.Entry firstTx = txs.getFirst();
BitcoindListTransactionsResponse.Entry firstTx = txs.stream().findFirst().orElseThrow();
assertEquals(firstTxReceiverAddress, firstTx.getAddress());
assertEquals("receive", firstTx.getCategory());
assertEquals(100000000, firstTx.getAmount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ public enum BitcoindZmqTopic {
}

public static BitcoindZmqTopic parse(String topicName) {
return switch (topicName) {
case BitcoindZmqTopic.HASHBLOCK_TOPIC_NAME -> TOPIC_HASHBLOCK;
case BitcoindZmqTopic.RAWTX_TOPIC_NAME -> TOPIC_RAWTX;
default -> throw new IllegalStateException("Unknown ZMQ topic: " + topicName);
};
if (topicName.equals(BitcoindZmqTopic.HASHBLOCK_TOPIC_NAME)) {
return TOPIC_HASHBLOCK;
} else if (topicName.equals(BitcoindZmqTopic.RAWTX_TOPIC_NAME)) {
return TOPIC_RAWTX;
} else {
throw new IllegalStateException("Unknown ZMQ topic: " + topicName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private String findZmqAddress(List<BitcoindGetZmqNotificationsResponse.Entry> zm
throw new CannotFindZmqAddressException("ZeroMQ: All topics need to published on the same address.");
}

return zmqNotifications.getFirst().getAddress();
return zmqNotifications.stream().findFirst().orElseThrow().getAddress();
}

private boolean canSubscribeToAllTopics(List<BitcoindGetZmqNotificationsResponse.Entry> zmqNotifications) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,14 @@

package bisq.wallets.json_rpc;

import bisq.common.proto.PersistableProto;
import lombok.Builder;
import lombok.Getter;

@Builder
@Getter
public final class RpcConfig implements PersistableProto {
public final class RpcConfig {
private String hostname;
private int port;
private String user;
private String password;

@Override
public bisq.wallets.protobuf.RpcConfig toProto(boolean serializeForHash) {
return resolveProto(serializeForHash);
}

@Override
public bisq.wallets.protobuf.RpcConfig.Builder getBuilder(boolean serializeForHash) {
return bisq.wallets.protobuf.RpcConfig.newBuilder()
.setHostname(hostname)
.setPort(port)
.setUser(user)
.setPassword(password);
}

public static RpcConfig fromProto(bisq.wallets.protobuf.RpcConfig proto) {
return RpcConfig.builder()
.hostname(proto.getHostname())
.port(proto.getPort())
.user(proto.getUser())
.password(proto.getPassword())
.build();
}
}
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 @@ -23,7 +23,7 @@
import bisq.persistence.Persistence;
import bisq.persistence.PersistenceService;
import bisq.wallets.bitcoind.AbstractBitcoindWalletService;
import bisq.wallets.json_rpc.RpcConfig;
import bisq.wallets.bitcoind.RpcConfig;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

Expand All @@ -47,19 +47,25 @@ public LiquidWalletService(PersistenceService persistenceService,
}

@Override
protected LiquidWallet createWallet(RpcConfig rpcConfig) {
return WalletFactory.createLiquidWallet(rpcConfig, walletName, persistableStore);
protected LiquidWallet createWallet(bisq.wallets.bitcoind.RpcConfig rpcConfig) {
return WalletFactory.createLiquidWallet(rpcConfig.toJsonRpcConfig(), walletName, persistableStore);
}

@Override
protected void persistRpcConfig(RpcConfig rpcConfig) {
persistableStore.setRpcConfig(Optional.of(rpcConfig));
protected void persistRpcConfig(bisq.wallets.bitcoind.RpcConfig rpcConfig) {
persistableStore.setRpcConfig(Optional.of(rpcConfig.toJsonRpcConfig()));
persist();
}

@Override
protected Optional<RpcConfig> getRpcConfigFromPersistableStore() {
return persistableStore.getRpcConfig();
protected Optional<bisq.wallets.bitcoind.RpcConfig> getRpcConfigFromPersistableStore() {
return persistableStore.getRpcConfig().map(jsonRpcConfig ->
RpcConfig.builder()
.hostname(jsonRpcConfig.getHostname())
.port(jsonRpcConfig.getPort())
.user(jsonRpcConfig.getUser())
.password(jsonRpcConfig.getPassword())
.build());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ public bisq.wallets.protobuf.LiquidWalletStore.Builder getBuilder(boolean serial
bisq.wallets.protobuf.LiquidWalletStore.newBuilder()
.addAllWalletAddresses(walletAddresses);

rpcConfig.ifPresent(config -> builder.setRpcConfig(config.toProto(serializeForHash)));
return builder;
throw new UnsupportedOperationException("Not implemented.");
/* rpcConfig.ifPresent(config -> builder.setRpcConfig(config.toProto(serializeForHash)));
return builder; */
}

@Override
Expand All @@ -61,9 +62,10 @@ public bisq.wallets.protobuf.LiquidWalletStore toProto(boolean serializeForHash)
}

public static LiquidWalletStore fromProto(bisq.wallets.protobuf.LiquidWalletStore proto) {
Optional<RpcConfig> rpcConfig = proto.hasRpcConfig() ? Optional.of(RpcConfig.fromProto(proto.getRpcConfig()))
throw new UnsupportedOperationException("Not implemented.");
/* Optional<RpcConfig> rpcConfig = proto.hasRpcConfig() ? Optional.of(RpcConfig.fromProto(proto.getRpcConfig()))
: Optional.empty();
return new LiquidWalletStore(rpcConfig, new ArrayList<>(proto.getWalletAddressesList()));
return new LiquidWalletStore(rpcConfig, new ArrayList<>(proto.getWalletAddressesList())); */
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
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 lombok.Getter;
import lombok.extern.slf4j.Slf4j;

Expand Down Expand Up @@ -115,8 +114,10 @@ public CompletableFuture<Boolean> shutdown() {
// WalletService
///////////////////////////////////////////////////////////////////////////////////////////////////


@Override
public CompletableFuture<Boolean> initializeWallet(RpcConfig rpcConfig, Optional<String> walletPassphrase) {
public CompletableFuture<Boolean> initializeWallet(RpcConfig rpcConfig,
Optional<String> walletPassphrase) {
if (wallet.isEmpty()) {
boolean isSuccess = verifyRpcConfigAndCreateWallet(Optional.of(rpcConfig));

Expand Down Expand Up @@ -242,7 +243,7 @@ private boolean verifyRpcConfigAndCreateWallet(Optional<RpcConfig> optionalRpcCo
if (optionalRpcConfig.isEmpty()) return false;

RpcConfig rpcConfig = optionalRpcConfig.get();
boolean isValidRpcConfig = BitcoindDaemon.verifyRpcConfig(rpcConfig);
boolean isValidRpcConfig = BitcoindDaemon.verifyRpcConfig(rpcConfig.toJsonRpcConfig());
if (isValidRpcConfig) {
T walletImpl = createWallet(rpcConfig);
wallet = Optional.of(walletImpl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import bisq.persistence.DbSubDirectory;
import bisq.persistence.Persistence;
import bisq.persistence.PersistenceService;
import bisq.wallets.json_rpc.RpcConfig;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

Expand Down Expand Up @@ -63,7 +62,7 @@ public BitcoinWalletService(Config config,

@Override
protected BitcoinWallet createWallet(RpcConfig rpcConfig) {
return WalletFactory.createBitcoinWallet(rpcConfig, walletName, persistableStore);
return WalletFactory.createBitcoinWallet(rpcConfig.toJsonRpcConfig(), walletName, persistableStore);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import bisq.common.proto.ProtoResolver;
import bisq.common.proto.UnresolvableProtobufMessageException;
import bisq.persistence.PersistableStore;
import bisq.wallets.json_rpc.RpcConfig;
import com.google.protobuf.InvalidProtocolBufferException;
import lombok.Getter;
import lombok.Setter;
Expand Down
64 changes: 64 additions & 0 deletions wallets/wallet/src/main/java/bisq/wallets/bitcoind/RpcConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.wallets.bitcoind;

import bisq.common.proto.PersistableProto;
import lombok.Builder;
import lombok.Getter;

@Builder
@Getter
public final class RpcConfig implements PersistableProto {
private String hostname;
private int port;
private String user;
private String password;

@Override
public bisq.wallets.protobuf.RpcConfig toProto(boolean serializeForHash) {
return resolveProto(serializeForHash);
}

@Override
public bisq.wallets.protobuf.RpcConfig.Builder getBuilder(boolean serializeForHash) {
return bisq.wallets.protobuf.RpcConfig.newBuilder()
.setHostname(hostname)
.setPort(port)
.setUser(user)
.setPassword(password);
}

public static RpcConfig fromProto(bisq.wallets.protobuf.RpcConfig proto) {
return RpcConfig.builder()
.hostname(proto.getHostname())
.port(proto.getPort())
.user(proto.getUser())
.password(proto.getPassword())
.build();
}

public bisq.wallets.json_rpc.RpcConfig toJsonRpcConfig() {
return bisq.wallets.json_rpc.RpcConfig.builder()
.hostname(hostname)
.port(port)
.user(user)
.password(password)
.build();
}
}

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
Loading