mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 17:26:28 +01:00
Wallet: add createDeterministic() overloads with KeyChainGroupStructure parameter
This commit is contained in:
parent
3a0060461f
commit
760d9847fb
2 changed files with 33 additions and 3 deletions
|
@ -302,19 +302,48 @@ public class Wallet extends BaseTaggableObject
|
|||
* {@link #loadFromFile}.
|
||||
* @param params network parameters
|
||||
* @param outputScriptType type of addresses (aka output scripts) to generate for receiving
|
||||
* @return A new empty wallet
|
||||
*/
|
||||
public static Wallet createDeterministic(NetworkParameters params, Script.ScriptType outputScriptType) {
|
||||
return createDeterministic(Context.getOrCreate(params), outputScriptType);
|
||||
return createDeterministic(Context.getOrCreate(params), outputScriptType, KeyChainGroupStructure.BIP32);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new, empty wallet with a randomly chosen seed and no transactions. Make sure to provide for sufficient
|
||||
* backup! Any keys will be derived from the seed. If you want to restore a wallet from disk instead, see
|
||||
* {@link #loadFromFile}.
|
||||
* @param params network parameters
|
||||
* @param outputScriptType type of addresses (aka output scripts) to generate for receiving
|
||||
* @param keyChainGroupStructure structure (e.g. BIP32 or BIP43)
|
||||
* @return A new empty wallet
|
||||
*/
|
||||
public static Wallet createDeterministic(NetworkParameters params, Script.ScriptType outputScriptType, KeyChainGroupStructure keyChainGroupStructure) {
|
||||
return createDeterministic(Context.getOrCreate(params), outputScriptType, keyChainGroupStructure);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new, empty wallet with a randomly chosen seed and no transactions. Make sure to provide for sufficient
|
||||
* backup! Any keys will be derived from the seed. If you want to restore a wallet from disk instead, see
|
||||
* {@link #loadFromFile}.
|
||||
* @param context bitcoinj context
|
||||
* @param outputScriptType type of addresses (aka output scripts) to generate for receiving
|
||||
* @return A new empty wallet
|
||||
*/
|
||||
public static Wallet createDeterministic(Context context, Script.ScriptType outputScriptType) {
|
||||
return new Wallet(context, KeyChainGroup.builder(context.getParams()).fromRandom(outputScriptType).build());
|
||||
return createDeterministic(context, outputScriptType, KeyChainGroupStructure.BIP32);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new, empty wallet with a randomly chosen seed and no transactions. Make sure to provide for sufficient
|
||||
* backup! Any keys will be derived from the seed. If you want to restore a wallet from disk instead, see
|
||||
* {@link #loadFromFile}.
|
||||
* @param context bitcoinj context
|
||||
* @param outputScriptType type of addresses (aka output scripts) to generate for receiving
|
||||
* @param keyChainGroupStructure structure (e.g. BIP32 or BIP43)
|
||||
* @return A new empty wallet
|
||||
*/
|
||||
public static Wallet createDeterministic(Context context, Script.ScriptType outputScriptType, KeyChainGroupStructure keyChainGroupStructure) {
|
||||
return new Wallet(context, KeyChainGroup.builder(context.getParams(), keyChainGroupStructure).fromRandom(outputScriptType).build());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.bitcoinj.script.Script;
|
|||
import org.bitcoinj.store.BlockStore;
|
||||
import org.bitcoinj.store.MemoryBlockStore;
|
||||
import org.bitcoinj.utils.BriefLogFormatter;
|
||||
import org.bitcoinj.wallet.KeyChainGroupStructure;
|
||||
import org.bitcoinj.wallet.Wallet;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
|
@ -69,7 +70,7 @@ public class TestWithWallet {
|
|||
public void setUp() throws Exception {
|
||||
BriefLogFormatter.init();
|
||||
Context.propagate(new Context(UNITTEST, 100, Coin.ZERO, false));
|
||||
wallet = Wallet.createDeterministic(UNITTEST, Script.ScriptType.P2PKH);
|
||||
wallet = Wallet.createDeterministic(UNITTEST, Script.ScriptType.P2PKH, KeyChainGroupStructure.BIP32);
|
||||
myKey = wallet.freshReceiveKey();
|
||||
myAddress = wallet.freshReceiveAddress(Script.ScriptType.P2PKH);
|
||||
blockStore = new MemoryBlockStore(UNITTEST);
|
||||
|
|
Loading…
Add table
Reference in a new issue