diff --git a/drongo b/drongo index c1f6a124..08328806 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit c1f6a1245e4632deb19af64faaa6ffaaca475313 +Subproject commit 083288061ffe6e08805bb58108a9afab0d93fb0f diff --git a/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java index 4f2566a8..aad47cf6 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java @@ -160,6 +160,13 @@ public abstract class FileImportPane extends TitledDescriptionPane { } catch(ImportException e) { setError("Import Error", e.getMessage()); } + } else if(result.outputDescriptor != null) { + wallets = List.of(result.outputDescriptor.toKeystoreWallet(null)); + try { + importFile(importer.getName(), null, null); + } catch(ImportException e) { + setError("Import Error", e.getMessage()); + } } else if(result.payload != null) { try { importFile(importer.getName(), new ByteArrayInputStream(result.payload.getBytes(StandardCharsets.UTF_8)), null); @@ -177,6 +184,9 @@ public abstract class FileImportPane extends TitledDescriptionPane { } else if(result.exception != null) { log.error("Error importing QR", result.exception); setError("Import Error", result.exception.getMessage()); + } else { + setError("Import Error", null); + setExpanded(true); } } } diff --git a/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java index 4235aae3..f61a0820 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java @@ -481,19 +481,8 @@ public class QRScanDialog extends Dialog { List wallets = new ArrayList<>(); String masterFingerprint = Utils.bytesToHex(cryptoAccount.getMasterFingerprint()); for(CryptoOutput cryptoOutput : cryptoAccount.getOutputDescriptors()) { - Wallet wallet = new Wallet(); OutputDescriptor outputDescriptor = getOutputDescriptor(cryptoOutput); - if(outputDescriptor.isMultisig()) { - throw new IllegalStateException("Multisig output descriptors are unsupported in CryptoAccount"); - } - - ExtendedKey extendedKey = outputDescriptor.getSingletonExtendedPublicKey(); - wallet.setScriptType(outputDescriptor.getScriptType()); - Keystore keystore = new Keystore(); - keystore.setKeyDerivation(new KeyDerivation(masterFingerprint, KeyDerivation.writePath(outputDescriptor.getKeyDerivation(extendedKey).getDerivation()))); - keystore.setExtendedPublicKey(extendedKey); - wallet.getKeystores().add(keystore); - wallet.setDefaultPolicy(Policy.getPolicy(outputDescriptor.isCosigner() ? PolicyType.MULTI : PolicyType.SINGLE, wallet.getScriptType(), wallet.getKeystores(), 1)); + Wallet wallet = outputDescriptor.toKeystoreWallet(masterFingerprint); wallets.add(wallet); } diff --git a/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java index c3959491..0a24f392 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/WalletImportDialog.java @@ -48,7 +48,7 @@ public class WalletImportDialog extends Dialog { AnchorPane.setRightAnchor(scrollPane, 0.0); importAccordion = new Accordion(); - List keystoreImporters = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new KeystoneSinglesig(), new PassportSinglesig(), new SeedTool(), new SpecterDIY()); + List keystoreImporters = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new KeystoneSinglesig(), new PassportSinglesig(), new GordianSeedTool(), new SpecterDIY()); for(KeystoreFileImport importer : keystoreImporters) { FileWalletKeystoreImportPane importPane = new FileWalletKeystoreImportPane(importer); importAccordion.getPanes().add(importPane); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/SeedTool.java b/src/main/java/com/sparrowwallet/sparrow/io/GordianSeedTool.java similarity index 73% rename from src/main/java/com/sparrowwallet/sparrow/io/SeedTool.java rename to src/main/java/com/sparrowwallet/sparrow/io/GordianSeedTool.java index bc865e73..4f51cff7 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/SeedTool.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/GordianSeedTool.java @@ -1,5 +1,6 @@ package com.sparrowwallet.sparrow.io; +import com.sparrowwallet.drongo.Network; import com.sparrowwallet.drongo.protocol.ScriptType; import com.sparrowwallet.drongo.wallet.Keystore; import com.sparrowwallet.drongo.wallet.WalletModel; @@ -7,7 +8,7 @@ import com.sparrowwallet.drongo.wallet.WalletModel; import java.io.File; import java.io.InputStream; -public class SeedTool implements KeystoreFileImport { +public class GordianSeedTool implements KeystoreFileImport { @Override public boolean isEncrypted(File file) { return false; @@ -15,12 +16,12 @@ public class SeedTool implements KeystoreFileImport { @Override public String getName() { - return "Seed Tool"; + return "Gordian Seed Tool"; } @Override public WalletModel getWalletModel() { - return WalletModel.SEED_TOOL; + return WalletModel.GORDIAN_SEED_TOOL; } @Override @@ -35,7 +36,7 @@ public class SeedTool implements KeystoreFileImport { @Override public String getKeystoreImportDescription() { - return "Select your seed and scan the QR code created by Authenticate > Derive Key > Other Key Derivations > Account Descriptor. Click the share icon at the bottom to show the QR."; + return "Select your seed and scan the QR code created by Authenticate > Derive Key > Other Key Derivations > " + Network.get().toDisplayString() + " > Master Key > Account Descriptor. Click the share icon at the bottom."; } @Override diff --git a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java index c6bf736e..3959b875 100644 --- a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java +++ b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java @@ -18,9 +18,9 @@ public class HwAirgappedController extends KeystoreImportDetailController { public void initializeView() { List importers = Collections.emptyList(); if(getMasterController().getWallet().getPolicyType().equals(PolicyType.SINGLE)) { - importers = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new KeystoneSinglesig(), new PassportSinglesig(), new SeedSigner(), new SeedTool(), new SpecterDIY()); + importers = List.of(new ColdcardSinglesig(), new CoboVaultSinglesig(), new KeystoneSinglesig(), new PassportSinglesig(), new SeedSigner(), new GordianSeedTool(), new SpecterDIY()); } else if(getMasterController().getWallet().getPolicyType().equals(PolicyType.MULTI)) { - importers = List.of(new ColdcardMultisig(), new CoboVaultMultisig(), new KeystoneMultisig(), new PassportMultisig(), new SeedSigner(), new SeedTool(), new SpecterDIY()); + importers = List.of(new ColdcardMultisig(), new CoboVaultMultisig(), new KeystoneMultisig(), new PassportMultisig(), new SeedSigner(), new GordianSeedTool(), new SpecterDIY()); } for(KeystoreFileImport importer : importers) {