Skip to content

Commit

Permalink
Include vout when copying transaction ID from coin selection
Browse files Browse the repository at this point in the history
  • Loading branch information
meshcollider committed Sep 28, 2021
1 parent b55232a commit 10c6929
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions src/qt/coincontroldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ CoinControlDialog::CoinControlDialog(CCoinControl& coin_control, WalletModel* _m
contextMenu->addAction(tr("&Copy address"), this, &CoinControlDialog::copyAddress);
contextMenu->addAction(tr("Copy &label"), this, &CoinControlDialog::copyLabel);
contextMenu->addAction(tr("Copy &amount"), this, &CoinControlDialog::copyAmount);
copyTransactionHashAction = contextMenu->addAction(tr("Copy transaction &ID"), this, &CoinControlDialog::copyTransactionHash);
m_copy_transaction_outpoint_action = contextMenu->addAction(tr("Copy transaction &ID and output index"), this, &CoinControlDialog::copyTransactionOutpoint);
contextMenu->addSeparator();
lockAction = contextMenu->addAction(tr("L&ock unspent"), this, &CoinControlDialog::lockCoin);
unlockAction = contextMenu->addAction(tr("&Unlock unspent"), this, &CoinControlDialog::unlockCoin);
Expand Down Expand Up @@ -180,7 +180,7 @@ void CoinControlDialog::showMenu(const QPoint &point)
// disable some items (like Copy Transaction ID, lock, unlock) for tree roots in context menu
if (item->data(COLUMN_ADDRESS, TxHashRole).toString().length() == 64) // transaction hash is 64 characters (this means it is a child node, so it is not a parent node in tree mode)
{
copyTransactionHashAction->setEnabled(true);
m_copy_transaction_outpoint_action->setEnabled(true);
if (model->wallet().isLockedCoin(COutPoint(uint256S(item->data(COLUMN_ADDRESS, TxHashRole).toString().toStdString()), item->data(COLUMN_ADDRESS, VOutRole).toUInt())))
{
lockAction->setEnabled(false);
Expand All @@ -194,7 +194,7 @@ void CoinControlDialog::showMenu(const QPoint &point)
}
else // this means click on parent node in tree mode -> disable all
{
copyTransactionHashAction->setEnabled(false);
m_copy_transaction_outpoint_action->setEnabled(false);
lockAction->setEnabled(false);
unlockAction->setEnabled(false);
}
Expand Down Expand Up @@ -228,10 +228,14 @@ void CoinControlDialog::copyAddress()
GUIUtil::setClipboard(contextMenuItem->text(COLUMN_ADDRESS));
}

// context menu action: copy transaction id
void CoinControlDialog::copyTransactionHash()
// context menu action: copy transaction id and vout index
void CoinControlDialog::copyTransactionOutpoint()
{
GUIUtil::setClipboard(contextMenuItem->data(COLUMN_ADDRESS, TxHashRole).toString());
const QString address = contextMenuItem->data(COLUMN_ADDRESS, TxHashRole).toString();
const QString vout = contextMenuItem->data(COLUMN_ADDRESS, VOutRole).toString();
const QString outpoint = QString("%1:%2").arg(address).arg(vout);

GUIUtil::setClipboard(outpoint);
}

// context menu action: lock coin
Expand Down
4 changes: 2 additions & 2 deletions src/qt/coincontroldialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class CoinControlDialog : public QDialog

QMenu *contextMenu;
QTreeWidgetItem *contextMenuItem;
QAction *copyTransactionHashAction;
QAction* m_copy_transaction_outpoint_action;
QAction *lockAction;
QAction *unlockAction;

Expand Down Expand Up @@ -95,7 +95,7 @@ private Q_SLOTS:
void copyAmount();
void copyLabel();
void copyAddress();
void copyTransactionHash();
void copyTransactionOutpoint();
void lockCoin();
void unlockCoin();
void clipboardQuantity();
Expand Down

0 comments on commit 10c6929

Please sign in to comment.