From 04917c45b6e7c59c67743faffa88e49758ec3c83 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 25 Jul 2022 14:47:08 +0200 Subject: [PATCH] disallow duplicate xpubs in multisig wallet keystores --- drongo | 2 +- .../com/sparrowwallet/sparrow/wallet/KeystoreController.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drongo b/drongo index b2f5f5ff..8a6d2da5 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit b2f5f5ffebfc0ce9f0d992f3ac3b59965661491b +Subproject commit 8a6d2da5c911b3f63426c9e5331c55a36c27befc diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java index 73b768c9..b240a9f2 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java @@ -238,7 +238,9 @@ public class KeystoreController extends WalletFormController implements Initiali validationSupport.registerValidator(xpub, Validator.combine( Validator.createEmptyValidator(Network.get().getXpubHeader().getDisplayName() + " is required"), - (Control c, String newValue) -> ValidationResult.fromErrorIf( c, Network.get().getXpubHeader().getDisplayName() + " is invalid", !ExtendedKey.isValid(newValue)) + (Control c, String newValue) -> ValidationResult.fromErrorIf( c, Network.get().getXpubHeader().getDisplayName() + " is invalid", !ExtendedKey.isValid(newValue)), + (Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Extended key is not unique", ExtendedKey.isValid(newValue) && + walletForm.getWallet().getKeystores().stream().filter(k -> k != keystore && k.getExtendedPublicKey() != null).map(Keystore::getExtendedPublicKey).collect(Collectors.toList()).contains(ExtendedKey.fromDescriptor(newValue))) )); validationSupport.registerValidator(derivation, Validator.combine(