Changeset View
Changeset View
Standalone View
Standalone View
src/qt/coincontroldialog.cpp
Show First 20 Lines • Show All 229 Lines • ▼ Show 20 Lines | if (item) { | ||||
// roots in context menu | // roots in context menu | ||||
if (item->text(COLUMN_TXHASH).length() == 64) { | if (item->text(COLUMN_TXHASH).length() == 64) { | ||||
TxId txid; | TxId txid; | ||||
txid.SetHex(item->text(COLUMN_TXHASH).toStdString()); | txid.SetHex(item->text(COLUMN_TXHASH).toStdString()); | ||||
// transaction hash is 64 characters (this means its a child node, | // transaction hash is 64 characters (this means its a child node, | ||||
// so its not a parent node in tree mode) | // so its not a parent node in tree mode) | ||||
copyTransactionHashAction->setEnabled(true); | copyTransactionHashAction->setEnabled(true); | ||||
if (model->isLockedCoin(txid, | if (model->wallet().isLockedCoin( | ||||
item->text(COLUMN_VOUT_INDEX).toUInt())) { | COutPoint(txid, item->text(COLUMN_VOUT_INDEX).toUInt()))) { | ||||
lockAction->setEnabled(false); | lockAction->setEnabled(false); | ||||
unlockAction->setEnabled(true); | unlockAction->setEnabled(true); | ||||
} else { | } else { | ||||
lockAction->setEnabled(true); | lockAction->setEnabled(true); | ||||
unlockAction->setEnabled(false); | unlockAction->setEnabled(false); | ||||
} | } | ||||
} else { | } else { | ||||
// this means click on parent node in tree mode -> disable all | // this means click on parent node in tree mode -> disable all | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
void CoinControlDialog::lockCoin() { | void CoinControlDialog::lockCoin() { | ||||
if (contextMenuItem->checkState(COLUMN_CHECKBOX) == Qt::Checked) { | if (contextMenuItem->checkState(COLUMN_CHECKBOX) == Qt::Checked) { | ||||
contextMenuItem->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); | contextMenuItem->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); | ||||
} | } | ||||
COutPoint outpt( | COutPoint outpt( | ||||
uint256S(contextMenuItem->text(COLUMN_TXHASH).toStdString()), | uint256S(contextMenuItem->text(COLUMN_TXHASH).toStdString()), | ||||
contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); | contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); | ||||
model->lockCoin(outpt); | model->wallet().lockCoin(outpt); | ||||
contextMenuItem->setDisabled(true); | contextMenuItem->setDisabled(true); | ||||
contextMenuItem->setIcon( | contextMenuItem->setIcon( | ||||
COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed")); | COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed")); | ||||
updateLabelLocked(); | updateLabelLocked(); | ||||
} | } | ||||
// context menu action: unlock coin | // context menu action: unlock coin | ||||
void CoinControlDialog::unlockCoin() { | void CoinControlDialog::unlockCoin() { | ||||
COutPoint outpt( | COutPoint outpt( | ||||
uint256S(contextMenuItem->text(COLUMN_TXHASH).toStdString()), | uint256S(contextMenuItem->text(COLUMN_TXHASH).toStdString()), | ||||
contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); | contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); | ||||
model->unlockCoin(outpt); | model->wallet().unlockCoin(outpt); | ||||
contextMenuItem->setDisabled(false); | contextMenuItem->setDisabled(false); | ||||
contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon()); | contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon()); | ||||
updateLabelLocked(); | updateLabelLocked(); | ||||
} | } | ||||
// copy label "Quantity" to clipboard | // copy label "Quantity" to clipboard | ||||
void CoinControlDialog::clipboardQuantity() { | void CoinControlDialog::clipboardQuantity() { | ||||
GUIUtil::setClipboard(ui->labelCoinControlQuantity->text()); | GUIUtil::setClipboard(ui->labelCoinControlQuantity->text()); | ||||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | else if (column == COLUMN_CHECKBOX && item->childCount() > 0) { | ||||
item->setCheckState(COLUMN_CHECKBOX, Qt::Checked); | item->setCheckState(COLUMN_CHECKBOX, Qt::Checked); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// shows count of locked unspent outputs | // shows count of locked unspent outputs | ||||
void CoinControlDialog::updateLabelLocked() { | void CoinControlDialog::updateLabelLocked() { | ||||
std::vector<COutPoint> vOutpts; | std::vector<COutPoint> vOutpts; | ||||
model->listLockedCoins(vOutpts); | model->wallet().listLockedCoins(vOutpts); | ||||
if (vOutpts.size() > 0) { | if (vOutpts.size() > 0) { | ||||
ui->labelLocked->setText(tr("(%1 locked)").arg(vOutpts.size())); | ui->labelLocked->setText(tr("(%1 locked)").arg(vOutpts.size())); | ||||
ui->labelLocked->setVisible(true); | ui->labelLocked->setVisible(true); | ||||
} else { | } else { | ||||
ui->labelLocked->setVisible(false); | ui->labelLocked->setVisible(false); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | for (const COutput &out : vOutputs) { | ||||
// Amount | // Amount | ||||
nAmount += out.tx->tx->vout[out.i].nValue; | nAmount += out.tx->tx->vout[out.i].nValue; | ||||
// Bytes | // Bytes | ||||
CTxDestination address; | CTxDestination address; | ||||
if (ExtractDestination(out.tx->tx->vout[out.i].scriptPubKey, address)) { | if (ExtractDestination(out.tx->tx->vout[out.i].scriptPubKey, address)) { | ||||
CPubKey pubkey; | CPubKey pubkey; | ||||
CKeyID *keyid = boost::get<CKeyID>(&address); | CKeyID *keyid = boost::get<CKeyID>(&address); | ||||
if (keyid && model->getPubKey(*keyid, pubkey)) { | if (keyid && model->wallet().getPubKey(*keyid, pubkey)) { | ||||
nBytesInputs += (pubkey.IsCompressed() ? 148 : 180); | nBytesInputs += (pubkey.IsCompressed() ? 148 : 180); | ||||
if (!pubkey.IsCompressed()) { | if (!pubkey.IsCompressed()) { | ||||
nQuantityUncompressed++; | nQuantityUncompressed++; | ||||
} | } | ||||
} else { | } else { | ||||
// in all error cases, simply assume 148 here | // in all error cases, simply assume 148 here | ||||
nBytesInputs += 148; | nBytesInputs += 148; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 266 Lines • ▼ Show 20 Lines | for (const std::pair<QString, std::vector<COutput>> &coins : mapCoins) { | ||||
const TxId txid = out.tx->GetId(); | const TxId txid = out.tx->GetId(); | ||||
itemOutput->setText(COLUMN_TXHASH, | itemOutput->setText(COLUMN_TXHASH, | ||||
QString::fromStdString(txid.GetHex())); | QString::fromStdString(txid.GetHex())); | ||||
// vout index | // vout index | ||||
itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(out.i)); | itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(out.i)); | ||||
// disable locked coins | // disable locked coins | ||||
if (model->isLockedCoin(txid, out.i)) { | if (model->wallet().isLockedCoin(COutPoint(txid, out.i))) { | ||||
COutPoint outpt(txid, out.i); | COutPoint outpt(txid, out.i); | ||||
// just to be sure | // just to be sure | ||||
coinControl()->UnSelect(outpt); | coinControl()->UnSelect(outpt); | ||||
itemOutput->setDisabled(true); | itemOutput->setDisabled(true); | ||||
itemOutput->setIcon( | itemOutput->setIcon( | ||||
COLUMN_CHECKBOX, | COLUMN_CHECKBOX, | ||||
platformStyle->SingleColorIcon(":/icons/lock_closed")); | platformStyle->SingleColorIcon(":/icons/lock_closed")); | ||||
} | } | ||||
Show All 31 Lines |