Skip to content

Commit 33a968a

Browse files
committedNov 10, 2024··
core: Implement RegtestWalletAppKit
The RegtestWalletAppKit sets up BitcoinJ and loads the given wallets.
1 parent ba28806 commit 33a968a

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
 

‎core/build.gradle

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'bisq.java-conventions'
33
id 'bisq.javafx'
4+
id 'bisq.java-integration-tests'
45
}
56

67
javafx {
@@ -61,6 +62,10 @@ dependencies {
6162
testAnnotationProcessor libs.lombok
6263
testCompileOnly libs.lombok
6364
testImplementation libs.natpryce.make.it.easy
65+
66+
integrationTestImplementation libs.junit.jupiter
67+
integrationTestAnnotationProcessor libs.lombok
68+
integrationTestCompileOnly libs.lombok
6469
}
6570

6671
test {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package bisq.core;
2+
3+
import bisq.core.btc.wallet.WalletFactory;
4+
5+
import org.bitcoinj.core.NetworkParameters;
6+
import org.bitcoinj.kits.WalletAppKit;
7+
import org.bitcoinj.wallet.Wallet;
8+
9+
import java.nio.file.Path;
10+
11+
import java.util.List;
12+
13+
import lombok.Getter;
14+
15+
@Getter
16+
public class RegtestWalletAppKit {
17+
private final WalletAppKit walletAppKit;
18+
19+
public RegtestWalletAppKit(NetworkParameters networkParams, Path dataDirPath, List<Wallet> wallets) {
20+
walletAppKit = new WalletAppKit(networkParams, dataDirPath.toFile(), "dataDirFilePrefix") {
21+
@Override
22+
protected void onSetupCompleted() {
23+
super.onSetupCompleted();
24+
wallets.forEach(wallet -> {
25+
vChain.addWallet(wallet);
26+
vPeerGroup.addWallet(wallet);
27+
});
28+
}
29+
};
30+
}
31+
32+
public void initialize() {
33+
walletAppKit.connectToLocalHost();
34+
35+
var walletFactory = new WalletFactory(walletAppKit.params());
36+
walletAppKit.setWalletFactory((params, keyChainGroup) -> walletFactory.createBsqWallet());
37+
38+
walletAppKit.startAsync();
39+
walletAppKit.awaitRunning();
40+
}
41+
}

0 commit comments

Comments
 (0)
Please sign in to comment.