Include vout when copying transaction ID from coin selection

This commit is contained in:
Samuel Dobson 2021-09-28 01:10:40 +13:00
parent b55232a337
commit 10c6929d55
2 changed files with 12 additions and 8 deletions

View file

@ -55,7 +55,7 @@ CoinControlDialog::CoinControlDialog(CCoinControl& coin_control, WalletModel* _m
contextMenu->addAction(tr("&Copy address"), this, &CoinControlDialog::copyAddress); contextMenu->addAction(tr("&Copy address"), this, &CoinControlDialog::copyAddress);
contextMenu->addAction(tr("Copy &label"), this, &CoinControlDialog::copyLabel); contextMenu->addAction(tr("Copy &label"), this, &CoinControlDialog::copyLabel);
contextMenu->addAction(tr("Copy &amount"), this, &CoinControlDialog::copyAmount); 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(); contextMenu->addSeparator();
lockAction = contextMenu->addAction(tr("L&ock unspent"), this, &CoinControlDialog::lockCoin); lockAction = contextMenu->addAction(tr("L&ock unspent"), this, &CoinControlDialog::lockCoin);
unlockAction = contextMenu->addAction(tr("&Unlock unspent"), this, &CoinControlDialog::unlockCoin); unlockAction = contextMenu->addAction(tr("&Unlock unspent"), this, &CoinControlDialog::unlockCoin);
@ -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 // 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) 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()))) if (model->wallet().isLockedCoin(COutPoint(uint256S(item->data(COLUMN_ADDRESS, TxHashRole).toString().toStdString()), item->data(COLUMN_ADDRESS, VOutRole).toUInt())))
{ {
lockAction->setEnabled(false); lockAction->setEnabled(false);
@ -194,7 +194,7 @@ void CoinControlDialog::showMenu(const QPoint &point)
} }
else // this means click on parent node in tree mode -> disable all 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); lockAction->setEnabled(false);
unlockAction->setEnabled(false); unlockAction->setEnabled(false);
} }
@ -228,10 +228,14 @@ void CoinControlDialog::copyAddress()
GUIUtil::setClipboard(contextMenuItem->text(COLUMN_ADDRESS)); GUIUtil::setClipboard(contextMenuItem->text(COLUMN_ADDRESS));
} }
// context menu action: copy transaction id // context menu action: copy transaction id and vout index
void CoinControlDialog::copyTransactionHash() 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 // context menu action: lock coin

View file

@ -63,7 +63,7 @@ private:
QMenu *contextMenu; QMenu *contextMenu;
QTreeWidgetItem *contextMenuItem; QTreeWidgetItem *contextMenuItem;
QAction *copyTransactionHashAction; QAction* m_copy_transaction_outpoint_action;
QAction *lockAction; QAction *lockAction;
QAction *unlockAction; QAction *unlockAction;
@ -95,7 +95,7 @@ private Q_SLOTS:
void copyAmount(); void copyAmount();
void copyLabel(); void copyLabel();
void copyAddress(); void copyAddress();
void copyTransactionHash(); void copyTransactionOutpoint();
void lockCoin(); void lockCoin();
void unlockCoin(); void unlockCoin();
void clipboardQuantity(); void clipboardQuantity();