mirror of
https://github.com/feather-wallet/feather.git
synced 2025-01-09 20:39:58 +00:00
Send: allow 'all' in Fiat mode
This commit is contained in:
parent
0a2d911170
commit
c26793da56
1 changed files with 25 additions and 23 deletions
|
@ -142,11 +142,9 @@ void SendWidget::sendClicked() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString currency = ui->comboCurrencySelection->currentText();
|
|
||||||
QString recipient = ui->lineAddress->text().simplified().remove(' ');
|
QString recipient = ui->lineAddress->text().simplified().remove(' ');
|
||||||
QString description = ui->lineDescription->text();
|
|
||||||
if (recipient.isEmpty()) {
|
if (recipient.isEmpty()) {
|
||||||
QMessageBox::warning(this, "Malformed recipient", "No destination address was entered.");
|
QMessageBox::warning(this, "Error", "No destination address was entered.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,13 +156,15 @@ void SendWidget::sendClicked() {
|
||||||
errorText += QString("Line #%1:\n%2\n").arg(QString::number(error.idx + 1), error.error);
|
errorText += QString("Line #%1:\n%2\n").arg(QString::number(error.idx + 1), error.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox::warning(this, "Warning", QString("Invalid lines found:\n\n%1").arg(errorText));
|
QMessageBox::warning(this, "Error", QString("Invalid lines found:\n\n%1").arg(errorText));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString description = ui->lineDescription->text();
|
||||||
|
|
||||||
if (!outputs.empty()) { // multi destination transaction
|
if (!outputs.empty()) { // multi destination transaction
|
||||||
if (outputs.size() > 16) {
|
if (outputs.size() > 16) {
|
||||||
QMessageBox::warning(this, "Warning", "Maximum number of outputs (16) exceeded.");
|
QMessageBox::warning(this, "Error", "Maximum number of outputs (16) exceeded.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,23 +179,21 @@ void SendWidget::sendClicked() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 amount;
|
|
||||||
if (currency == "XMR") {
|
|
||||||
amount = this->amount();
|
|
||||||
bool sendAll = (ui->lineAmount->text() == "all");
|
bool sendAll = (ui->lineAmount->text() == "all");
|
||||||
|
QString currency = ui->comboCurrencySelection->currentText();
|
||||||
|
quint64 amount = this->amount();
|
||||||
|
|
||||||
if (amount == 0 && !sendAll) {
|
if (amount == 0 && !sendAll) {
|
||||||
QMessageBox::warning(this, "Amount error", "No amount was entered.");
|
QMessageBox::warning(this, "Error", "No amount was entered.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_ctx->onCreateTransaction(recipient, amount, description, sendAll);
|
|
||||||
} else {
|
if (currency != "XMR" && !sendAll) {
|
||||||
|
// Convert fiat amount to XMR, but only if we're not sending the entire balance
|
||||||
amount = WalletManager::amountFromDouble(this->conversionAmount());
|
amount = WalletManager::amountFromDouble(this->conversionAmount());
|
||||||
if (amount == 0) {
|
|
||||||
QMessageBox::warning(this, "Fiat conversion error", "Could not create transaction.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_ctx->onCreateTransaction(recipient, amount, description, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_ctx->onCreateTransaction(recipient, amount, description, sendAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendWidget::aliasClicked() {
|
void SendWidget::aliasClicked() {
|
||||||
|
@ -248,10 +246,14 @@ double SendWidget::conversionAmount() {
|
||||||
quint64 SendWidget::amount() {
|
quint64 SendWidget::amount() {
|
||||||
// grab amount from "amount" text box
|
// grab amount from "amount" text box
|
||||||
QString amount = ui->lineAmount->text();
|
QString amount = ui->lineAmount->text();
|
||||||
if (amount == "all") return 0;
|
if (amount == "all") {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
amount.replace(',', '.');
|
amount.replace(',', '.');
|
||||||
if (amount.isEmpty()) return 0;
|
if (amount.isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return WalletManager::amountFromString(amount);
|
return WalletManager::amountFromString(amount);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue