-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The RegtestWalletAppKit sets up BitcoinJ and loads the given wallets.
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
core/src/integrationTest/java/bisq/core/RegtestWalletAppKit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |