Search in sources :

Example 1 with KeyChainGroupStructure

use of org.bitcoinj.wallet.KeyChainGroupStructure in project haveno by haveno-dex.

the class HavenoKeyChainFactory method makeKeyChain.

@Override
public DeterministicKeyChain makeKeyChain(Protos.Key key, Protos.Key firstSubKey, DeterministicSeed seed, KeyCrypter crypter, boolean isMarried, Script.ScriptType outputScriptType, ImmutableList<ChildNumber> accountPath) {
    ImmutableList<ChildNumber> maybeUpdatedAccountPath = accountPath;
    if (DeterministicKeyChain.ACCOUNT_ZERO_PATH.equals(accountPath)) {
        // This is a bitcoinj 0.14 wallet that has no account path in the serialized mnemonic
        KeyChainGroupStructure structure = new HavenoKeyChainGroupStructure();
        maybeUpdatedAccountPath = structure.accountPathFor(outputScriptType);
    }
    return super.makeKeyChain(key, firstSubKey, seed, crypter, isMarried, outputScriptType, maybeUpdatedAccountPath);
}
Also used : KeyChainGroupStructure(org.bitcoinj.wallet.KeyChainGroupStructure) ChildNumber(org.bitcoinj.crypto.ChildNumber)

Example 2 with KeyChainGroupStructure

use of org.bitcoinj.wallet.KeyChainGroupStructure in project haveno by haveno-dex.

the class WalletConfig method createWallet.

protected Wallet createWallet() {
    Script.ScriptType preferredOutputScriptType = Script.ScriptType.P2WPKH;
    KeyChainGroupStructure structure = new HavenoKeyChainGroupStructure();
    KeyChainGroup.Builder kcgBuilder = KeyChainGroup.builder(params, structure);
    if (restoreFromSeed != null) {
        kcgBuilder.fromSeed(restoreFromSeed, preferredOutputScriptType);
    } else {
        // new wallet
        // btc wallet uses a new random seed.
        kcgBuilder.fromRandom(preferredOutputScriptType);
    }
    return new Wallet(params, kcgBuilder.build());
}
Also used : Script(org.bitcoinj.script.Script) KeyChainGroupStructure(org.bitcoinj.wallet.KeyChainGroupStructure) Wallet(org.bitcoinj.wallet.Wallet) KeyChainGroup(org.bitcoinj.wallet.KeyChainGroup)

Aggregations

KeyChainGroupStructure (org.bitcoinj.wallet.KeyChainGroupStructure)2 ChildNumber (org.bitcoinj.crypto.ChildNumber)1 Script (org.bitcoinj.script.Script)1 KeyChainGroup (org.bitcoinj.wallet.KeyChainGroup)1 Wallet (org.bitcoinj.wallet.Wallet)1