Skip to content

Commit 7e5ff3c

Browse files
MarcoFalkethelazier
MarcoFalke
authored andcommitted
Merge bitcoin-core/gui#223: qt: Re-add and rename transaction "Edit Label" action
5440c07 qt: Rename "Edit label" to "Edit address label" (Wladimir J. van der Laan) 22664d6 Revert "qt: Remove Transactionview Edit Label Action" (Wladimir J. van der Laan) Pull request description: This reverts PR dashpay#211. I disagree with this change, I use the functionality a lot, it was the primary way I used to organize and edit transactions labels and am sad to see this go. > you can edit a sending address in the send tab Address Book Using the address book should not be encouraged at all! A while ago it was even proposed to remove it. There's rarely need to scroll through all historical addresses used and unused. The transaction list does just fine for this. > While all other actions apply directly to the selected transaction, the Edit Label action applies to the selected transaction's address. **In practice** when bitcoin is used in the commonly advised way, generate a new address for each transaction, those are equivalent though. I doubt I (and **luke-jr**) will be the only users that will stumblle on this. Further discussion here: bitcoin-core/gui#211 (comment) ACKs for top commit: hebasto: ACK 5440c07, verified that 22664d6 is a clean revert of 8f96448. Tree-SHA512: 3a86a730279bc454d0bd25d874dbfb6b1c0492480e66c3164e7c60d8658d622d4522de11bf8564876dc3ee056b53db71ecbe8a37281bf25d41a27e6e0d72ad8f
1 parent 7c2a9c5 commit 7e5ff3c

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/qt/transactionview.cpp

+49
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ transactionView(nullptr), abandonAction(nullptr), columnResizingFixer(nullptr)
155155
QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this);
156156
QAction *copyTxHexAction = new QAction(tr("Copy raw transaction"), this);
157157
QAction *copyTxPlainText = new QAction(tr("Copy full transaction details"), this);
158+
QAction *editLabelAction = new QAction(tr("Edit address label"), this);
158159
QAction *showDetailsAction = new QAction(tr("Show transaction details"), this);
159160
QAction *showAddressQRCodeAction = new QAction(tr("Show address QR code"), this);
160161

@@ -170,6 +171,7 @@ transactionView(nullptr), abandonAction(nullptr), columnResizingFixer(nullptr)
170171
contextMenu->addAction(showAddressQRCodeAction);
171172
contextMenu->addSeparator();
172173
contextMenu->addAction(abandonAction);
174+
contextMenu->addAction(editLabelAction);
173175

174176
mapperThirdPartyTxUrls = new QSignalMapper(this);
175177

@@ -195,6 +197,7 @@ transactionView(nullptr), abandonAction(nullptr), columnResizingFixer(nullptr)
195197
connect(copyTxIDAction, &QAction::triggered, this, &TransactionView::copyTxID);
196198
connect(copyTxHexAction, &QAction::triggered, this, &TransactionView::copyTxHex);
197199
connect(copyTxPlainText, &QAction::triggered, this, &TransactionView::copyTxPlainText);
200+
connect(editLabelAction, &QAction::triggered, this, &TransactionView::editLabel);
198201
connect(showDetailsAction, &QAction::triggered, this, &TransactionView::showDetails);
199202
connect(showAddressQRCodeAction, &QAction::triggered, this, &TransactionView::showAddressQRCode);
200203
// Double-clicking on a transaction on the transaction history page shows details
@@ -476,6 +479,52 @@ void TransactionView::copyTxPlainText()
476479
GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxPlainTextRole);
477480
}
478481

482+
void TransactionView::editLabel()
483+
{
484+
if(!transactionView->selectionModel() ||!model)
485+
return;
486+
QModelIndexList selection = transactionView->selectionModel()->selectedRows();
487+
if(!selection.isEmpty())
488+
{
489+
AddressTableModel *addressBook = model->getAddressTableModel();
490+
if(!addressBook)
491+
return;
492+
QString address = selection.at(0).data(TransactionTableModel::AddressRole).toString();
493+
if(address.isEmpty())
494+
{
495+
// If this transaction has no associated address, exit
496+
return;
497+
}
498+
// Is address in address book? Address book can miss address when a transaction is
499+
// sent from outside the UI.
500+
int idx = addressBook->lookupAddress(address);
501+
if(idx != -1)
502+
{
503+
// Edit sending / receiving address
504+
QModelIndex modelIdx = addressBook->index(idx, 0, QModelIndex());
505+
// Determine type of address, launch appropriate editor dialog type
506+
QString type = modelIdx.data(AddressTableModel::TypeRole).toString();
507+
508+
EditAddressDialog dlg(
509+
type == AddressTableModel::Receive
510+
? EditAddressDialog::EditReceivingAddress
511+
: EditAddressDialog::EditSendingAddress, this);
512+
dlg.setModel(addressBook);
513+
dlg.loadRow(idx);
514+
dlg.exec();
515+
}
516+
else
517+
{
518+
// Add sending address
519+
EditAddressDialog dlg(EditAddressDialog::NewSendingAddress,
520+
this);
521+
dlg.setModel(addressBook);
522+
dlg.setAddress(address);
523+
dlg.exec();
524+
}
525+
}
526+
}
527+
479528
void TransactionView::showDetails()
480529
{
481530
if(!transactionView->selectionModel())

src/qt/transactionview.h

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ private Q_SLOTS:
9494
void showDetails();
9595
void showAddressQRCode();
9696
void copyAddress();
97+
void editLabel();
9798
void copyLabel();
9899
void copyAmount();
99100
void copyTxID();

0 commit comments

Comments
 (0)