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

RegtestWalletAppKit: Implement createNewBsqWallet method #7322

Merged
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
17 changes: 15 additions & 2 deletions core/src/integrationTest/java/bisq/core/RegtestWalletAppKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import bisq.core.btc.wallet.WalletFactory;

import org.bitcoinj.core.BlockChain;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.PeerGroup;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.wallet.Wallet;

Expand All @@ -15,6 +17,7 @@
@Getter
public class RegtestWalletAppKit {
private final WalletAppKit walletAppKit;
private final WalletFactory walletFactory;

public RegtestWalletAppKit(NetworkParameters networkParams, Path dataDirPath, List<Wallet> wallets) {
walletAppKit = new WalletAppKit(networkParams, dataDirPath.toFile(), "dataDirFilePrefix") {
Expand All @@ -27,15 +30,25 @@ protected void onSetupCompleted() {
});
}
};

walletFactory = new WalletFactory(networkParams);
}

public void initialize() {
walletAppKit.connectToLocalHost();

var walletFactory = new WalletFactory(walletAppKit.params());
walletAppKit.setWalletFactory((params, keyChainGroup) -> walletFactory.createBsqWallet());

walletAppKit.startAsync();
walletAppKit.awaitRunning();
}

public Wallet createNewBsqWallet() {
Wallet bsqWallet = walletFactory.createBsqWallet();
BlockChain blockChain = walletAppKit.chain();
blockChain.addWallet(bsqWallet);

PeerGroup peerGroup = walletAppKit.peerGroup();
peerGroup.addWallet(bsqWallet);
return bsqWallet;
}
}
Loading