From 1224abcd1d1871d1aa013b84df1760830db2d9d6 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 26 Apr 2022 14:34:45 +0200 Subject: [PATCH] truncate keystore labels on caravan import --- .../java/com/sparrowwallet/sparrow/io/CaravanMultisig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/io/CaravanMultisig.java b/src/main/java/com/sparrowwallet/sparrow/io/CaravanMultisig.java index 912d56b7..d8b9b2b5 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/CaravanMultisig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/CaravanMultisig.java @@ -53,7 +53,7 @@ public class CaravanMultisig implements WalletImport, WalletExport { ScriptType scriptType = ScriptType.valueOf(cf.addressType.replace('-', '_')); for(ExtPublicKey extKey : cf.extendedPublicKeys) { - Keystore keystore = new Keystore(extKey.name); + Keystore keystore = new Keystore(extKey.name.length() > Keystore.MAX_LABEL_LENGTH ? extKey.name.substring(0, Keystore.MAX_LABEL_LENGTH) : extKey.name); try { keystore.setKeyDerivation(new KeyDerivation(extKey.xfp, extKey.bip32Path)); } catch(NumberFormatException e) { @@ -70,6 +70,7 @@ public class CaravanMultisig implements WalletImport, WalletExport { keystore.setWalletModel(walletModel); keystore.setSource(KeystoreSource.HW_USB); } + wallet.makeLabelsUnique(keystore); wallet.getKeystores().add(keystore); }