aboutsummaryrefslogtreecommitdiff
path: root/main.qml
diff options
context:
space:
mode:
authorxiphon <xiphon@protonmail.com>2021-02-02 16:00:46 +0000
committerxiphon <xiphon@protonmail.com>2021-03-03 00:53:51 +0000
commit92a2ae1a117eac6190f486cf48b6066fe7f205eb (patch)
tree22b96350258dcb012ec612566da8faae9c60fb92 /main.qml
parentc073867657d877940ccd826451b3e583d7934231 (diff)
downloadmonzero-gui-92a2ae1a117eac6190f486cf48b6066fe7f205eb.tar.gz
monzero-gui-92a2ae1a117eac6190f486cf48b6066fe7f205eb.tar.xz
monzero-gui-92a2ae1a117eac6190f486cf48b6066fe7f205eb.zip
TxConfirmationDialog: implement multiple recipients support, layout fixes
Diffstat (limited to 'main.qml')
-rw-r--r--main.qml61
1 files changed, 31 insertions, 30 deletions
diff --git a/main.qml b/main.qml
index 42ca1305..54cdbdab 100644
--- a/main.qml
+++ b/main.qml
@@ -852,48 +852,49 @@ ApplicationWindow {
}
}
+ function getDisplayAmountTotal(recipients) {
+ const amounts = recipients.map(function (recipient) {
+ return recipient.amount;
+ });
+ const total = walletManager.amountsSumFromStrings(amounts);
+ return Utils.removeTrailingZeros(walletManager.displayAmount(total));
+ }
// called on "transfer"
- function handlePayment(address, paymentId, amount, mixinCount, priority, description, createFile) {
+ function handlePayment(recipients, paymentId, mixinCount, priority, description, createFile) {
console.log("Creating transaction: ")
- console.log("\taddress: ", address,
+ console.log("\trecipients: ", recipients,
", payment_id: ", paymentId,
- ", amount: ", amount,
", mixins: ", mixinCount,
", priority: ", priority,
", description: ", description);
- txConfirmationPopup.bottomTextAnimation.running = false
- txConfirmationPopup.bottomText.text = qsTr("Creating transaction...") + translationManager.emptyString;
- txConfirmationPopup.transactionAddress = address;
- txConfirmationPopup.transactionAmount = Utils.removeTrailingZeros(amount);
- txConfirmationPopup.transactionPriority = priority;
- txConfirmationPopup.transactionDescription = description;
- // validate amount;
- if (amount !== "(all)") {
- var amountxmr = walletManager.amountFromString(amount);
- console.log("integer amount: ", amountxmr);
- console.log("integer unlocked", currentWallet.unlockedBalance())
- if (amountxmr <= 0) {
- txConfirmationPopup.errorText.text = qsTr("Amount is wrong: expected number from %1 to %2")
- .arg(walletManager.displayAmount(0))
- .arg(walletManager.displayAmount(currentWallet.unlockedBalance()))
- + translationManager.emptyString;
- return;
- } else if (amountxmr > currentWallet.unlockedBalance()) {
- txConfirmationPopup.errorText.text = qsTr("Insufficient funds. Unlocked balance: %1")
- .arg(walletManager.displayAmount(currentWallet.unlockedBalance()))
- + translationManager.emptyString;
- return;
- }
+ const recipientAll = recipients.find(function (recipient) {
+ return recipient.amount == "(all)";
+ });
+ if (recipientAll && recipients.length > 1) {
+ throw "Sending all requires one destination address";
}
+ txConfirmationPopup.bottomTextAnimation.running = false;
+ txConfirmationPopup.bottomText.text = qsTr("Creating transaction...") + translationManager.emptyString;
+ txConfirmationPopup.recipients = recipients;
+ txConfirmationPopup.transactionAmount = recipientAll ? "(all)" : getDisplayAmountTotal(recipients);
+ txConfirmationPopup.transactionPriority = priority;
+ txConfirmationPopup.transactionDescription = description;
txConfirmationPopup.open();
- if (amount === "(all)")
- currentWallet.createTransactionAllAsync(address, paymentId, mixinCount, priority);
- else
- currentWallet.createTransactionAsync([address], paymentId, [amountxmr], mixinCount, priority);
+ if (recipientAll) {
+ currentWallet.createTransactionAllAsync(recipientAll.address, paymentId, mixinCount, priority);
+ } else {
+ const addresses = recipients.map(function (recipient) {
+ return recipient.address;
+ });
+ const amountsxmr = recipients.map(function (recipient) {
+ return walletManager.amountFromString(recipient.amount);
+ });
+ currentWallet.createTransactionAsync(addresses, paymentId, amountsxmr, mixinCount, priority);
+ }
}
//Choose where to save transaction