mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
core: Implement RegtestWalletAppKit
The RegtestWalletAppKit sets up BitcoinJ and loads the given wallets.
This commit is contained in:
parent
ba28806d74
commit
33a968a6d5
@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'bisq.java-conventions'
|
id 'bisq.java-conventions'
|
||||||
id 'bisq.javafx'
|
id 'bisq.javafx'
|
||||||
|
id 'bisq.java-integration-tests'
|
||||||
}
|
}
|
||||||
|
|
||||||
javafx {
|
javafx {
|
||||||
@ -61,6 +62,10 @@ dependencies {
|
|||||||
testAnnotationProcessor libs.lombok
|
testAnnotationProcessor libs.lombok
|
||||||
testCompileOnly libs.lombok
|
testCompileOnly libs.lombok
|
||||||
testImplementation libs.natpryce.make.it.easy
|
testImplementation libs.natpryce.make.it.easy
|
||||||
|
|
||||||
|
integrationTestImplementation libs.junit.jupiter
|
||||||
|
integrationTestAnnotationProcessor libs.lombok
|
||||||
|
integrationTestCompileOnly libs.lombok
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
package bisq.core;
|
||||||
|
|
||||||
|
import bisq.core.btc.wallet.WalletFactory;
|
||||||
|
|
||||||
|
import org.bitcoinj.core.NetworkParameters;
|
||||||
|
import org.bitcoinj.kits.WalletAppKit;
|
||||||
|
import org.bitcoinj.wallet.Wallet;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class RegtestWalletAppKit {
|
||||||
|
private final WalletAppKit walletAppKit;
|
||||||
|
|
||||||
|
public RegtestWalletAppKit(NetworkParameters networkParams, Path dataDirPath, List<Wallet> wallets) {
|
||||||
|
walletAppKit = new WalletAppKit(networkParams, dataDirPath.toFile(), "dataDirFilePrefix") {
|
||||||
|
@Override
|
||||||
|
protected void onSetupCompleted() {
|
||||||
|
super.onSetupCompleted();
|
||||||
|
wallets.forEach(wallet -> {
|
||||||
|
vChain.addWallet(wallet);
|
||||||
|
vPeerGroup.addWallet(wallet);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialize() {
|
||||||
|
walletAppKit.connectToLocalHost();
|
||||||
|
|
||||||
|
var walletFactory = new WalletFactory(walletAppKit.params());
|
||||||
|
walletAppKit.setWalletFactory((params, keyChainGroup) -> walletFactory.createBsqWallet());
|
||||||
|
|
||||||
|
walletAppKit.startAsync();
|
||||||
|
walletAppKit.awaitRunning();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user