From e6fce14fde86435e50b90a3922261d984df7c320 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 19 Jul 2021 11:56:02 +0200 Subject: [PATCH] handle unknown derivation path for unchained caravan key --- .../com/sparrowwallet/sparrow/io/CaravanMultisig.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/io/CaravanMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/CaravanMultisig.java index 79acad0a..113232ce 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/CaravanMultisig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/CaravanMultisig.java @@ -50,10 +50,16 @@ public class CaravanMultisig implements WalletImport, WalletExport { Wallet wallet = new Wallet(); wallet.setName(cf.name); wallet.setPolicyType(PolicyType.MULTI); + ScriptType scriptType = ScriptType.valueOf(cf.addressType); for(ExtPublicKey extKey : cf.extendedPublicKeys) { Keystore keystore = new Keystore(extKey.name); - keystore.setKeyDerivation(new KeyDerivation(extKey.xfp, extKey.bip32Path)); + try { + keystore.setKeyDerivation(new KeyDerivation(extKey.xfp, extKey.bip32Path)); + } catch(NumberFormatException e) { + keystore.setKeyDerivation(new KeyDerivation(extKey.xfp, scriptType.getDefaultDerivationPath())); + } + keystore.setExtendedPublicKey(ExtendedKey.fromDescriptor(extKey.xpub)); WalletModel walletModel = WalletModel.fromType(extKey.method); @@ -67,7 +73,6 @@ public class CaravanMultisig implements WalletImport, WalletExport { wallet.getKeystores().add(keystore); } - ScriptType scriptType = ScriptType.valueOf(cf.addressType); wallet.setScriptType(scriptType); wallet.setDefaultPolicy(Policy.getPolicy(PolicyType.MULTI, scriptType, wallet.getKeystores(), cf.quorum.requiredSigners));