Merge pull request #7290 from alvasw/core_Implement_RegtestWalletAppKit

core: Implement RegtestWalletAppKit
This commit is contained in:
Alejandro García 2024-11-12 06:34:07 +00:00 committed by GitHub
commit f9a2345228
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 46 additions and 0 deletions

View File

@ -1,6 +1,7 @@
plugins {
id 'bisq.java-conventions'
id 'bisq.javafx'
id 'bisq.java-integration-tests'
}
javafx {
@ -61,6 +62,10 @@ dependencies {
testAnnotationProcessor libs.lombok
testCompileOnly libs.lombok
testImplementation libs.natpryce.make.it.easy
integrationTestImplementation libs.junit.jupiter
integrationTestAnnotationProcessor libs.lombok
integrationTestCompileOnly libs.lombok
}
test {

View File

@ -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();
}
}