diff --git a/drongo b/drongo index 0e084782..87b5f992 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 0e084782941f514613a15967c00476e21e038e1d +Subproject commit 87b5f992d085efac64e7466af4906f9d1691fc8a diff --git a/src/main/java/com/sparrowwallet/sparrow/io/CaravanMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/CaravanMultisig.java index 63f0ef98..4fe7b9ce 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/CaravanMultisig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/CaravanMultisig.java @@ -60,7 +60,7 @@ public class CaravanMultisig implements WalletImport, WalletExport { } try { - keystore.setKeyDerivation(new KeyDerivation(extKey.xfp, extKey.bip32Path)); + keystore.setKeyDerivation(new KeyDerivation(extKey.xfp, extKey.bip32Path, true)); } catch(NumberFormatException e) { keystore.setKeyDerivation(new KeyDerivation(extKey.xfp, scriptType.getDefaultDerivationPath())); } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java index a9f36a28..7e302c16 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/CoboVaultSinglesig.java @@ -48,7 +48,7 @@ public class CoboVaultSinglesig implements KeystoreFileImport, WalletImport { keystore.setLabel(getName()); keystore.setSource(KeystoreSource.HW_AIRGAPPED); keystore.setWalletModel(WalletModel.COBO_VAULT); - keystore.setKeyDerivation(new KeyDerivation(coboKeystore.MasterFingerprint.toLowerCase(Locale.ROOT), "m/" + coboKeystore.AccountKeyPath)); + keystore.setKeyDerivation(new KeyDerivation(coboKeystore.MasterFingerprint.toLowerCase(Locale.ROOT), "m/" + coboKeystore.AccountKeyPath, true)); keystore.setExtendedPublicKey(ExtendedKey.fromDescriptor(coboKeystore.ExtPubKey)); ExtendedKey.Header header = ExtendedKey.Header.fromExtendedKey(coboKeystore.ExtPubKey); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java index 11b633d4..c21a75b9 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardMultisig.java @@ -71,16 +71,16 @@ public class ColdcardMultisig implements WalletImport, KeystoreFileImport, Walle if(header.getDefaultScriptType() != scriptType) { throw new ImportException("This wallet's script type (" + scriptType + ") does not match the " + getName() + " script type (" + header.getDefaultScriptType() + ")"); } - keystore.setKeyDerivation(new KeyDerivation(cck.xfp, cck.path)); + keystore.setKeyDerivation(new KeyDerivation(cck.xfp, cck.path, true)); keystore.setExtendedPublicKey(ExtendedKey.fromDescriptor(cck.xpub)); } else if(scriptType.equals(ScriptType.P2SH)) { - keystore.setKeyDerivation(new KeyDerivation(cck.xfp, cck.p2sh_deriv)); + keystore.setKeyDerivation(new KeyDerivation(cck.xfp, cck.p2sh_deriv, true)); keystore.setExtendedPublicKey(ExtendedKey.fromDescriptor(cck.p2sh)); } else if(scriptType.equals(ScriptType.P2SH_P2WSH)) { - keystore.setKeyDerivation(new KeyDerivation(cck.xfp, cck.p2wsh_p2sh_deriv != null ? cck.p2wsh_p2sh_deriv : cck.p2sh_p2wsh_deriv)); + keystore.setKeyDerivation(new KeyDerivation(cck.xfp, cck.p2wsh_p2sh_deriv != null ? cck.p2wsh_p2sh_deriv : cck.p2sh_p2wsh_deriv, true)); keystore.setExtendedPublicKey(ExtendedKey.fromDescriptor(cck.p2wsh_p2sh != null ? cck.p2wsh_p2sh : cck.p2sh_p2wsh)); } else if(scriptType.equals(ScriptType.P2WSH)) { - keystore.setKeyDerivation(new KeyDerivation(cck.xfp, cck.p2wsh_deriv)); + keystore.setKeyDerivation(new KeyDerivation(cck.xfp, cck.p2wsh_deriv, true)); keystore.setExtendedPublicKey(ExtendedKey.fromDescriptor(cck.p2wsh)); } else { throw new ImportException("Correct derivation not found for script type: " + scriptType); @@ -157,7 +157,7 @@ public class ColdcardMultisig implements WalletImport, KeystoreFileImport, Walle Keystore keystore = new Keystore("Coldcard"); keystore.setSource(KeystoreSource.HW_AIRGAPPED); keystore.setWalletModel(WalletModel.COLDCARD); - keystore.setKeyDerivation(new KeyDerivation(key, derivation)); + keystore.setKeyDerivation(new KeyDerivation(key, derivation, true)); keystore.setExtendedPublicKey(ExtendedKey.fromDescriptor(value)); wallet.makeLabelsUnique(keystore); wallet.getKeystores().add(keystore); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java index 7d7a9b41..0c95d335 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ColdcardSinglesig.java @@ -78,7 +78,7 @@ public class ColdcardSinglesig implements KeystoreFileImport, WalletImport { keystore.setLabel(getName()); keystore.setSource(KeystoreSource.HW_AIRGAPPED); keystore.setWalletModel(WalletModel.COLDCARD); - keystore.setKeyDerivation(new KeyDerivation(masterFingerprint, ck.deriv)); + keystore.setKeyDerivation(new KeyDerivation(masterFingerprint, ck.deriv, true)); keystore.setExtendedPublicKey(ExtendedKey.fromDescriptor(ck.xpub)); return keystore; diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java b/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java index 9286769c..a8d995d1 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Electrum.java @@ -186,7 +186,7 @@ public class Electrum implements KeystoreFileImport, WalletImport, WalletExport keystore.setWalletModel(WalletModel.ELECTRUM); } - keystore.setKeyDerivation(new KeyDerivation(masterFingerprint, derivationPath)); + keystore.setKeyDerivation(new KeyDerivation(masterFingerprint, derivationPath, true)); keystore.setExtendedPublicKey(xPub); keystore.setLabel(ek.label != null ? ek.label : "Electrum"); if(keystore.getLabel().length() > Keystore.MAX_LABEL_LENGTH) { diff --git a/src/main/java/com/sparrowwallet/sparrow/io/satochip/SatoCardApi.java b/src/main/java/com/sparrowwallet/sparrow/io/satochip/SatoCardApi.java index 05fb797e..132de40d 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/satochip/SatoCardApi.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/satochip/SatoCardApi.java @@ -142,7 +142,7 @@ public class SatoCardApi extends CardApi { String masterXpub = this.cardProtocol.cardBip32GetXpub("m", xtype); ExtendedKey masterExtendedKey = ExtendedKey.fromDescriptor(masterXpub); String masterFingerprint = Utils.bytesToHex(masterExtendedKey.getKey().getFingerprint()); - KeyDerivation keyDerivation = new KeyDerivation(masterFingerprint, keyDerivationString); + KeyDerivation keyDerivation = new KeyDerivation(masterFingerprint, keyDerivationString, true); Keystore keystore = new Keystore(); keystore.setLabel(WalletModel.SATOCHIP.toDisplayString()); diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletFormController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletFormController.java index 63f519ef..e9cb5059 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletFormController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletFormController.java @@ -41,8 +41,9 @@ public abstract class WalletFormController extends BaseController { protected boolean isSingleDerivationPath() { KeyDerivation firstDerivation = getWalletForm().getWallet().getKeystores().get(0).getKeyDerivation(); + String firstDerivationPath = KeyDerivation.writePath(firstDerivation.getDerivation()); for(Keystore keystore : getWalletForm().getWallet().getKeystores()) { - if(!keystore.getKeyDerivation().getDerivationPath().equals(firstDerivation.getDerivationPath())) { + if(!KeyDerivation.writePath(keystore.getKeyDerivation().getDerivation()).equals(firstDerivationPath)) { return false; } }