org.bitcoinj.wallet.DeterministicSeed Java Examples

The following examples show how to use org.bitcoinj.wallet.DeterministicSeed. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GUIUtil.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void restoreSeedWords(DeterministicSeed seed, WalletsManager walletsManager, File storageDir) {
    try {
        FileUtil.renameFile(new File(storageDir, "AddressEntryList"), new File(storageDir, "AddressEntryList_wallet_restore_" + System.currentTimeMillis()));
    } catch (Throwable t) {
        new Popup().error(Res.get("error.deleteAddressEntryListFailed", t)).show();
    }
    walletsManager.restoreSeedWords(
            seed,
            () -> UserThread.execute(() -> {
                log.info("Wallets restored with seed words");
                new Popup().feedback(Res.get("seed.restore.success")).hideCloseButton().show();
                BisqApp.getShutDownHandler().run();
            }),
            throwable -> UserThread.execute(() -> {
                log.error(throwable.toString());
                new Popup().error(Res.get("seed.restore.error", Res.get("shared.errorMessageInline", throwable)))
                        .show();
            }));
}
 
Example #2
Source File: WalletsSetup.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public void restoreSeedWords(@Nullable DeterministicSeed seed,
                             ResultHandler resultHandler,
                             ExceptionHandler exceptionHandler) {
    checkNotNull(seed, "Seed must be not be null.");

    backupWallets();

    Context ctx = Context.get();
    new Thread(() -> {
        try {
            Context.propagate(ctx);
            walletConfig.stopAsync();
            walletConfig.awaitTerminated();
            initialize(seed, resultHandler, exceptionHandler);
        } catch (Throwable t) {
            t.printStackTrace();
            log.error("Executing task failed. " + t.getMessage());
        }
    }, "RestoreBTCWallet-%d").start();
}
 
Example #3
Source File: WalletsSetup.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
public void restoreSeedWords(@Nullable DeterministicSeed seed, ResultHandler resultHandler, ExceptionHandler exceptionHandler) {
    checkNotNull(seed, "Seed must be not be null.");

    backupWallets();

    Context ctx = Context.get();
    new Thread(() -> {
        try {
            Context.propagate(ctx);
            walletConfig.stopAsync();
            walletConfig.awaitTerminated();
            initialize(seed, resultHandler, exceptionHandler);
        } catch (Throwable t) {
            t.printStackTrace();
            log.error("Executing task failed. " + t.getMessage());
        }
    }, "RestoreBTCWallet-%d").start();
}
 
Example #4
Source File: ETHMnemonic.java    From Upchain-wallet with GNU Affero General Public License v3.0 6 votes vote down vote up
private static EthHDWallet importMnemonic(String path, List<String> list, String password) {
    if (!path.startsWith("m") && !path.startsWith("M")) {
        //参数非法
        return null;
    }
    String[] pathArray = path.split("/");
    if (pathArray.length <= 1) {
        //内容不对
        return null;
    }
    if (password.length() < 8) {
        //密码过短
        return null;
    }
    String passphrase = "";
    long creationTimeSeconds = System.currentTimeMillis() / 1000;
    DeterministicSeed ds = new DeterministicSeed(list, null, passphrase, creationTimeSeconds);

    return createEthWallet(ds, pathArray, password);
}
 
Example #5
Source File: WalletConfig.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
private Wallet createOrLoadWallet(File walletFile, boolean shouldReplayWallet,
                                  BisqKeyChainGroup keyChainGroup, boolean isBsqWallet, DeterministicSeed restoreFromSeed)
        throws Exception {

    if (restoreFromSeed != null)
        maybeMoveOldWalletOutOfTheWay(walletFile);

    Wallet wallet;
    if (walletFile.exists()) {
        wallet = loadWallet(walletFile, shouldReplayWallet, keyChainGroup.isUseBitcoinDeterministicKeyChain());
    } else {
        wallet = createWallet(keyChainGroup, isBsqWallet);
        wallet.freshReceiveKey();
        wallet.saveToFile(walletFile);
    }

    if (useAutoSave) wallet.autosaveToFile(walletFile, 5, TimeUnit.SECONDS, null);

    return wallet;
}
 
Example #6
Source File: WalletManager.java    From token-core-android with Apache License 2.0 6 votes vote down vote up
public static Wallet findWalletByMnemonic(String chainType, String network, String mnemonic, String path, String segWit) {
  List<String> mnemonicCodes = Arrays.asList(mnemonic.split(" "));
  MnemonicUtil.validateMnemonics(mnemonicCodes);
  DeterministicSeed seed = new DeterministicSeed(mnemonicCodes, null, "", 0L);
  DeterministicKeyChain keyChain = DeterministicKeyChain.builder().seed(seed).build();
  if (Strings.isNullOrEmpty(path)) {
    throw new TokenException(Messages.INVALID_MNEMONIC_PATH);
  }

  if (ChainType.BITCOIN.equalsIgnoreCase(chainType)) {
    path += "/0/0";
  }

  DeterministicKey key = keyChain.getKeyByPath(BIP44Util.generatePath(path), true);
  Network net = new Network(network);
  String address = AddressCreatorManager.getInstance(chainType, net.isMainnet(), segWit).fromPrivateKey(key.getPrivateKeyAsHex());
  return findWalletByAddress(chainType, address);
}
 
Example #7
Source File: V3MnemonicKeystore.java    From token-core-android with Apache License 2.0 6 votes vote down vote up
private V3MnemonicKeystore(Metadata metadata, String password, List<String> mnemonicCodes, String path, String id) {
  MnemonicUtil.validateMnemonics(mnemonicCodes);
  DeterministicSeed seed = new DeterministicSeed(mnemonicCodes, null, "", 0L);
  DeterministicKeyChain keyChain = DeterministicKeyChain.builder().seed(seed).build();

  this.mnemonicPath = path;
  List<ChildNumber> zeroPath = BIP44Util.generatePath(path);

  byte[] prvKeyBytes = keyChain.getKeyByPath(zeroPath, true).getPrivKeyBytes();
  this.crypto = Crypto.createPBKDF2CryptoWithKDFCached(password, prvKeyBytes);
  this.encMnemonic = crypto.deriveEncPair(password, Joiner.on(" ").join(mnemonicCodes).getBytes());
  this.crypto.clearCachedDerivedKey();

  this.address = AddressCreatorManager.getInstance(metadata.getChainType(), metadata.isMainNet(), metadata.getSegWit()).fromPrivateKey(prvKeyBytes);
  metadata.setTimestamp(DateUtil.getUTCTime());
  metadata.setWalletType(Metadata.V3);
  this.metadata = metadata;
  this.version = VERSION;
  this.id = Strings.isNullOrEmpty(id) ? UUID.randomUUID().toString() : id;
}
 
Example #8
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 6 votes vote down vote up
public void restoreFromBlock0(String mnemonicCode, Runnable callback) {
    if (mnemonicCode.charAt(mnemonicCode.length() - 1) == ' ') {
        mnemonicCode = mnemonicCode.substring(0, mnemonicCode.length() - 1);
    }

    DeterministicSeed seed = new DeterministicSeed(Splitter.on(' ').splitToList(mnemonicCode), null, "", 0);

    wallet = Wallet.fromSeed(params, seed);
    mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode());
    //sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey));
    walletFriendlyAddress = wallet.currentReceiveAddress().toString();
    callback.run();

    RequestorBtc.getUTXOListDgbNew(wallet.currentReceiveAddress().toString(), new ApiMethods.RequestListener() {
        @Override
        public void onSuccess(Object response) {
            List<UTXOItemDgb> utxos = (List<UTXOItemDgb>)response;
            setUTXO(utxos);
        }

        @Override
        public void onFailure(String msg) {

        }
    });
}
 
Example #9
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 6 votes vote down vote up
public void restoreFromBlock0(String mnemonicCode, Runnable callback) {
    if (mnemonicCode.charAt(mnemonicCode.length() - 1) == ' ') {
        mnemonicCode = mnemonicCode.substring(0, mnemonicCode.length() - 1);
    }

    DeterministicSeed seed = new DeterministicSeed(Splitter.on(' ').splitToList(mnemonicCode), null, "", 0);

    wallet = Wallet.fromSeed(params, seed);
    mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode());
    //sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey));
    walletFriendlyAddress = wallet.currentReceiveAddress().toString();
    callback.run();

    RequestorBtc.getUTXOListSbtcNew(wallet.currentReceiveAddress().toString(), new ApiMethods.RequestListener() {
        @Override
        public void onSuccess(Object response) {
            List<UTXOItem> utxos = (List<UTXOItem>)response;
            setUTXO(utxos);
        }

        @Override
        public void onFailure(String msg) {

        }
    });
}
 
Example #10
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 6 votes vote down vote up
public void createWallet2(String passphrase, Runnable callback) {

        wallet = new Wallet(params);
        DeterministicSeed seed = wallet.getKeyChainSeed();

        mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode());
        sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey));

        updateWalletFriendlyAddress();

//        ChildNumber childNumber = new ChildNumber(ChildNumber.HARDENED_BIT);
//        DeterministicKey de = wallet.getKeyByPath(ImmutableList.of(childNumber));
//        xprvKey = de.serializePrivB58(params);
//
//        if (BuildConfig.DEBUG) {
//            DeterministicKey dk = extractWalletDeterministicKey();
//            wifKey = dk.getPrivateKeyAsWiF(params);
//        } else {
//            wifKey = wallet.currentReceiveKey().getPrivateKeyAsWiF(params);
//        }

        callback.run();
    }
 
Example #11
Source File: ETHMnemonic.java    From Upchain-wallet with GNU Affero General Public License v3.0 6 votes vote down vote up
public static EthHDWallet generateMnemonic(String path, String password) {
    if (!path.startsWith("m") && !path.startsWith("M")) {
        //参数非法
        return null;
    }
    String[] pathArray = path.split("/");
    if (pathArray.length <= 1) {
        //内容不对
        return null;
    }

    if (password.length() < 8) {
        //密码过短
        return null;
    }

    String passphrase = "";
    long creationTimeSeconds = System.currentTimeMillis() / 1000;
    DeterministicSeed ds = new DeterministicSeed(secureRandom, 128, passphrase, creationTimeSeconds);
    return createEthWallet(ds, pathArray, password);
}
 
Example #12
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 6 votes vote down vote up
public void restoreFromBlock0(String mnemonicCode, Runnable callback) {
    if (mnemonicCode.charAt(mnemonicCode.length() - 1) == ' ') {
        mnemonicCode = mnemonicCode.substring(0, mnemonicCode.length() - 1);
    }

    DeterministicSeed seed = new DeterministicSeed(Splitter.on(' ').splitToList(mnemonicCode), null, "", 0);

    wallet = Wallet.fromSeed(params, seed);
    mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode());
    //sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey));
    walletFriendlyAddress = wallet.currentReceiveAddress().toString();
    callback.run();

    RequestorBtc.getUTXOListBtgNew(wallet.currentReceiveAddress().toString(), new ApiMethods.RequestListener() {
        @Override
        public void onSuccess(Object response) {
            List<UTXOItem> utxos = (List<UTXOItem>)response;
            setUTXO(utxos);
        }

        @Override
        public void onFailure(String msg) {

        }
    });
}
 
Example #13
Source File: Main.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
public void setupWalletKit(@Nullable DeterministicSeed seed) {
    // If seed is non-null it means we are restoring from backup.
    bitcoin = new WalletAppKit(params, new File("."), WALLET_FILE_NAME) {
        @Override
        protected void onSetupCompleted() {
            // Don't make the user wait for confirmations for now, as the intention is they're sending it
            // their own money!
            bitcoin.wallet().allowSpendingUnconfirmedTransactions();
            Platform.runLater(controller::onBitcoinSetup);
        }
    };
    // Now configure and start the appkit. This will take a second or two - we could show a temporary splash screen
    // or progress widget to keep the user engaged whilst we initialise, but we don't.
    if (params == RegTestParams.get()) {
        bitcoin.connectToLocalHost();   // You should run a regtest mode bitcoind locally.
    }
    bitcoin.setDownloadListener(controller.progressBarUpdater())
           .setBlockingStartup(false)
           .setUserAgent(APP_NAME, "1.0");
    if (seed != null)
        bitcoin.restoreWalletFromSeed(seed);
}
 
Example #14
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 6 votes vote down vote up
public void restoreFromBlock0(String mnemonicCode, Runnable callback) {
    if (mnemonicCode.charAt(mnemonicCode.length() - 1) == ' ') {
        mnemonicCode = mnemonicCode.substring(0, mnemonicCode.length() - 1);
    }

    DeterministicSeed seed = new DeterministicSeed(Splitter.on(' ').splitToList(mnemonicCode), null, "", 0);

    wallet = Wallet.fromSeed(params, seed);
    mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode());
    //sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey));
    walletFriendlyAddress = wallet.currentReceiveAddress().toString();
    callback.run();

    RequestorBtc.getUTXOListLtcNew(wallet.currentReceiveAddress().toString(), new ApiMethods.RequestListener() {
        @Override
        public void onSuccess(Object response) {
            List<UTXOItem> utxos = (List<UTXOItem>)response;
            setUTXO(utxos);
        }

        @Override
        public void onFailure(String msg) {

        }
    });
}
 
Example #15
Source File: Main.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
public void setupWalletKit(@Nullable DeterministicSeed seed) {
    // If seed is non-null it means we are restoring from backup.
    bitcoin = new WalletAppKit(params, new File("."), WALLET_FILE_NAME) {
        @Override
        protected void onSetupCompleted() {
            // Don't make the user wait for confirmations for now, as the intention is they're sending it
            // their own money!
            bitcoin.wallet().allowSpendingUnconfirmedTransactions();
            Platform.runLater(controller::onBitcoinSetup);
        }
    };
    // Now configure and start the appkit. This will take a second or two - we could show a temporary splash screen
    // or progress widget to keep the user engaged whilst we initialise, but we don't.
    if (params == RegTestParams.get()) {
        bitcoin.connectToLocalHost();   // You should run a regtest mode bitcoind locally.
    }
    bitcoin.setDownloadListener(controller.progressBarUpdater())
           .setBlockingStartup(false)
           .setUserAgent(APP_NAME, "1.0");
    if (seed != null)
        bitcoin.restoreWalletFromSeed(seed);
}
 
Example #16
Source File: Main.java    From thundernetwork with GNU Affero General Public License v3.0 6 votes vote down vote up
public void setupWalletKit (@Nullable DeterministicSeed seed) {
    // If seed is non-null it means we are restoring from backup.
    bitcoin = new WalletAppKit(params, new File("."), APP_NAME + "-" + params.getPaymentProtocolId() + CLIENTID) {
        @Override
        protected void onSetupCompleted () {
            // Don't make the user wait for confirmations for now, as the intention is they're sending it
            // their own money!
            bitcoin.wallet().allowSpendingUnconfirmedTransactions();
            Platform.runLater(controller::onBitcoinSetup);

        }
    };

    bitcoin.setDownloadListener(controller.progressBarUpdater())
            .setBlockingStartup(false)
            .setUserAgent(APP_NAME, "1.0");
    if (seed != null) {
        bitcoin.restoreWalletFromSeed(seed);
    }

}
 
Example #17
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 6 votes vote down vote up
public void createWallet2(String passphrase, Runnable callback) {

        wallet = new Wallet(params);
        DeterministicSeed seed = wallet.getKeyChainSeed();
        mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode());
        sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey));

        walletFriendlyAddress = wallet.currentReceiveAddress().toString();

        ChildNumber childNumber = new ChildNumber(ChildNumber.HARDENED_BIT);
        DeterministicKey de = wallet.getKeyByPath(ImmutableList.of(childNumber));
        xprvKey = de.serializePrivB58(params);

        wifKey = wallet.currentReceiveKey().getPrivateKeyAsWiF(params);

        callback.run();
    }
 
Example #18
Source File: WalletSettingsController.java    From devcoretalk with GNU General Public License v2.0 5 votes vote down vote up
public void restoreClicked(ActionEvent event) {
    // Don't allow a restore unless this wallet is presently empty. We don't want to end up with two wallets, too
    // much complexity, even though WalletAppKit will keep the current one as a backup file in case of disaster.
    if (Main.bitcoin.wallet().getBalance().value > 0) {
        informationalAlert("Wallet is not empty",
                "You must empty this wallet out before attempting to restore an older one, as mixing wallets " +
                        "together can lead to invalidated backups.");
        return;
    }

    if (aesKey != null) {
        // This is weak. We should encrypt the new seed here.
        informationalAlert("Wallet is encrypted",
                "After restore, the wallet will no longer be encrypted and you must set a new password.");
    }

    log.info("Attempting wallet restore using seed '{}' from date {}", wordsArea.getText(), datePicker.getValue());
    informationalAlert("Wallet restore in progress",
            "Your wallet will now be resynced from the Bitcoin network. This can take a long time for old wallets.");
    overlayUI.done();
    Main.instance.controller.restoreFromSeedAnimation();

    long birthday = datePicker.getValue().atStartOfDay().toEpochSecond(ZoneOffset.UTC);
    DeterministicSeed seed = new DeterministicSeed(Splitter.on(' ').splitToList(wordsArea.getText()), null, "", birthday);
    // Shut down bitcoinj and restart it with the new seed.
    Main.bitcoin.addListener(new Service.Listener() {
        @Override
        public void terminated(Service.State from) {
            Main.instance.setupWalletKit(seed);
            Main.bitcoin.startAsync();
        }
    }, Platform::runLater);
    Main.bitcoin.stopAsync();
}
 
Example #19
Source File: WalletPasswordWindow.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void doRestore() {
    final LocalDate value = datePicker.getValue();
    //TODO Is ZoneOffset correct?
    long date = value != null ? value.atStartOfDay().toEpochSecond(ZoneOffset.UTC) : 0;
    DeterministicSeed seed = new DeterministicSeed(Splitter.on(" ").splitToList(seedWordsTextArea.getText()), null, "", date);
    GUIUtil.restoreSeedWords(seed, walletsManager, storageDir);
}
 
Example #20
Source File: WalletSettingsController.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
public void restoreClicked(ActionEvent event) {
    // Don't allow a restore unless this wallet is presently empty. We don't want to end up with two wallets, too
    // much complexity, even though WalletAppKit will keep the current one as a backup file in case of disaster.
    if (Main.bitcoin.wallet().getBalance().value > 0) {
        informationalAlert("Wallet is not empty",
                "You must empty this wallet out before attempting to restore an older one, as mixing wallets " +
                        "together can lead to invalidated backups.");
        return;
    }

    if (aesKey != null) {
        // This is weak. We should encrypt the new seed here.
        informationalAlert("Wallet is encrypted",
                "After restore, the wallet will no longer be encrypted and you must set a new password.");
    }

    log.info("Attempting wallet restore using seed '{}' from date {}", wordsArea.getText(), datePicker.getValue());
    informationalAlert("Wallet restore in progress",
            "Your wallet will now be resynced from the Bitcoin network. This can take a long time for old wallets.");
    overlayUI.done();
    Main.instance.controller.restoreFromSeedAnimation();

    long birthday = datePicker.getValue().atStartOfDay().toEpochSecond(ZoneOffset.UTC);
    DeterministicSeed seed = new DeterministicSeed(Splitter.on(' ').splitToList(wordsArea.getText()), null, "", birthday);
    // Shut down bitcoinj and restart it with the new seed.
    Main.bitcoin.addListener(new Service.Listener() {
        @Override
        public void terminated(Service.State from) {
            Main.instance.setupWalletKit(seed);
            Main.bitcoin.startAsync();
        }
    }, Platform::runLater);
    Main.bitcoin.stopAsync();
}
 
Example #21
Source File: BackupToMnemonicSeed.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) {

        NetworkParameters params = TestNet3Params.get();
        Wallet wallet = new Wallet(params);

        DeterministicSeed seed = wallet.getKeyChainSeed();
        System.out.println("seed: " + seed.toString());

        System.out.println("creation time: " + seed.getCreationTimeSeconds());
        System.out.println("mnemonicCode: " + Utils.join(seed.getMnemonicCode()));
    }
 
Example #22
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
public void createWallet2(String passphrase, Runnable callback) {

        wallet = new Wallet(params);
        DeterministicSeed seed = wallet.getKeyChainSeed();

        mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode());
        sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey));

        walletFriendlyAddress = wallet.currentReceiveAddress().toString();
        callback.run();
    }
 
Example #23
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
public void restoreFromBlock2(String mnemonicCode, Runnable callback) {
    if (mnemonicCode.charAt(mnemonicCode.length() - 1) == ' ') {
        mnemonicCode = mnemonicCode.substring(0, mnemonicCode.length() - 1);
    }

    DeterministicSeed seed = new DeterministicSeed(Splitter.on(' ').splitToList(mnemonicCode), null, "", 0);

    wallet = Wallet.fromSeed(params, seed);
    mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode());
    sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey));

    walletFriendlyAddress = wallet.currentReceiveAddress().toString();

    ChildNumber childNumber = new ChildNumber(ChildNumber.HARDENED_BIT);
    DeterministicKey de = wallet.getKeyByPath(ImmutableList.of(childNumber));
    xprvKey = de.serializePrivB58(params);

    wifKey = wallet.currentReceiveKey().getPrivateKeyAsWiF(params);

    callback.run();


    RequestorBtc.getUTXOListBch(wallet.currentReceiveAddress().toString(), new ApiMethods.RequestListener() {
        @Override
        public void onSuccess(Object response) {
            List<UTXOItem> utxos = (List<UTXOItem>)response;
            setUTXO(utxos);
        }

        @Override
        public void onFailure(String msg) {

        }
    });
}
 
Example #24
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
public void restoreFromBlock(String mnemonicCode, WalletCreationCallback callback) {
    mnemonicCode = mnemonicCode.trim();
    if (mnemonicCode.equals("")) {
        callback.onWalletCreated(null);
        return;
    }

    DeterministicSeed seed = new DeterministicSeed(Splitter.on(' ').splitToList(mnemonicCode), null, "", 0);

    wallet = Wallet.fromSeed(params, seed);
    mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode());
    //sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey));

    walletFriendlyAddress = wallet.currentReceiveAddress().toString();

    ChildNumber childNumber = new ChildNumber(ChildNumber.HARDENED_BIT);
    DeterministicKey de = wallet.getKeyByPath(ImmutableList.of(childNumber));
    xprvKey = de.serializePrivB58(params);

    wifKey = wallet.currentReceiveKey().getPrivateKeyAsWiF(params);

    callback.onWalletCreated(wallet);


    RequestorBtc.getUTXOListBch(wallet.currentReceiveAddress().toString(), new ApiMethods.RequestListener() {
        @Override
        public void onSuccess(Object response) {
            List<UTXOItem> utxos = (List<UTXOItem>)response;
            setUTXO(utxos);
        }

        @Override
        public void onFailure(String msg) {

        }
    });
}
 
Example #25
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
public void restoreFromBlock(String mnemonicCode, WalletCreationCallback callback) {
    mnemonicCode = mnemonicCode.trim();
    if (mnemonicCode.equals("")) {
        callback.onWalletCreated(null);
        return;
    }

    DeterministicSeed seed = new DeterministicSeed(Splitter.on(' ').splitToList(mnemonicCode), null, "", 0);

    wallet = Wallet.fromSeed(params, seed);
    mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode());
    //sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey));
    walletFriendlyAddress = wallet.currentReceiveAddress().toString();

    ChildNumber childNumber = new ChildNumber(ChildNumber.HARDENED_BIT);
    DeterministicKey de = wallet.getKeyByPath(ImmutableList.of(childNumber));
    xprvKey = de.serializePrivB58(params);

    wifKey = wallet.currentReceiveKey().getPrivateKeyAsWiF(params);

    callback.onWalletCreated(wallet);

    RequestorBtc.getUTXOListBtgNew(wallet.currentReceiveAddress().toString(), new ApiMethods.RequestListener() {
        @Override
        public void onSuccess(Object response) {
            List<UTXOItem> utxos = (List<UTXOItem>)response;
            setUTXO(utxos);
        }

        @Override
        public void onFailure(String msg) {

        }
    });
}
 
Example #26
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
public void restoreFromBlock2(String mnemonicCode, Runnable callback) {
    if (mnemonicCode.charAt(mnemonicCode.length() - 1) == ' ') {
        mnemonicCode = mnemonicCode.substring(0, mnemonicCode.length() - 1);
    }

    DeterministicSeed seed = new DeterministicSeed(Splitter.on(' ').splitToList(mnemonicCode), null, "", 0);

    wallet = Wallet.fromSeed(params, seed);
    mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode());
    sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey));

    walletFriendlyAddress = wallet.currentReceiveAddress().toString();

    ChildNumber childNumber = new ChildNumber(ChildNumber.HARDENED_BIT);
    DeterministicKey de = wallet.getKeyByPath(ImmutableList.of(childNumber));
    xprvKey = de.serializePrivB58(params);

    wifKey = wallet.currentReceiveKey().getPrivateKeyAsWiF(params);

    callback.run();


    RequestorBtc.getUTXOList(wallet.currentReceiveAddress().toString(), new ApiMethods.RequestListener() {
        @Override
        public void onSuccess(Object response) {
            UTXOListResponse utxoResponse = (UTXOListResponse) response;
            setUTXO(utxoResponse.getUTXOList());
        }

        @Override
        public void onFailure(String msg) {

        }
    });
}
 
Example #27
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
public void restoreFromBlock0(String mnemonicCode, Runnable callback) {
    if (mnemonicCode.charAt(mnemonicCode.length() - 1) == ' ') {
        mnemonicCode = mnemonicCode.substring(0, mnemonicCode.length() - 1);
    }

    DeterministicSeed seed = new DeterministicSeed(Splitter.on(' ').splitToList(mnemonicCode), null, "", 0);

    wallet = Wallet.fromSeed(params, seed);
    mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode());
    //sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey));

    walletFriendlyAddress = wallet.currentReceiveAddress().toString();

    callback.run();


    RequestorBtc.getUTXOList(wallet.currentReceiveAddress().toString(), new ApiMethods.RequestListener() {
        @Override
        public void onSuccess(Object response) {
            UTXOListResponse utxoResponse = (UTXOListResponse) response;
            setUTXO(utxoResponse.getUTXOList());
        }

        @Override
        public void onFailure(String msg) {

        }
    });
}
 
Example #28
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
public void restoreFromBlock(String mnemonicCode, WalletCreationCallback callback) {
    mnemonicCode = mnemonicCode.trim();
    if (mnemonicCode.equals("")) {
        callback.onWalletCreated(null);
        return;
    }

    DeterministicSeed seed = new DeterministicSeed(Splitter.on(' ').splitToList(mnemonicCode), null, "", 0);

    wallet = Wallet.fromSeed(params, seed);
    mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode());
    //sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey));

    walletFriendlyAddress = wallet.currentReceiveAddress().toString();

    ChildNumber childNumber = new ChildNumber(ChildNumber.HARDENED_BIT);
    DeterministicKey de = wallet.getKeyByPath(ImmutableList.of(childNumber));
    xprvKey = de.serializePrivB58(params);

    wifKey = wallet.currentReceiveKey().getPrivateKeyAsWiF(params);

    callback.onWalletCreated(wallet);


    RequestorBtc.getUTXOList(wallet.currentReceiveAddress().toString(), new ApiMethods.RequestListener() {
        @Override
        public void onSuccess(Object response) {
            UTXOListResponse utxoResponse = (UTXOListResponse) response;
            setUTXO(utxoResponse.getUTXOList());
        }

        @Override
        public void onFailure(String msg) {

        }
    });
}
 
Example #29
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
public void restoreFromBlock2(String mnemonicCode, Runnable callback) {
    if (mnemonicCode.charAt(mnemonicCode.length() - 1) == ' ') {
        mnemonicCode = mnemonicCode.substring(0, mnemonicCode.length() - 1);
    }

    DeterministicSeed seed = new DeterministicSeed(Splitter.on(' ').splitToList(mnemonicCode), null, "", 0);

    wallet = Wallet.fromSeed(params, seed);
    mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode());
    sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey));
    walletFriendlyAddress = wallet.currentReceiveAddress().toString();

    ChildNumber childNumber = new ChildNumber(ChildNumber.HARDENED_BIT);
    DeterministicKey de = wallet.getKeyByPath(ImmutableList.of(childNumber));
    xprvKey = de.serializePrivB58(params);

    wifKey = wallet.currentReceiveKey().getPrivateKeyAsWiF(params);

    callback.run();

    RequestorBtc.getUTXOListBtgNew(wallet.currentReceiveAddress().toString(), new ApiMethods.RequestListener() {
        @Override
        public void onSuccess(Object response) {
            List<UTXOItem> utxos = (List<UTXOItem>)response;
            setUTXO(utxos);
        }

        @Override
        public void onFailure(String msg) {

        }
    });
}
 
Example #30
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
public void restoreFromBlock0(String mnemonicCode, Runnable callback) {
    if (mnemonicCode.charAt(mnemonicCode.length() - 1) == ' ') {
        mnemonicCode = mnemonicCode.substring(0, mnemonicCode.length() - 1);
    }

    DeterministicSeed seed = new DeterministicSeed(Splitter.on(' ').splitToList(mnemonicCode), null, "", 0);

    wallet = Wallet.fromSeed(params, seed);
    mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode());
    //sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey));

    updateWalletFriendlyAddress();

    callback.run();


    RequestorBtc.getUTXOListQtum(walletFriendlyAddress, new ApiMethods.RequestListener() {
        @Override
        public void onSuccess(Object response) {
            List<UTXOItem> utxos = (List<UTXOItem>)response;
            setUTXO(utxos);
        }

        @Override
        public void onFailure(String msg) {

        }
    });
}