23 #include <validation.h> 29 #include <QFontMetrics> 30 #include <QMessageBox> 33 #include <QTextDocument> 36 static const std::array<int, 9> confTargets = { {2, 4, 6, 12, 24, 48, 144, 504, 1008} };
38 if (index+1 > static_cast<int>(confTargets.size())) {
39 return confTargets.back();
42 return confTargets[0];
44 return confTargets[index];
47 for (
unsigned int i = 0; i < confTargets.size(); i++) {
48 if (confTargets[i] >= target) {
52 return confTargets.size() - 1;
60 fNewRecipientAllowed(true),
61 platformStyle(_platformStyle)
90 QAction *clipboardQuantityAction =
new QAction(tr(
"Copy quantity"),
this);
91 QAction *clipboardAmountAction =
new QAction(tr(
"Copy amount"),
this);
92 QAction *clipboardFeeAction =
new QAction(tr(
"Copy fee"),
this);
93 QAction *clipboardAfterFeeAction =
new QAction(tr(
"Copy after fee"),
this);
94 QAction *clipboardBytesAction =
new QAction(tr(
"Copy bytes"),
this);
95 QAction *clipboardLowOutputAction =
new QAction(tr(
"Copy dust"),
this);
96 QAction *clipboardChangeAction =
new QAction(tr(
"Copy change"),
this);
114 if (!settings.contains(
"nFeeRadio") && settings.contains(
"nTransactionFee") && settings.value(
"nTransactionFee").toLongLong() > 0)
115 settings.setValue(
"nFeeRadio", 1);
116 if (!settings.contains(
"nFeeRadio"))
117 settings.setValue(
"nFeeRadio", 0);
118 if (!settings.contains(
"nSmartFeeSliderPosition"))
119 settings.setValue(
"nSmartFeeSliderPosition", 0);
120 if (!settings.contains(
"nTransactionFee"))
121 settings.setValue(
"nTransactionFee", (qint64)DEFAULT_TRANSACTION_FEE);
122 if (!settings.contains(
"fPayOnlyMinFee"))
123 settings.setValue(
"fPayOnlyMinFee",
false);
136 connect(_clientModel, SIGNAL(numBlocksChanged(
int,QDateTime,
double,
bool)),
this, SLOT(
updateSmartFeeLabel()));
142 this->
model = _model;
146 for(
int i = 0; i <
ui->
entries->count(); ++i)
157 connect(
model, SIGNAL(balanceChanged(
CAmount,
CAmount,
CAmount,
CAmount,
CAmount,
CAmount,
CAmount,
CAmount)),
this, SLOT(
setBalance(
CAmount,
CAmount,
CAmount,
CAmount,
CAmount,
CAmount,
CAmount,
CAmount)));
168 for (
const int &n : confTargets) {
191 if (settings.value(
"nSmartFeeSliderPosition").toInt() != 0) {
194 int nConfirmTarget = 25 - settings.value(
"nSmartFeeSliderPosition").toInt();
195 settings.setValue(
"nConfTarget", nConfirmTarget);
196 settings.remove(
"nSmartFeeSliderPosition");
198 if (settings.value(
"nConfTarget").toInt() == 0)
208 settings.setValue(
"nFeeRadio",
ui->
groupFee->checkedId());
221 QList<SendCoinsRecipient> recipients;
224 for(
int i = 0; i <
ui->
entries->count(); ++i)
231 recipients.append(entry->
getValue());
240 if(!valid || recipients.isEmpty())
279 QStringList formatted;
284 amount.append(
"</b>");
286 QString
address =
"<span style='font-family: monospace;'>" + rcp.address;
287 address.append(
"</span>");
289 QString recipientElement;
291 if (!rcp.paymentRequest.IsInitialized())
293 if(rcp.label.length() > 0)
296 recipientElement.append(QString(
" (%1)").arg(address));
300 recipientElement = tr(
"%1 to %2").arg(amount, address);
303 else if(!rcp.authenticatedMerchant.isEmpty())
305 recipientElement = tr(
"%1 to %2").arg(amount,
GUIUtil::HtmlEscape(rcp.authenticatedMerchant));
309 recipientElement = tr(
"%1 to %2").arg(amount, address);
312 formatted.append(recipientElement);
315 QString questionString = tr(
"Are you sure you want to send?");
316 questionString.append(
"<br /><br />%1");
321 questionString.append(
"<hr /><span style='color:#aa0000;'>");
323 questionString.append(
"</span> ");
324 questionString.append(tr(
"added as transaction fee"));
327 questionString.append(
" (" + QString::number((
double)currentTransaction.
getTransactionSize() / 1000) +
" kB)");
331 questionString.append(
"<hr />");
333 QStringList alternativeUnits;
339 questionString.append(tr(
"Total Amount %1")
341 questionString.append(QString(
"<span style='font-size:10pt;font-weight:normal;'><br />(=%2)</span>")
342 .arg(alternativeUnits.join(
" " + tr(
"or") +
"<br />")));
346 questionString.append(
"<hr /><span>");
347 questionString.append(tr(
"This transaction signals replaceability (optin-RBF)."));
348 questionString.append(
"</span>");
353 confirmationDialog.
exec();
354 QMessageBox::StandardButton retval = (QMessageBox::StandardButton)confirmationDialog.result();
356 if(retval != QMessageBox::Yes)
381 ui->
entries->takeAt(0)->widget()->deleteLater();
411 qApp->processEvents();
414 bar->setSliderPosition(bar->maximum());
434 entry->deleteLater();
441 for(
int i = 0; i <
ui->
entries->count(); ++i)
510 Q_UNUSED(unconfirmedBalance);
511 Q_UNUSED(immatureBalance);
512 Q_UNUSED(watchBalance);
514 Q_UNUSED(watchUnconfirmedBalance);
515 Q_UNUSED(watchImmatureBalance);
516 Q_UNUSED(watchStake);
534 QPair<QString, CClientUIInterface::MessageBoxFlags> msgParams;
541 switch(sendCoinsReturn.
status)
544 msgParams.first = tr(
"The recipient address is not valid. Please recheck.");
547 msgParams.first = tr(
"The amount to pay must be larger than 0.");
550 msgParams.first = tr(
"The amount exceeds your balance.");
553 msgParams.first = tr(
"The total exceeds your balance when the %1 transaction fee is included.").arg(msgArg);
556 msgParams.first = tr(
"Duplicate address found: addresses should only be used once each.");
559 msgParams.first = tr(
"Transaction creation failed!");
563 msgParams.first = tr(
"The transaction was rejected with the following reason: %1").arg(sendCoinsReturn.
reasonCommitFailed);
570 msgParams.first = tr(
"Payment request expired.");
579 Q_EMIT
message(tr(
"Send Coins"), msgParams.first, msgParams.second);
640 QColor warning_colour(255 - (lightness / 5), 176 - (lightness / 3), 48 - (lightness / 14));
699 if (!checked &&
model)
717 if (state == Qt::Unchecked)
755 QMessageBox::StandardButton btnRetVal = QMessageBox::question(
this, tr(
"Confirm custom change address"), tr(
"The address you selected for change is not part of this wallet. Any or all funds in your wallet may be sent to this address. Are you sure?"),
756 QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
758 if(btnRetVal == QMessageBox::Yes)
773 if (!associatedLabel.isEmpty())
796 for(
int i = 0; i <
ui->
entries->count(); ++i)
799 if(entry && !entry->isHidden())
828 QMessageBox(QMessageBox::Question, title, text, QMessageBox::Yes | QMessageBox::Cancel, parent), secDelay(_secDelay)
830 setDefaultButton(QMessageBox::Cancel);
840 return QMessageBox::exec();
CAmount GetFeePerK() const
Return the fee in liu for a size of 1000 bytes.
QLabel * labelCoinControlChange
void removeEntry(SendCoinsEntry *entry)
QLabel * labelCoinControlAmount
#define SetObjectStyleSheet(object, name)
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
void setValue(const SendCoinsRecipient &value)
QLabel * labelFeeEstimation
struct evm_uint256be balance(struct evm_env *env, struct evm_uint160be address)
QString reasonCommitFailed
static CCoinControl * coinControl
bool IsSpendable(const CTxDestination &dest) const
boost::optional< unsigned int > m_confirm_target
Override the default confirmation target if set.
SendCoinsRecipient getValue()
QWidget * widgetCoinControl
CAmount maxTxFee
Absolute maximum transaction fee (in liu) used by wallet and mempool (rejects high fee in sendrawtran...
UnlockContext requestUnlock()
QPushButton * clearButton
void coinControlClipboardQuantity()
void coinControlClipboardAfterFee()
void setAddress(const QString &address)
QLabel * labelCoinControlFee
base58-encoded Fabcoin addresses.
void setSingleStep(const CAmount &step)
Set single step in satoshis.
QValidatedLineEdit * lineEditCoinControlChange
#define SEND_CONFIRM_DELAY
SendCoinsReturn sendCoins(WalletModelTransaction &transaction)
void updateCoinControlState(CCoinControl &ctrl)
QString HtmlEscape(const QString &str, bool fMultiLine)
bool handlePaymentRequest(const SendCoinsRecipient &recipient)
CAmount getUnconfirmedBalance() const
QLabel * labelCoinControlAfterFee
AddressTableModel * getAddressTableModel()
QLabel * labelCoinControlQuantity
A single entry in the dialog for sending fabcoins.
QLabel * labelCoinControlLowOutput
QPushButton * pushButtonCoinControl
QLabel * labelCoinControlAutomaticallySelected
boost::optional< CFeeRate > m_feerate
Override the default payTxFee if set.
void coinControlFeatureChanged(bool)
QWidget * setupTabChain(QWidget *prev)
Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://...
static CAmount GetRequiredFee(unsigned int nTxBytes)
Return the minimum required fee taking into account the floating relay fee and user set minimum trans...
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
bool getCoinControlFeatures()
int64_t CAmount
Amount in lius (Can be negative)
QList< SendCoinsRecipient > getRecipients()
CBlockPolicyEstimator feeEstimator
static QList< CAmount > payAmounts
QWidget * setupTabChain(QWidget *prev)
Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://...
QCheckBox * checkBoxMinimumFee
void on_sendButton_clicked()
SendCoinsEntry * addEntry()
CAmount getWatchBalance() const
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
bool signalRbf
Signal BIP-125 replace by fee.
void setAddress(const QString &address)
void coinControlClipboardChange()
void setClientModel(ClientModel *clientModel)
void setClipboard(const QString &str)
ClientModel * clientModel
CTxDestination destChange
FabcoinAmountField * customFee
SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const CCoinControl &coinControl)
Dialog for sending fabcoins.
QCheckBox * checkBoxCoinControlChange
void coinControlChangeEdited(const QString &)
QStackedWidget * stackedFeeTypes
static void updateLabels(WalletModel *, QDialog *)
CAmount getTransactionFee()
CTxDestination Get() const
Model for Fabcoin network client.
void coinControlUpdateLabels()
void setModel(WalletModel *model)
int getConfTargetForIndex(int index)
CAmount getWatchImmatureBalance() const
void setupUi(QDialog *SendCoinsDialog)
bool isClear()
Return whether the entry is still empty and unedited.
void coinControlClipboardLowOutput()
QLabel * labelCoinControlChangeLabel
void updateFeeSectionControls()
void setEnabled(bool fEnabled)
Enable/Disable.
QWidget * scrollAreaWidgetContents
QLabel * labelMinFeeWarning
void setModel(WalletModel *model)
static CAmount GetMinimumFee(unsigned int nTxBytes, const CCoinControl &coin_control, const CTxMemPool &pool, const CBlockPolicyEstimator &estimator, FeeCalculation *feeCalc)
Estimate the minimum fee considering user set parameters and the required fee.
static bool fSubtractFeeFromAmount
void setValue(const CAmount &value)
void updateSmartFeeLabel()
QString labelForAddress(const QString &address) const
int getIndexForConfTarget(int target)
void updateTabsAndLabels()
const CChainParams & Params()
Return the currently selected parameters.
Interface to Fabcoin wallet from Qt view code.
CAmount getWatchStake() const
static QList< Unit > availableUnits()
Get list of units, for drop-down box.
SendCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent=0)
QLabel * labelCoinControlBytes
SendConfirmationDialog(const QString &title, const QString &text, int secDelay=SEND_CONFIRM_DELAY, QWidget *parent=0)
void setModel(WalletModel *model)
void processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg=QString())
Fee rate in liu per kilobyte: CAmount / kB.
Data model for a walletmodel transaction.
QComboBox * confTargetSelector
void setEnabled(bool enabled)
void coinControlClipboardBytes()
CAmount getImmatureBalance() const
static QString formatHtmlWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as HTML string (with unit)
bool fSubtractFeeFromAmount
const PlatformStyle * platformStyle
QString formatNiceTimeOffset(qint64 secs)
dev::WithExisting max(dev::WithExisting _a, dev::WithExisting _b)
struct evm_uint160be address(struct evm_env *env)
void coinControlClipboardAmount()
QLabel * fallbackFeeWarningLabel
CAmount getTotalTransactionAmount()
bool getDefaultWalletRbf() const
QCheckBox * radioSmartFee
void pasteEntry(const SendCoinsRecipient &rv)
QGroupBox * groupBoxCoinControl
QAbstractButton * yesButton
void message(const QString &title, const QString &message, unsigned int style)
void setDisplayUnit(int unit)
Change unit used to display amount.
CAmount getWatchUnconfirmedBalance() const
QLabel * labelCustomPerKilobyte
bool fNewRecipientAllowed
QCheckBox * radioCustomFee
void setBalance(const CAmount &balance, const CAmount &unconfirmedBalance, const CAmount &immatureBalance, const CAmount &stake, const CAmount &watchOnlyBalance, const CAmount &watchUnconfBalance, const CAmount &watchImmatureBalance, const CAmount &watchOnlyStake)
void coinControlButtonClicked()
unsigned int getTransactionSize()
int getDefaultConfirmTarget() const
void coinControlClipboardFee()
CAmount getBalance(const CCoinControl *coinControl=nullptr) const
OptionsModel * getOptionsModel()
QLabel * labelCoinControlInsuffFunds
void coinControlChangeChecked(int)