/** * Work out which restore method to use, depending on if it is a Trezor wallet or not and what backups there are */ public void calculateRestoreMethod() { Optional<HardwareWalletService> hardwareWalletService = CoreServices.getCurrentHardwareWalletService(); // User has selected restore wallet - see if wallet is hard Trezor wallet // If so no need to enter a seed phrase - use the rootNode from the master public key to work out the wallet id HardwareWalletContext context = hardwareWalletService.get().getContext(); // Create a wallet id from the rootNode to work out the wallet root directory if (context.getDeterministicKey().isPresent()) { walletId = Optional.of(new WalletId(context.getDeterministicKey().get().getIdentifier())); String walletRoot = WalletManager.createWalletRoot(walletId.get()); log.debug("Hardware wallet root : {}", walletRoot); } // Ensure Trezor is cancelled hardwareWalletService.get().requestCancel(); restoreMethod = RESTORE_WALLET_HARD_TREZOR; if (!isLocalZipBackupPresent()) { // Next ask for the cloud backup location state = RESTORE_WALLET_SELECT_BACKUP_LOCATION; } else { // Next select one of the local backups state = RESTORE_WALLET_SELECT_BACKUP; } }
final DeterministicKey parentKey = hardwareWalletContext.getDeterministicKey().get(); log.info("Parent key path: {}", parentKey.getPathAsString());
DeterministicKey parent = context.getDeterministicKey().orNull(); log.debug("Parent key path: {}", parent == null ? "Root" : parent.getPathAsString()); DeterministicKey child = DeterministicKey.deserializeB58(parent, base58Xpub, MainNetParams.get()); context.setDeterministicHierarchy(new DeterministicHierarchy(context.getDeterministicKey().get()));