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

Remove bitcoind's dependency to root build-logic module #2849

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
11 changes: 11 additions & 0 deletions wallets/bitcoind/build-logic/commons/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
}

dependencies {
implementation(libs.protobuf.gradle.plugin)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
plugins {
`java-library`
}

repositories {
mavenCentral()
maven {
url = uri("https://jitpack.io")
}
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

tasks {
test {
useJUnitPlatform()
}
}

val versionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")
dependencies {
versionCatalog.findLibrary("google-guava").ifPresent {
implementation(it)
}

versionCatalog.findLibrary("lombok").ifPresent {
compileOnly(it)
annotationProcessor(it)
testAnnotationProcessor(it)
testCompileOnly(it)
}

versionCatalog.findLibrary("slf4j-api").ifPresent {
implementation(it)
}

versionCatalog.findLibrary("logback-core").ifPresent {
implementation(it)
}
versionCatalog.findLibrary("logback-classic").ifPresent {
implementation(it)
}

versionCatalog.findLibrary("junit-jupiter").ifPresent {
testImplementation(it)
}

versionCatalog.findLibrary("assertj-core").ifPresent {
testImplementation(it)
}

versionCatalog.findLibrary("mockito").ifPresent {
testImplementation(it)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
plugins {
java
}

sourceSets {
create("integrationTest") {
compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output
}
}

val integrationTestImplementation by configurations.getting {
extendsFrom(configurations.implementation.get())
}

val integrationTestRuntimeOnly by configurations.getting
configurations["integrationTestRuntimeOnly"].extendsFrom(configurations.runtimeOnly.get())

val versionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")
dependencies {
versionCatalog.findLibrary("lombok").ifPresent {
"integrationTestAnnotationProcessor"(it)
"integrationTestCompileOnly"(it)
}

versionCatalog.findLibrary("slf4j-api").ifPresent {
"integrationTestImplementation"(it)
}

versionCatalog.findLibrary("logback-core").ifPresent {
"integrationTestImplementation"(it)
}
versionCatalog.findLibrary("logback-classic").ifPresent {
"integrationTestImplementation"(it)
}

versionCatalog.findLibrary("junit-jupiter").ifPresent {
"integrationTestImplementation"(it)
}

versionCatalog.findLibrary("assertj-core").ifPresent {
"integrationTestImplementation"(it)
}
}

tasks.register<Test>("integrationTest") {
description = "Runs integration tests."
group = "verification"

testClassesDirs = sourceSets["integrationTest"].output.classesDirs
classpath = sourceSets["integrationTest"].runtimeClasspath
shouldRunAfter("test")

useJUnitPlatform()

testLogging {
events("passed")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id("bisq.java-conventions")
}
1 change: 1 addition & 0 deletions wallets/bitcoind/build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencyResolutionManagement {
}
}

include("commons")
include("bitcoin-core-binaries")
include("gradle-tasks")

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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ public enum Os {
this.canonicalName = canonicalName;
}

public static bisq.common.platform.OS getOS() {
String osName = getOsName();
if (isLinux(osName)) {
return bisq.common.platform.OS.LINUX;
} else if (isMacOs(osName)) {
return bisq.common.platform.OS.MAC_OS;
} else if (isWindows(osName)) {
return bisq.common.platform.OS.WINDOWS;
}
throw new IllegalStateException("Running on unsupported OS: " + osName);
}

public static boolean isLinux() {
return isLinux(getOsName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package bisq.wallets.regtest.process;

import bisq.common.threading.ThreadName;
import bisq.wallets.regtest.LogScanner;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -63,7 +62,7 @@ public void shutdown() {

protected void waitUntilReady() {
FutureTask<Boolean> waitingFuture = new FutureTask<>(() -> {
ThreadName.set(this, "waitUntilLogContainsLines");
Thread.currentThread().setName("waitUntilLogContainsLines");
return waitUntilLogContainsLines();
});
Thread waitingThread = new Thread(waitingFuture);
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 @@ -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
Loading
Loading