mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-28 17:15:14 +01:00
Merge pull request #7322 from alvasw/RegtestWalletAppKit_Implement_createNewBsqWallet_method
RegtestWalletAppKit: Implement createNewBsqWallet method
This commit is contained in:
commit
e4b618d718
1 changed files with 15 additions and 2 deletions
|
@ -2,7 +2,9 @@ package bisq.core;
|
|||
|
||||
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;
|
||||
|
||||
|
@ -15,6 +17,7 @@ import lombok.Getter;
|
|||
@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") {
|
||||
|
@ -27,15 +30,25 @@ public class RegtestWalletAppKit {
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
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…
Add table
Reference in a new issue