@@ -172,6 +172,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
172172 QAction *copyTxIDAction = new QAction (tr (" Copy transaction ID" ), this );
173173 QAction *copyTxHexAction = new QAction (tr (" Copy raw transaction" ), this );
174174 QAction *copyTxPlainText = new QAction (tr (" Copy full transaction details" ), this );
175+ QAction *editLabelAction = new QAction (tr (" Edit label" ), this );
175176 QAction *showDetailsAction = new QAction (tr (" Show transaction details" ), this );
176177
177178 contextMenu = new QMenu (this );
@@ -186,6 +187,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
186187 contextMenu->addSeparator ();
187188 contextMenu->addAction (bumpFeeAction);
188189 contextMenu->addAction (abandonAction);
190+ contextMenu->addAction (editLabelAction);
189191
190192 connect (dateWidget, static_cast <void (QComboBox::*)(int )>(&QComboBox::activated), this , &TransactionView::chooseDate);
191193 connect (typeWidget, static_cast <void (QComboBox::*)(int )>(&QComboBox::activated), this , &TransactionView::chooseType);
@@ -206,6 +208,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
206208 connect (copyTxIDAction, &QAction::triggered, this , &TransactionView::copyTxID);
207209 connect (copyTxHexAction, &QAction::triggered, this , &TransactionView::copyTxHex);
208210 connect (copyTxPlainText, &QAction::triggered, this , &TransactionView::copyTxPlainText);
211+ connect (editLabelAction, &QAction::triggered, this , &TransactionView::editLabel);
209212 connect (showDetailsAction, &QAction::triggered, this , &TransactionView::showDetails);
210213 // Double-clicking on a transaction on the transaction history page shows details
211214 connect (this , &TransactionView::doubleClicked, this , &TransactionView::showDetails);
@@ -474,6 +477,52 @@ void TransactionView::copyTxPlainText()
474477 GUIUtil::copyEntryData (transactionView, 0 , TransactionTableModel::TxPlainTextRole);
475478}
476479
480+ void TransactionView::editLabel ()
481+ {
482+ if (!transactionView->selectionModel () ||!model)
483+ return ;
484+ QModelIndexList selection = transactionView->selectionModel ()->selectedRows ();
485+ if (!selection.isEmpty ())
486+ {
487+ AddressTableModel *addressBook = model->getAddressTableModel ();
488+ if (!addressBook)
489+ return ;
490+ QString address = selection.at (0 ).data (TransactionTableModel::AddressRole).toString ();
491+ if (address.isEmpty ())
492+ {
493+ // If this transaction has no associated address, exit
494+ return ;
495+ }
496+ // Is address in address book? Address book can miss address when a transaction is
497+ // sent from outside the UI.
498+ int idx = addressBook->lookupAddress (address);
499+ if (idx != -1 )
500+ {
501+ // Edit sending / receiving address
502+ QModelIndex modelIdx = addressBook->index (idx, 0 , QModelIndex ());
503+ // Determine type of address, launch appropriate editor dialog type
504+ QString type = modelIdx.data (AddressTableModel::TypeRole).toString ();
505+
506+ EditAddressDialog dlg (
507+ type == AddressTableModel::Receive
508+ ? EditAddressDialog::EditReceivingAddress
509+ : EditAddressDialog::EditSendingAddress, this );
510+ dlg.setModel (addressBook);
511+ dlg.loadRow (idx);
512+ dlg.exec ();
513+ }
514+ else
515+ {
516+ // Add sending address
517+ EditAddressDialog dlg (EditAddressDialog::NewSendingAddress,
518+ this );
519+ dlg.setModel (addressBook);
520+ dlg.setAddress (address);
521+ dlg.exec ();
522+ }
523+ }
524+ }
525+
477526void TransactionView::showDetails ()
478527{
479528 if (!transactionView->selectionModel ())
0 commit comments