Search in sources :

Example 1 with InvalidMasterSeedException

use of com.toshi.exception.InvalidMasterSeedException in project toshi-android-client by toshiapp.

the class HDWallet method createFromMasterSeed.

public Single<HDWallet> createFromMasterSeed(final String masterSeed) {
    return Single.fromCallable(() -> {
        try {
            final DeterministicSeed seed = getSeed(masterSeed);
            seed.check();
            final Wallet wallet = constructFromSeed(seed);
            deriveKeysFromWallet(wallet);
            saveMasterSeedToStorage(masterSeed);
            return this;
        } catch (final UnreadableWalletException | MnemonicException e) {
            LogUtil.exception("Error while creating wallet from master seed", e);
            throw new InvalidMasterSeedException(e);
        }
    });
}
Also used : DeterministicSeed(org.bitcoinj.wallet.DeterministicSeed) UnreadableWalletException(org.bitcoinj.wallet.UnreadableWalletException) MnemonicException(org.bitcoinj.crypto.MnemonicException) Wallet(org.bitcoinj.wallet.Wallet) InvalidMasterSeedException(com.toshi.exception.InvalidMasterSeedException)

Aggregations

InvalidMasterSeedException (com.toshi.exception.InvalidMasterSeedException)1 MnemonicException (org.bitcoinj.crypto.MnemonicException)1 DeterministicSeed (org.bitcoinj.wallet.DeterministicSeed)1 UnreadableWalletException (org.bitcoinj.wallet.UnreadableWalletException)1 Wallet (org.bitcoinj.wallet.Wallet)1