Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add memo field to withdrawal transaction #4229

Merged
merged 5 commits into from May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,8 @@ funds.withdrawal.feeExcluded=Amount excludes mining fee
funds.withdrawal.feeIncluded=Amount includes mining fee
funds.withdrawal.fromLabel=Withdraw from address
funds.withdrawal.toLabel=Withdraw to address
funds.withdrawal.memoLabel=Withdrawal memo
funds.withdrawal.memo=Optionally fill memo
funds.withdrawal.withdrawButton=Withdraw selected
funds.withdrawal.noFundsAvailable=No funds are available for withdrawal
funds.withdrawal.confirmWithdrawalRequest=Confirm withdrawal request
Expand Down Expand Up @@ -936,6 +938,7 @@ funds.tx.noFundsFromDispute=No refund from dispute
funds.tx.receivedFunds=Received funds
funds.tx.withdrawnFromWallet=Withdrawn from wallet
funds.tx.withdrawnFromBSQWallet=BTC withdrawn from BSQ wallet
funds.tx.memo=Memo
funds.tx.noTxAvailable=No transactions available
funds.tx.revert=Revert
funds.tx.txSent=Transaction successfully sent to a new address in the local Bisq wallet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class TransactionsListItem {
private boolean received;
private boolean detailsAvailable;
private Coin amountAsCoin = Coin.ZERO;
private String memo = "";
private int confirmations = 0;
@Getter
private final boolean isDustAttackTx;
Expand All @@ -91,6 +92,7 @@ class TransactionsListItem {
long ignoreDustThreshold) {
this.btcWalletService = btcWalletService;
this.formatter = formatter;
this.memo = transaction.getMemo();

txId = transaction.getHashAsString();

Expand Down Expand Up @@ -340,5 +342,7 @@ public Tradable getTradable() {
public String getNumConfirmations() {
return String.valueOf(confirmations);
}

public String getMemo() { return memo; }
}

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<TableColumn fx:id="addressColumn" minWidth="260"/>
<TableColumn fx:id="transactionColumn" minWidth="180"/>
<TableColumn fx:id="amountColumn" minWidth="130" maxWidth="130"/>
<TableColumn fx:id="memoColumn" minWidth="50" maxWidth="50"/>
<TableColumn fx:id="confidenceColumn" minWidth="130" maxWidth="130"/>
<TableColumn fx:id="revertTxColumn" sortable="false" minWidth="110" maxWidth="110" visible="false"/>
</columns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
@FXML
TableView<TransactionsListItem> tableView;
@FXML
TableColumn<TransactionsListItem, TransactionsListItem> dateColumn, detailsColumn, addressColumn, transactionColumn, amountColumn, confidenceColumn, revertTxColumn;
TableColumn<TransactionsListItem, TransactionsListItem> dateColumn, detailsColumn, addressColumn, transactionColumn, amountColumn, memoColumn, confidenceColumn, revertTxColumn;
@FXML
AutoTooltipButton exportButton;

Expand Down Expand Up @@ -136,6 +136,7 @@ public void initialize() {
addressColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.address")));
transactionColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.txId", Res.getBaseCurrencyCode())));
amountColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.amountWithCur", Res.getBaseCurrencyCode())));
memoColumn.setGraphic(new AutoTooltipLabel(Res.get("funds.tx.memo")));
confidenceColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.confirmations", Res.getBaseCurrencyCode())));
revertTxColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.revert", Res.getBaseCurrencyCode())));

Expand All @@ -147,6 +148,7 @@ public void initialize() {
setAddressColumnCellFactory();
setTransactionColumnCellFactory();
setAmountColumnCellFactory();
setMemoColumnCellFactory();
setConfidenceColumnCellFactory();
setRevertTxColumnCellFactory();

Expand Down Expand Up @@ -237,13 +239,14 @@ protected void activate() {
return columns;
};
CSVEntryConverter<TransactionsListItem> contentConverter = item -> {
String[] columns = new String[6];
String[] columns = new String[7];
columns[0] = item.getDateString();
columns[1] = item.getDetails();
columns[2] = item.getDirection() + " " + item.getAddressString();
columns[3] = item.getTxId();
columns[4] = item.getAmount();
columns[5] = item.getNumConfirmations();
columns[5] = item.getMemo();
columns[6] = item.getNumConfirmations();
return columns;
};

Expand Down Expand Up @@ -453,6 +456,33 @@ public void updateItem(final TransactionsListItem item, boolean empty) {
});
}

private void setMemoColumnCellFactory() {
memoColumn.setCellValueFactory((addressListItem) ->
new ReadOnlyObjectWrapper<>(addressListItem.getValue()));

memoColumn.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.getMemo()));
} else {
setGraphic(null);
}
}
};
}
});
}

private void setConfidenceColumnCellFactory() {
confidenceColumn.getStyleClass().add("last-column");
confidenceColumn.setCellValueFactory((addressListItem) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@

import org.spongycastle.crypto.params.KeyParameter;

import java.text.MessageFormat;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand All @@ -125,7 +124,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {

private RadioButton useAllInputsRadioButton, useCustomInputsRadioButton, feeExcludedRadioButton;
private Label amountLabel;
private TextField amountTextField, withdrawFromTextField, withdrawToTextField;
private TextField amountTextField, withdrawFromTextField, withdrawToTextField, withdrawMemoTextField;

private final BtcWalletService walletService;
private final TradeManager tradeManager;
Expand Down Expand Up @@ -220,6 +219,10 @@ public void initialize() {
Res.get("funds.withdrawal.toLabel", Res.getBaseCurrencyCode())).second;
withdrawToTextField.setMaxWidth(380);

withdrawMemoTextField = addTopLabelInputTextField(gridPane, ++rowIndex,
Res.get("funds.withdrawal.memoLabel", Res.getBaseCurrencyCode())).second;
withdrawMemoTextField.setMaxWidth(380);

final Button withdrawButton = addButton(gridPane, ++rowIndex, Res.get("funds.withdrawal.withdrawButton"), 15);

withdrawButton.setOnAction(event -> onWithdraw());
Expand Down Expand Up @@ -384,6 +387,7 @@ private void onWithdraw() {
@Override
public void onSuccess(@javax.annotation.Nullable Transaction transaction) {
if (transaction != null) {
transaction.setMemo(withdrawMemoTextField.getText());
log.debug("onWithdraw onSuccess tx ID:{}", transaction.getHashAsString());
} else {
log.error("onWithdraw transaction is null");
Expand Down Expand Up @@ -528,6 +532,9 @@ private void reset() {
withdrawToTextField.setText("");
withdrawToTextField.setPromptText(Res.get("funds.withdrawal.fillDestAddress"));

withdrawMemoTextField.setText("");
withdrawMemoTextField.setPromptText(Res.get("funds.withdrawal.memo"));

selectedItems.clear();
tableView.getSelectionModel().clearSelection();
}
Expand Down