|
3 | 3 | import com.sparrowwallet.drongo.KeyPurpose;
|
4 | 4 | import com.sparrowwallet.drongo.OsType;
|
5 | 5 | import com.sparrowwallet.drongo.address.Address;
|
| 6 | +import com.sparrowwallet.drongo.bip47.PaymentCode; |
6 | 7 | import com.sparrowwallet.drongo.protocol.Sha256Hash;
|
7 | 8 | import com.sparrowwallet.drongo.protocol.TransactionOutput;
|
8 | 9 | import com.sparrowwallet.drongo.uri.BitcoinURI;
|
@@ -702,7 +703,9 @@ private Pane getOutputsLabels(List<Payment> displayedPayments) {
|
702 | 703 | paymentBox.getChildren().addAll(region, amountLabel);
|
703 | 704 | }
|
704 | 705 |
|
705 |
| - outputNodes.add(new OutputNode(paymentBox, payment.getAddress(), payment.getAmount())); |
| 706 | + Wallet bip47Wallet = toWallet != null && toWallet.isBip47() ? toWallet : (toBip47Wallet != null && toBip47Wallet.isBip47() ? toBip47Wallet : null); |
| 707 | + PaymentCode paymentCode = bip47Wallet == null ? null : bip47Wallet.getKeystores().getFirst().getExternalPaymentCode(); |
| 708 | + outputNodes.add(new OutputNode(paymentBox, payment.getAddress(), payment.getAmount(), paymentCode)); |
706 | 709 | }
|
707 | 710 |
|
708 | 711 | Set<Integer> seenIndexes = new HashSet<>();
|
@@ -766,7 +769,7 @@ private Pane getOutputsLabels(List<Payment> displayedPayments) {
|
766 | 769 | outputsBox.getChildren().add(outputNode.outputLabel);
|
767 | 770 | outputsBox.getChildren().add(createSpacer());
|
768 | 771 |
|
769 |
| - ContextMenu contextMenu = new LabelContextMenu(outputNode.address, outputNode.amount); |
| 772 | + ContextMenu contextMenu = new LabelContextMenu(outputNode.address, outputNode.amount, outputNode.paymentCode); |
770 | 773 | if(!outputNode.outputLabel.getChildren().isEmpty() && outputNode.outputLabel.getChildren().get(0) instanceof Label outputLabelControl) {
|
771 | 774 | outputLabelControl.setContextMenu(contextMenu);
|
772 | 775 | }
|
@@ -1073,16 +1076,26 @@ private static class OutputNode {
|
1073 | 1076 | public Pane outputLabel;
|
1074 | 1077 | public Address address;
|
1075 | 1078 | public long amount;
|
| 1079 | + public PaymentCode paymentCode; |
1076 | 1080 |
|
1077 | 1081 | public OutputNode(Pane outputLabel, Address address, long amount) {
|
| 1082 | + this(outputLabel, address, amount, null); |
| 1083 | + } |
| 1084 | + |
| 1085 | + public OutputNode(Pane outputLabel, Address address, long amount, PaymentCode paymentCode) { |
1078 | 1086 | this.outputLabel = outputLabel;
|
1079 | 1087 | this.address = address;
|
1080 | 1088 | this.amount = amount;
|
| 1089 | + this.paymentCode = paymentCode; |
1081 | 1090 | }
|
1082 | 1091 | }
|
1083 | 1092 |
|
1084 | 1093 | private class LabelContextMenu extends ContextMenu {
|
1085 | 1094 | public LabelContextMenu(Address address, long value) {
|
| 1095 | + this(address, value, null); |
| 1096 | + } |
| 1097 | + |
| 1098 | + public LabelContextMenu(Address address, long value, PaymentCode paymentCode) { |
1086 | 1099 | if(address != null) {
|
1087 | 1100 | MenuItem copyAddress = new MenuItem("Copy Address");
|
1088 | 1101 | copyAddress.setOnAction(event -> {
|
@@ -1119,6 +1132,17 @@ public LabelContextMenu(Address address, long value) {
|
1119 | 1132 | Clipboard.getSystemClipboard().setContent(content);
|
1120 | 1133 | });
|
1121 | 1134 | getItems().addAll(copySatsValue, copyBtcValue);
|
| 1135 | + |
| 1136 | + if(paymentCode != null) { |
| 1137 | + MenuItem copyPaymentCode = new MenuItem("Copy Payment Code"); |
| 1138 | + copyPaymentCode.setOnAction(AE -> { |
| 1139 | + hide(); |
| 1140 | + ClipboardContent content = new ClipboardContent(); |
| 1141 | + content.putString(paymentCode.toString()); |
| 1142 | + Clipboard.getSystemClipboard().setContent(content); |
| 1143 | + }); |
| 1144 | + getItems().add(copyPaymentCode); |
| 1145 | + } |
1122 | 1146 | }
|
1123 | 1147 | }
|
1124 | 1148 | }
|
0 commit comments