add transaction fee column to funds > transactions

Co-authored-by: niyid <neeyeed@gmail.com>
This commit is contained in:
woodser 2024-09-25 11:34:12 -04:00
parent 6c640ddbef
commit 1329902a55
3 changed files with 48 additions and 7 deletions

View file

@ -54,6 +54,7 @@ class TransactionsListItem {
private boolean received; private boolean received;
private boolean detailsAvailable; private boolean detailsAvailable;
private BigInteger amount = BigInteger.ZERO; private BigInteger amount = BigInteger.ZERO;
private BigInteger txFee = BigInteger.ZERO;
private String memo = ""; private String memo = "";
private long confirmations = 0; private long confirmations = 0;
@Getter @Getter
@ -107,6 +108,7 @@ class TransactionsListItem {
amount = valueSentFromMe.multiply(BigInteger.valueOf(-1)); amount = valueSentFromMe.multiply(BigInteger.valueOf(-1));
received = false; received = false;
direction = Res.get("funds.tx.direction.sentTo"); direction = Res.get("funds.tx.direction.sentTo");
txFee = tx.getFee().multiply(BigInteger.valueOf(-1));
} }
if (optionalTradable.isPresent()) { if (optionalTradable.isPresent()) {
@ -201,6 +203,14 @@ class TransactionsListItem {
return amount; return amount;
} }
public BigInteger getTxFee() {
return txFee;
}
public String getTxFeeStr() {
return txFee.equals(BigInteger.ZERO) ? "" : HavenoUtils.formatXmr(txFee);
}
public String getAddressString() { public String getAddressString() {
return addressString; return addressString;
} }

View file

@ -36,7 +36,8 @@
<TableColumn fx:id="detailsColumn" minWidth="220" maxWidth="220"/> <TableColumn fx:id="detailsColumn" minWidth="220" maxWidth="220"/>
<TableColumn fx:id="addressColumn" minWidth="260"/> <TableColumn fx:id="addressColumn" minWidth="260"/>
<TableColumn fx:id="transactionColumn" minWidth="180"/> <TableColumn fx:id="transactionColumn" minWidth="180"/>
<TableColumn fx:id="amountColumn" minWidth="130" maxWidth="130"/> <TableColumn fx:id="amountColumn" minWidth="110" maxWidth="110"/>
<TableColumn fx:id="txFeeColumn" minWidth="110" maxWidth="110"/>
<TableColumn fx:id="memoColumn" minWidth="40"/> <TableColumn fx:id="memoColumn" minWidth="40"/>
<TableColumn fx:id="confidenceColumn" minWidth="120" maxWidth="130"/> <TableColumn fx:id="confidenceColumn" minWidth="120" maxWidth="130"/>
<TableColumn fx:id="revertTxColumn" sortable="false" minWidth="110" maxWidth="110" visible="false"/> <TableColumn fx:id="revertTxColumn" sortable="false" minWidth="110" maxWidth="110" visible="false"/>

View file

@ -70,7 +70,7 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
@FXML @FXML
TableView<TransactionsListItem> tableView; TableView<TransactionsListItem> tableView;
@FXML @FXML
TableColumn<TransactionsListItem, TransactionsListItem> dateColumn, detailsColumn, addressColumn, transactionColumn, amountColumn, memoColumn, confidenceColumn, revertTxColumn; TableColumn<TransactionsListItem, TransactionsListItem> dateColumn, detailsColumn, addressColumn, transactionColumn, amountColumn, txFeeColumn, memoColumn, confidenceColumn, revertTxColumn;
@FXML @FXML
Label numItems; Label numItems;
@FXML @FXML
@ -89,7 +89,7 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
private EventHandler<KeyEvent> keyEventEventHandler; private EventHandler<KeyEvent> keyEventEventHandler;
private Scene scene; private Scene scene;
private TransactionsUpdater transactionsUpdater = new TransactionsUpdater(); private final TransactionsUpdater transactionsUpdater = new TransactionsUpdater();
private class TransactionsUpdater extends MoneroWalletListener { private class TransactionsUpdater extends MoneroWalletListener {
@Override @Override
@ -129,11 +129,12 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
addressColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.address"))); addressColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.address")));
transactionColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.txId", Res.getBaseCurrencyCode()))); transactionColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.txId", Res.getBaseCurrencyCode())));
amountColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.amountWithCur", Res.getBaseCurrencyCode()))); amountColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.amountWithCur", Res.getBaseCurrencyCode())));
txFeeColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.txFee", Res.getBaseCurrencyCode())));
memoColumn.setGraphic(new AutoTooltipLabel(Res.get("funds.tx.memo"))); memoColumn.setGraphic(new AutoTooltipLabel(Res.get("funds.tx.memo")));
confidenceColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.confirmations", Res.getBaseCurrencyCode()))); confidenceColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.confirmations", Res.getBaseCurrencyCode())));
revertTxColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.revert", Res.getBaseCurrencyCode()))); revertTxColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.revert", Res.getBaseCurrencyCode())));
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY_FLEX_LAST_COLUMN);
tableView.setPlaceholder(new AutoTooltipLabel(Res.get("funds.tx.noTxAvailable"))); tableView.setPlaceholder(new AutoTooltipLabel(Res.get("funds.tx.noTxAvailable")));
setDateColumnCellFactory(); setDateColumnCellFactory();
@ -141,6 +142,7 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
setAddressColumnCellFactory(); setAddressColumnCellFactory();
setTransactionColumnCellFactory(); setTransactionColumnCellFactory();
setAmountColumnCellFactory(); setAmountColumnCellFactory();
setTxFeeColumnCellFactory();
setMemoColumnCellFactory(); setMemoColumnCellFactory();
setConfidenceColumnCellFactory(); setConfidenceColumnCellFactory();
setRevertTxColumnCellFactory(); setRevertTxColumnCellFactory();
@ -156,7 +158,7 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
addressColumn.setComparator(Comparator.comparing(item -> item.getDirection() + item.getAddressString())); addressColumn.setComparator(Comparator.comparing(item -> item.getDirection() + item.getAddressString()));
transactionColumn.setComparator(Comparator.comparing(TransactionsListItem::getTxId)); transactionColumn.setComparator(Comparator.comparing(TransactionsListItem::getTxId));
amountColumn.setComparator(Comparator.comparing(TransactionsListItem::getAmount)); amountColumn.setComparator(Comparator.comparing(TransactionsListItem::getAmount));
confidenceColumn.setComparator(Comparator.comparingLong(item -> item.getNumConfirmations())); confidenceColumn.setComparator(Comparator.comparingLong(TransactionsListItem::getNumConfirmations));
memoColumn.setComparator(Comparator.comparing(TransactionsListItem::getMemo)); memoColumn.setComparator(Comparator.comparing(TransactionsListItem::getMemo));
dateColumn.setSortType(TableColumn.SortType.DESCENDING); dateColumn.setSortType(TableColumn.SortType.DESCENDING);
@ -216,8 +218,9 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
columns[2] = item.getDirection() + " " + item.getAddressString(); columns[2] = item.getDirection() + " " + item.getAddressString();
columns[3] = item.getTxId(); columns[3] = item.getTxId();
columns[4] = item.getAmountStr(); columns[4] = item.getAmountStr();
columns[5] = item.getMemo() == null ? "" : item.getMemo(); columns[5] = item.getTxFeeStr();
columns[6] = String.valueOf(item.getNumConfirmations()); columns[6] = item.getMemo() == null ? "" : item.getMemo();
columns[7] = String.valueOf(item.getNumConfirmations());
return columns; return columns;
}; };
@ -414,6 +417,33 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
}); });
} }
private void setTxFeeColumnCellFactory() {
txFeeColumn.setCellValueFactory((addressListItem) ->
new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
txFeeColumn.setCellFactory(
new Callback<>() {
@Override
public TableCell<TransactionsListItem, TransactionsListItem> call(TableColumn<TransactionsListItem,
TransactionsListItem> column) {
return new TableCell<>() {
@Override
public void updateItem(final TransactionsListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
setGraphic(new AutoTooltipLabel(item.getTxFeeStr()));
} else {
setGraphic(null);
}
}
};
}
});
}
private void setMemoColumnCellFactory() { private void setMemoColumnCellFactory() {
memoColumn.setCellValueFactory((addressListItem) -> memoColumn.setCellValueFactory((addressListItem) ->
new ReadOnlyObjectWrapper<>(addressListItem.getValue())); new ReadOnlyObjectWrapper<>(addressListItem.getValue()));