diff options
| author | luigi1111 <luigi1111w@gmail.com> | 2019-12-19 19:45:33 -0500 |
|---|---|---|
| committer | luigi1111 <luigi1111w@gmail.com> | 2019-12-19 19:45:33 -0500 |
| commit | b963028f102ea75622ef792968819b79a68d36bd (patch) | |
| tree | 9435a146d4198cc8d50b4848ba4f3c2ca8c27476 /pages | |
| parent | 4aac66a024bfcd4259a6133abd670bc8f7289a55 (diff) | |
| parent | a83adb70adebf4528d558372998ac348bcc6c148 (diff) | |
| download | monzero-gui-b963028f102ea75622ef792968819b79a68d36bd.tar.gz monzero-gui-b963028f102ea75622ef792968819b79a68d36bd.tar.xz monzero-gui-b963028f102ea75622ef792968819b79a68d36bd.zip | |
Merge pull request #2626
a83adb7 Transfer: improve warning flow (tobtoht)
Diffstat (limited to 'pages')
| -rw-r--r-- | pages/Transfer.qml | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/pages/Transfer.qml b/pages/Transfer.qml index e9537897..1da3f69a 100644 --- a/pages/Transfer.qml +++ b/pages/Transfer.qml @@ -193,6 +193,7 @@ Rectangle { amountLine.cursorPosition = 1; } } + amountLine.error = walletManager.amountFromString(amountLine.text) > appWindow.getUnlockedBalance() } validator: RegExpValidator { @@ -444,22 +445,8 @@ Rectangle { } } - function checkInformation(amount, address, payment_id, nettype) { - address = address.trim() - payment_id = payment_id.trim() - - var amount_ok = amount.length > 0 - var address_ok = walletManager.addressValid(address, nettype) - var payment_id_ok = payment_id.length == 0 || (payment_id.length == 64 && walletManager.paymentIdValid(payment_id)) - var ipid = walletManager.paymentIdFromAddress(address, nettype) - if (ipid.length > 0 && payment_id.length > 0) - payment_id_ok = false - - addressLine.error = !address_ok - amountLine.error = !amount_ok - paymentIdLine.error = !payment_id_ok - - return amount_ok && address_ok && payment_id_ok + function checkInformation(amount, address, nettype) { + return amount.length > 0 && walletManager.amountFromString(amountLine.text) <= appWindow.getUnlockedBalance() && TxUtils.checkAddress(address, nettype) } } // pageRoot @@ -505,7 +492,7 @@ Rectangle { id: saveTxButton text: qsTr("Create tx file") + translationManager.emptyString visible: appWindow.viewOnly - enabled: pageRoot.checkInformation(amountLine.text, addressLine.text, paymentIdLine.text, appWindow.persistentSettings.nettype) + enabled: pageRoot.checkInformation(amountLine.text, addressLine.text, appWindow.persistentSettings.nettype) small: true onClicked: { console.log("Transfer: saveTx Clicked") @@ -772,7 +759,7 @@ Rectangle { } // There are sufficient unlocked funds available - if(parseFloat(amountLine.text) > parseFloat(middlePanel.unlockedBalanceText)){ + if(walletManager.amountFromString(amountLine.text) > appWindow.getUnlockedBalance()){ root.sendButtonWarning = qsTr("Amount is more than unlocked balance.") + translationManager.emptyString; return false; } @@ -782,10 +769,19 @@ Rectangle { return false; } - // The transactional information is correct - if(!pageRoot.checkInformation(amountLine.text, addressLine.text, paymentIdLine.text, appWindow.persistentSettings.nettype)){ - if(amountLine.text && addressLine.text) - root.sendButtonWarning = qsTr("Transaction information is incorrect.") + translationManager.emptyString; + if (addressLine.text == "") { + return false; + } + + // Address is valid + if(!TxUtils.checkAddress(addressLine.text, appWindow.persistentSettings.nettype)){ + root.sendButtonWarning = qsTr("Address is invalid.") + translationManager.emptyString; + return false; + } + + // Amount is nonzero + if (!amountLine.text || parseFloat(amountLine.text) <= 0) { + root.sendButtonWarning = qsTr("Enter an amount.") + translationManager.emptyString; return false; } |
