From 04cb27f85e86c7d8c0ec03fca233a4d05e8ff0c1 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 17 Mar 2022 09:45:51 +0200 Subject: [PATCH] label invalid notification transactions and avoid relink attempts --- drongo | 2 +- .../com/sparrowwallet/sparrow/paynym/PayNymController.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drongo b/drongo index 04631be8..64017615 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 04631be8c10bf0ef72ebd7f7ef26254cccecb282 +Subproject commit 640176153016e6b38b367d6d7e37ecf15cfee745 diff --git a/src/main/java/com/sparrowwallet/sparrow/paynym/PayNymController.java b/src/main/java/com/sparrowwallet/sparrow/paynym/PayNymController.java index 37d77ea1..98657a2c 100644 --- a/src/main/java/com/sparrowwallet/sparrow/paynym/PayNymController.java +++ b/src/main/java/com/sparrowwallet/sparrow/paynym/PayNymController.java @@ -43,6 +43,7 @@ public class PayNymController { private static final Logger log = LoggerFactory.getLogger(PayNymController.class); public static final Pattern PAYNYM_REGEX = Pattern.compile("\\+[a-z]+[0-9][0-9a-fA-F][0-9a-fA-F]"); + public static final String INVALID_PAYMENT_CODE_LABEL = "Invalid Payment Code"; private String walletId; private boolean selectLinkedOnly; @@ -344,7 +345,7 @@ public class PayNymController { if(!isLinked(payNym)) { PaymentCode externalPaymentCode = payNym.paymentCode(); Map unlinkedNotification = getMasterWallet().getNotificationTransaction(externalPaymentCode); - if(!unlinkedNotification.isEmpty()) { + if(!unlinkedNotification.isEmpty() && !INVALID_PAYMENT_CODE_LABEL.equals(unlinkedNotification.keySet().iterator().next().getLabel())) { unlinkedNotifications.putAll(unlinkedNotification); unlinkedPayNyms.put(unlinkedNotification.keySet().iterator().next(), payNym); } @@ -397,6 +398,9 @@ public class PayNymController { byte[] opReturnData = PaymentCode.getOpReturnData(blockTransaction.getTransaction()); if(Arrays.equals(opReturnData, blindedPaymentCode)) { addedWallets.addAll(addChildWallets(payNym, externalPaymentCode)); + } else { + blockTransaction.setLabel(INVALID_PAYMENT_CODE_LABEL); + EventManager.get().post(new WalletEntryLabelsChangedEvent(input0Node.getWallet(), new TransactionEntry(input0Node.getWallet(), blockTransaction, Collections.emptyMap(), Collections.emptyMap()))); } } catch(Exception e) { log.error("Error adding linked contact from notification transaction", e);