Changeset View
Changeset View
Standalone View
Standalone View
src/qt/sendcoinsdialog.cpp
Show All 11 Lines | |||||
#include "guiutil.h" | #include "guiutil.h" | ||||
#include "optionsmodel.h" | #include "optionsmodel.h" | ||||
#include "platformstyle.h" | #include "platformstyle.h" | ||||
#include "sendcoinsentry.h" | #include "sendcoinsentry.h" | ||||
#include "walletmodel.h" | #include "walletmodel.h" | ||||
#include "chainparams.h" | #include "chainparams.h" | ||||
#include "dstencode.h" | #include "dstencode.h" | ||||
#include "interface/node.h" | |||||
#include "txmempool.h" | #include "txmempool.h" | ||||
#include "ui_interface.h" | #include "ui_interface.h" | ||||
#include "validation.h" // mempool and minRelayTxFee | #include "validation.h" // mempool and minRelayTxFee | ||||
#include "wallet/coincontrol.h" | #include "wallet/coincontrol.h" | ||||
#include "wallet/fees.h" | #include "wallet/fees.h" | ||||
#include "wallet/wallet.h" | #include "wallet/wallet.h" | ||||
#include <QMessageBox> | #include <QMessageBox> | ||||
▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | if (_model && _model->getOptionsModel()) { | ||||
for (int i = 0; i < ui->entries->count(); ++i) { | for (int i = 0; i < ui->entries->count(); ++i) { | ||||
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry *>( | SendCoinsEntry *entry = qobject_cast<SendCoinsEntry *>( | ||||
ui->entries->itemAt(i)->widget()); | ui->entries->itemAt(i)->widget()); | ||||
if (entry) { | if (entry) { | ||||
entry->setModel(_model); | entry->setModel(_model); | ||||
} | } | ||||
} | } | ||||
setBalance(_model->getBalance(), _model->getUnconfirmedBalance(), | interface::WalletBalances balances = _model->wallet().getBalances(); | ||||
_model->getImmatureBalance(), _model->getWatchBalance(), | setBalance(balances.balance, balances.unconfirmed_balance, | ||||
_model->getWatchUnconfirmedBalance(), | balances.immature_balance, balances.watch_only_balance, | ||||
_model->getWatchImmatureBalance()); | balances.unconfirmed_watch_only_balance, | ||||
balances.immature_watch_only_balance); | |||||
connect( | connect( | ||||
_model, | _model, | ||||
SIGNAL( | SIGNAL( | ||||
balanceChanged(Amount, Amount, Amount, Amount, Amount, Amount)), | balanceChanged(Amount, Amount, Amount, Amount, Amount, Amount)), | ||||
this, | this, | ||||
SLOT(setBalance(Amount, Amount, Amount, Amount, Amount, Amount))); | SLOT(setBalance(Amount, Amount, Amount, Amount, Amount, Amount))); | ||||
connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), | connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), | ||||
this, SLOT(updateDisplayUnit())); | this, SLOT(updateDisplayUnit())); | ||||
▲ Show 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | WalletModel::SendCoinsReturn sendStatus = | ||||
model->sendCoins(currentTransaction); | model->sendCoins(currentTransaction); | ||||
// process sendStatus and on error generate message shown to user | // process sendStatus and on error generate message shown to user | ||||
processSendCoinsReturn(sendStatus); | processSendCoinsReturn(sendStatus); | ||||
if (sendStatus.status == WalletModel::OK) { | if (sendStatus.status == WalletModel::OK) { | ||||
accept(); | accept(); | ||||
CoinControlDialog::coinControl()->UnSelectAll(); | CoinControlDialog::coinControl()->UnSelectAll(); | ||||
coinControlUpdateLabels(); | coinControlUpdateLabels(); | ||||
Q_EMIT coinsSent(currentTransaction.getTransaction()->GetId()); | Q_EMIT coinsSent(currentTransaction.getWtx()->get().GetId()); | ||||
} | } | ||||
fNewRecipientAllowed = true; | fNewRecipientAllowed = true; | ||||
} | } | ||||
void SendCoinsDialog::clear() { | void SendCoinsDialog::clear() { | ||||
// Remove entries until only one left | // Remove entries until only one left | ||||
while (ui->entries->count()) { | while (ui->entries->count()) { | ||||
ui->entries->takeAt(0)->widget()->deleteLater(); | ui->entries->takeAt(0)->widget()->deleteLater(); | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | void SendCoinsDialog::setBalance(const Amount balance, | ||||
if (model && model->getOptionsModel()) { | if (model && model->getOptionsModel()) { | ||||
ui->labelBalance->setText(BitcoinUnits::formatWithUnit( | ui->labelBalance->setText(BitcoinUnits::formatWithUnit( | ||||
model->getOptionsModel()->getDisplayUnit(), balance)); | model->getOptionsModel()->getDisplayUnit(), balance)); | ||||
} | } | ||||
} | } | ||||
void SendCoinsDialog::updateDisplayUnit() { | void SendCoinsDialog::updateDisplayUnit() { | ||||
setBalance(model->getBalance(), Amount::zero(), Amount::zero(), | setBalance(model->wallet().getBalance(), Amount::zero(), Amount::zero(), | ||||
Amount::zero(), Amount::zero(), Amount::zero()); | Amount::zero(), Amount::zero(), Amount::zero()); | ||||
ui->customFee->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); | ui->customFee->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); | ||||
updateMinFeeLabel(); | updateMinFeeLabel(); | ||||
updateSmartFeeLabel(); | updateSmartFeeLabel(); | ||||
} | } | ||||
void SendCoinsDialog::processSendCoinsReturn( | void SendCoinsDialog::processSendCoinsReturn( | ||||
const WalletModel::SendCoinsReturn &sendCoinsReturn, | const WalletModel::SendCoinsReturn &sendCoinsReturn, | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | |||||
void SendCoinsDialog::useAvailableBalance(SendCoinsEntry *entry) { | void SendCoinsDialog::useAvailableBalance(SendCoinsEntry *entry) { | ||||
// Get CCoinControl instance if CoinControl is enabled or create a new one. | // Get CCoinControl instance if CoinControl is enabled or create a new one. | ||||
CCoinControl coin_control; | CCoinControl coin_control; | ||||
if (model->getOptionsModel()->getCoinControlFeatures()) { | if (model->getOptionsModel()->getCoinControlFeatures()) { | ||||
coin_control = *CoinControlDialog::coinControl(); | coin_control = *CoinControlDialog::coinControl(); | ||||
} | } | ||||
// Calculate available amount to send. | // Calculate available amount to send. | ||||
Amount amount = model->getBalance(&coin_control); | Amount amount = model->wallet().getAvailableBalance(coin_control); | ||||
for (int i = 0; i < ui->entries->count(); ++i) { | for (int i = 0; i < ui->entries->count(); ++i) { | ||||
SendCoinsEntry *e = | SendCoinsEntry *e = | ||||
qobject_cast<SendCoinsEntry *>(ui->entries->itemAt(i)->widget()); | qobject_cast<SendCoinsEntry *>(ui->entries->itemAt(i)->widget()); | ||||
if (e && !e->isHidden() && e != entry) { | if (e && !e->isHidden() && e != entry) { | ||||
amount -= e->getValue().amount; | amount -= e->getValue().amount; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | if (model && model->getAddressTableModel()) { | ||||
// Nothing entered | // Nothing entered | ||||
ui->labelCoinControlChangeLabel->setText(""); | ui->labelCoinControlChangeLabel->setText(""); | ||||
} else if (!IsValidDestination(dest)) { | } else if (!IsValidDestination(dest)) { | ||||
// Invalid address | // Invalid address | ||||
ui->labelCoinControlChangeLabel->setText( | ui->labelCoinControlChangeLabel->setText( | ||||
tr("Warning: Invalid Bitcoin address")); | tr("Warning: Invalid Bitcoin address")); | ||||
} else { | } else { | ||||
// Valid address | // Valid address | ||||
if (!model->IsSpendable(dest)) { | if (!model->wallet().isSpendable(dest)) { | ||||
ui->labelCoinControlChangeLabel->setText( | ui->labelCoinControlChangeLabel->setText( | ||||
tr("Warning: Unknown change address")); | tr("Warning: Unknown change address")); | ||||
// confirmation dialog | // confirmation dialog | ||||
QMessageBox::StandardButton btnRetVal = QMessageBox::question( | QMessageBox::StandardButton btnRetVal = QMessageBox::question( | ||||
this, tr("Confirm custom change address"), | this, tr("Confirm custom change address"), | ||||
tr("The address you selected for change is not part of " | tr("The address you selected for change is not part of " | ||||
"this wallet. Any or all funds in your wallet may be " | "this wallet. Any or all funds in your wallet may be " | ||||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |