From e50fe4c68cd0ce0b9a987b4adbc05c09bb942810 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 30 Sep 2024 11:31:55 +0200 Subject: [PATCH] switch from paynym.is to paynym.rs and tor equivalents, update child wallet labels on displaying paynym dialog --- .../sparrowwallet/sparrow/control/PayNymAvatar.java | 2 +- .../sparrow/paynym/PayNymController.java | 12 +++++++++--- .../sparrowwallet/sparrow/paynym/PayNymService.java | 5 ++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/PayNymAvatar.java b/src/main/java/com/sparrowwallet/sparrow/control/PayNymAvatar.java index ae9a796a..66ac32b6 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/PayNymAvatar.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/PayNymAvatar.java @@ -125,7 +125,7 @@ public class PayNymAvatar extends StackPane { } try(InputStream is = (proxy == null ? new URI(url).toURL().openStream() : new URI(url).toURL().openConnection(proxy).getInputStream())) { - Image image = new Image(is, 150, 150, true, false); + Image image = new Image(is, 150, 150, true, true); paymentCodeCache.put(cacheId, image); Platform.runLater(() -> EventManager.get().post(new PayNymImageLoadedEvent(paymentCode, image))); return image; diff --git a/src/main/java/com/sparrowwallet/sparrow/paynym/PayNymController.java b/src/main/java/com/sparrowwallet/sparrow/paynym/PayNymController.java index b5c35e91..c8ed7b23 100644 --- a/src/main/java/com/sparrowwallet/sparrow/paynym/PayNymController.java +++ b/src/main/java/com/sparrowwallet/sparrow/paynym/PayNymController.java @@ -42,7 +42,8 @@ import static com.sparrowwallet.sparrow.wallet.PaymentController.MINIMUM_P2PKH_O 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 Pattern SAMOURAI_PAYNYM_REGEX = Pattern.compile("\\+[a-z]+[0-9][0-9a-fA-F][0-9a-fA-F]"); + public static final Pattern ASHIGARU_PAYNYM_REGEX = Pattern.compile("\\+[a-z]+[0-9][0-9]"); public static final String INVALID_PAYMENT_CODE_LABEL = "Invalid Payment Code"; private String walletId; @@ -127,7 +128,7 @@ public class PayNymController { } catch(Exception e) { //ignore } - } else if(PAYNYM_REGEX.matcher(input).matches()) { + } else if(ASHIGARU_PAYNYM_REGEX.matcher(input).matches()) { findNymProperty.set(input); } else { findNymProperty.set(null); @@ -343,7 +344,12 @@ public class PayNymController { PaymentCode externalPaymentCode = childWallet.getKeystores().get(0).getExternalPaymentCode(); String walletNymName = PayNym.getNymName(childWallet); if(payNymMap.get(externalPaymentCode) == null || (walletNymName != null && !walletNymName.equals(payNymMap.get(externalPaymentCode).nymName()))) { - payNymMap.put(externalPaymentCode, PayNym.fromWallet(childWallet)); + if(walletNymName != null && payNymMap.get(externalPaymentCode) != null && SAMOURAI_PAYNYM_REGEX.matcher(walletNymName).matches()) { + childWallet.setLabel(payNymMap.get(externalPaymentCode).nymName() + " " + childWallet.getScriptType().getName()); + EventManager.get().post(new WalletLabelChangedEvent(childWallet)); + } else { + payNymMap.put(externalPaymentCode, PayNym.fromWallet(childWallet)); + } } } } diff --git a/src/main/java/com/sparrowwallet/sparrow/paynym/PayNymService.java b/src/main/java/com/sparrowwallet/sparrow/paynym/PayNymService.java index 01014e61..ddd69b15 100644 --- a/src/main/java/com/sparrowwallet/sparrow/paynym/PayNymService.java +++ b/src/main/java/com/sparrowwallet/sparrow/paynym/PayNymService.java @@ -251,6 +251,9 @@ public class PayNymService { } public static String getHostUrl(boolean tor) { - return tor ? "http://paynym7bwekdtb2hzgkpl6y2waqcrs2dii7lwincvxme7mdpcpxzfsad.onion" : "https://paynym.is"; + //Samourai PayNym server + //return tor ? "http://paynym7bwekdtb2hzgkpl6y2waqcrs2dii7lwincvxme7mdpcpxzfsad.onion" : "https://paynym.is"; + //Ashigaru PayNym server + return tor ? "http://paynym25chftmsywv4v2r67agbrr62lcxagsf4tymbzpeeucucy2ivad.onion" : "https://paynym.rs"; } }