Search in sources :

Example 1 with KeystoreImportDialog

use of com.sparrowwallet.sparrow.keystoreimport.KeystoreImportDialog in project sparrow by sparrowwallet.

the class KeystoreController method launchImportDialog.

private void launchImportDialog(KeystoreSource initialSource) {
    boolean restrictSource = keystoreSourceToggleGroup.getToggles().stream().anyMatch(toggle -> ((ToggleButton) toggle).isDisabled());
    KeyDerivation requiredDerivation = restrictSource ? keystore.getKeyDerivation() : null;
    WalletModel requiredModel = restrictSource ? keystore.getWalletModel() : null;
    KeystoreImportDialog dlg = new KeystoreImportDialog(getWalletForm().getWallet(), initialSource, requiredDerivation, requiredModel, restrictSource);
    Optional<Keystore> result = dlg.showAndWait();
    if (result.isPresent()) {
        selectSourcePane.setVisible(false);
        Keystore importedKeystore = result.get();
        walletForm.getWallet().makeLabelsUnique(importedKeystore);
        keystore.setSource(importedKeystore.getSource());
        keystore.setWalletModel(importedKeystore.getWalletModel());
        keystore.setLabel(importedKeystore.getLabel());
        keystore.setKeyDerivation(importedKeystore.getKeyDerivation());
        keystore.setExtendedPublicKey(importedKeystore.getExtendedPublicKey());
        keystore.setMasterPrivateExtendedKey(importedKeystore.getMasterPrivateExtendedKey());
        keystore.setSeed(importedKeystore.getSeed());
        keystore.setBip47ExtendedPrivateKey(importedKeystore.getBip47ExtendedPrivateKey());
        updateType();
        label.setText(keystore.getLabel());
        fingerprint.setText(keystore.getKeyDerivation().getMasterFingerprint());
        derivation.setText(keystore.getKeyDerivation().getDerivationPath());
        if (keystore.getExtendedPublicKey() != null) {
            xpub.setText(keystore.getExtendedPublicKey().toString());
            setXpubContext(keystore.getExtendedPublicKey());
        } else {
            xpub.setText("");
        }
    }
}
Also used : Keystore(com.sparrowwallet.drongo.wallet.Keystore) WalletModel(com.sparrowwallet.drongo.wallet.WalletModel) KeystoreImportDialog(com.sparrowwallet.sparrow.keystoreimport.KeystoreImportDialog)

Aggregations

Keystore (com.sparrowwallet.drongo.wallet.Keystore)1 WalletModel (com.sparrowwallet.drongo.wallet.WalletModel)1 KeystoreImportDialog (com.sparrowwallet.sparrow.keystoreimport.KeystoreImportDialog)1