mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
core: Implement WalletFactory
The WalletFactory can create BTC and BSQ wallets.
This commit is contained in:
parent
4a65e40d5c
commit
77c48d8dd8
34
core/src/main/java/bisq/core/btc/wallet/WalletFactory.java
Normal file
34
core/src/main/java/bisq/core/btc/wallet/WalletFactory.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package bisq.core.btc.wallet;
|
||||||
|
|
||||||
|
import bisq.core.btc.setup.BisqKeyChainGroupStructure;
|
||||||
|
|
||||||
|
import org.bitcoinj.core.NetworkParameters;
|
||||||
|
import org.bitcoinj.script.Script;
|
||||||
|
import org.bitcoinj.wallet.KeyChainGroup;
|
||||||
|
import org.bitcoinj.wallet.KeyChainGroupStructure;
|
||||||
|
import org.bitcoinj.wallet.Wallet;
|
||||||
|
|
||||||
|
public class WalletFactory {
|
||||||
|
private final NetworkParameters networkParams;
|
||||||
|
|
||||||
|
public WalletFactory(NetworkParameters networkParams) {
|
||||||
|
this.networkParams = networkParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Wallet createBtcWallet() {
|
||||||
|
return createWallet(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Wallet createBsqWallet() {
|
||||||
|
return createWallet(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Wallet createWallet(boolean isBsqWallet) {
|
||||||
|
KeyChainGroupStructure structure = new BisqKeyChainGroupStructure(isBsqWallet);
|
||||||
|
KeyChainGroup.Builder kcgBuilder = KeyChainGroup.builder(networkParams, structure);
|
||||||
|
|
||||||
|
Script.ScriptType preferredOutputScriptType = Script.ScriptType.P2WPKH;
|
||||||
|
kcgBuilder.fromRandom(preferredOutputScriptType);
|
||||||
|
return new Wallet(networkParams, kcgBuilder.build());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user