add duplicate payment address warning to transaction diagram

This commit is contained in:
Craig Raw 2023-10-12 12:37:41 +02:00
parent a6a671f687
commit 9280504f70
3 changed files with 17 additions and 3 deletions

View file

@ -697,7 +697,8 @@ public class TransactionDiagram extends GridPane {
Wallet toBip47Wallet = getBip47SendWallet(payment); Wallet toBip47Wallet = getBip47SendWallet(payment);
Tooltip recipientTooltip = new Tooltip((toWallet == null ? (toNode != null ? "Consolidate " : "Pay ") : "Receive ") Tooltip recipientTooltip = new Tooltip((toWallet == null ? (toNode != null ? "Consolidate " : "Pay ") : "Receive ")
+ getSatsValue(payment.getAmount()) + " sats to " + getSatsValue(payment.getAmount()) + " sats to "
+ (payment instanceof AdditionalPayment ? (isExpanded() ? "\n" : "(click to expand)\n") + payment : (toWallet == null ? (payment.getLabel() == null ? (toNode != null ? toNode : (toBip47Wallet == null ? "external address" : toBip47Wallet.getDisplayName())) : payment.getLabel()) : toWallet.getFullDisplayName()) + "\n" + payment.getAddress().toString())); + (payment instanceof AdditionalPayment ? (isExpanded() ? "\n" : "(click to expand)\n") + payment : (toWallet == null ? (payment.getLabel() == null ? (toNode != null ? toNode : (toBip47Wallet == null ? "external address" : toBip47Wallet.getDisplayName())) : payment.getLabel()) : toWallet.getFullDisplayName()) + "\n" + payment.getAddress().toString())
+ (isDuplicateAddress(payment) ? " (Duplicate)" : ""));
recipientTooltip.getStyleClass().add("recipient-label"); recipientTooltip.getStyleClass().add("recipient-label");
recipientTooltip.setShowDelay(new Duration(TOOLTIP_SHOW_DELAY)); recipientTooltip.setShowDelay(new Duration(TOOLTIP_SHOW_DELAY));
recipientTooltip.setShowDuration(Duration.INDEFINITE); recipientTooltip.setShowDuration(Duration.INDEFINITE);
@ -990,11 +991,17 @@ public class TransactionDiagram extends GridPane {
return ((AdditionalPayment)payment).getOutputGlyph(this); return ((AdditionalPayment)payment).getOutputGlyph(this);
} else if(getToWallet(payment) != null) { } else if(getToWallet(payment) != null) {
return getDepositGlyph(); return getDepositGlyph();
} else if(isDuplicateAddress(payment)) {
return getPaymentWarningGlyph();
} }
return getPaymentGlyph(); return getPaymentGlyph();
} }
private boolean isDuplicateAddress(Payment payment) {
return walletTx.getPayments().stream().filter(p -> payment != p).anyMatch(p -> payment.getAddress().equals(p.getAddress()));
}
public static Glyph getExcludeGlyph() { public static Glyph getExcludeGlyph() {
Glyph excludeGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.TIMES_CIRCLE); Glyph excludeGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.TIMES_CIRCLE);
excludeGlyph.getStyleClass().add("exclude-utxo"); excludeGlyph.getStyleClass().add("exclude-utxo");
@ -1009,6 +1016,13 @@ public class TransactionDiagram extends GridPane {
return paymentGlyph; return paymentGlyph;
} }
public static Glyph getPaymentWarningGlyph() {
Glyph paymentWarningGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.EXCLAMATION_TRIANGLE);
paymentWarningGlyph.getStyleClass().add("payment-warning-icon");
paymentWarningGlyph.setFontSize(12);
return paymentWarningGlyph;
}
public static Glyph getConsolidationGlyph() { public static Glyph getConsolidationGlyph() {
Glyph consolidationGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.REPLY_ALL); Glyph consolidationGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.REPLY_ALL);
consolidationGlyph.getStyleClass().add("consolidation-icon"); consolidationGlyph.getStyleClass().add("consolidation-icon");

View file

@ -78,7 +78,7 @@
-fx-fill: -fx-text-base-color; -fx-fill: -fx-text-base-color;
} }
#transactionDiagram .change-warning-icon { #transactionDiagram .change-warning-icon, #transactionDiagram .payment-warning-icon {
-fx-text-fill: rgb(238, 210, 2); -fx-text-fill: rgb(238, 210, 2);
} }

View file

@ -109,7 +109,7 @@
-fx-fill: -fx-text-base-color; -fx-fill: -fx-text-base-color;
} }
#transactionDiagram .change-warning-icon { #transactionDiagram .change-warning-icon, #transactionDiagram .payment-warning-icon {
-fx-text-fill: rgb(238, 210, 2); -fx-text-fill: rgb(238, 210, 2);
} }