mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Merge pull request #7287 from alvasw/core_Implement_WalletFactory
core: Implement WalletFactory
This commit is contained in:
commit
9af707d4e4
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