Skip to content

Commit

Permalink
Merge pull request #7322 from alvasw/RegtestWalletAppKit_Implement_cr…
Browse files Browse the repository at this point in the history
…eateNewBsqWallet_method

RegtestWalletAppKit: Implement createNewBsqWallet method
  • Loading branch information
alejandrogarcia83 authored Dec 10, 2024
2 parents 6e7f80b + 53467f9 commit e4b618d
Showing 1 changed file with 15 additions and 2 deletions.
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;
}
}

0 comments on commit e4b618d

Please sign in to comment.