aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorselsta <selsta@sent.at>2021-09-05 05:48:50 +0200
committerselsta <selsta@sent.at>2021-09-05 05:52:56 +0200
commitf327d20deb08d948829d2c2214af3cc3ac254456 (patch)
tree71eed0c54fd26c39e1f3ecf7e92a92cbfd9e4831
parentdcc16a44bee19c5e99cc967268e6a1428decf27a (diff)
downloadmonzero-gui-f327d20deb08d948829d2c2214af3cc3ac254456.tar.gz
monzero-gui-f327d20deb08d948829d2c2214af3cc3ac254456.tar.xz
monzero-gui-f327d20deb08d948829d2c2214af3cc3ac254456.zip
qml: use libwalletqt make_uri function
-rw-r--r--js/TxUtils.js27
-rw-r--r--pages/Receive.qml9
-rw-r--r--pages/merchant/Merchant.qml6
3 files changed, 7 insertions, 35 deletions
diff --git a/js/TxUtils.js b/js/TxUtils.js
index 42a5d449..63405338 100644
--- a/js/TxUtils.js
+++ b/js/TxUtils.js
@@ -73,30 +73,3 @@ function isValidOpenAliasAddress(address) {
// we can get an awful lot of valid domains, including non ASCII chars... accept anything
return true
}
-
-function makeQRCodeString(addr, amount, txDescription, recipientName) {
- var XMR_URI_SCHEME = "monero:"
- var XMR_AMOUNT = "tx_amount"
- var XMR_RECIPIENT_NAME = "recipient_name"
- var XMR_TX_DESCRIPTION = "tx_description"
- var qrCodeString =""
- qrCodeString += (XMR_URI_SCHEME + addr)
- if (amount !== undefined && amount !== ""){
- qrCodeString += ("?" + XMR_AMOUNT + "=" + amount)
- }
- if (txDescription !== undefined && txDescription !== ""){
- if (amount == ""){
- qrCodeString += ("?" + XMR_TX_DESCRIPTION + "=" + encodeURI(txDescription))
- } else {
- qrCodeString += ("&" + XMR_TX_DESCRIPTION + "=" + encodeURI(txDescription))
- }
- }
- if (recipientName !== undefined && recipientName !== ""){
- if (amount == "" && txDescription == ""){
- qrCodeString += ("?" + XMR_RECIPIENT_NAME + "=" + encodeURI(recipientName))
- } else {
- qrCodeString += ("&" + XMR_RECIPIENT_NAME + "=" + encodeURI(recipientName))
- }
- }
- return qrCodeString
-}
diff --git a/pages/Receive.qml b/pages/Receive.qml
index 5282a106..6045c324 100644
--- a/pages/Receive.qml
+++ b/pages/Receive.qml
@@ -63,12 +63,11 @@ Rectangle {
function generateQRCodeString() {
if (pageReceive.state == "PaymentRequest") {
- return TxUtils.makeQRCodeString(appWindow.current_address,
- (amountToReceiveXMR.text != "" && parseFloat(amountToReceiveXMR.text) != 0 ? amountToReceiveXMR.text : ""),
- (txDescriptionInput.text != "" ? txDescriptionInput.text : ""),
- (receiverNameInput.text != "" ? receiverNameInput.text : ""));
+ return walletManager.make_uri(appWindow.current_address,
+ walletManager.amountFromString(amountToReceiveXMR.text),
+ txDescriptionInput.text, receiverNameInput.text);
} else {
- return TxUtils.makeQRCodeString(appWindow.current_address);
+ return walletManager.make_uri(appWindow.current_address);
}
}
diff --git a/pages/merchant/Merchant.qml b/pages/merchant/Merchant.qml
index 3722a7a6..e17ed870 100644
--- a/pages/merchant/Merchant.qml
+++ b/pages/merchant/Merchant.qml
@@ -211,7 +211,7 @@ Item {
smooth: false
fillMode: Image.PreserveAspectFit
- source: "image://qrcode/" + TxUtils.makeQRCodeString(appWindow.current_address, amountToReceive.text)
+ source: "image://qrcode/" + walletManager.make_uri(appWindow.current_address, walletManager.amountFromString(amountToReceive.text))
MouseArea {
anchors.fill: parent
@@ -400,7 +400,7 @@ Item {
font.pixelSize: 12
font.bold: true
color: _color
- text: TxUtils.makeQRCodeString(appWindow.current_address, amountToReceive.text)
+ text: walletManager.make_uri(appWindow.current_address, walletManager.amountFromString(amountToReceive.text))
themeTransition: false
MouseArea {
@@ -685,7 +685,7 @@ Item {
selectExisting: false
nameFilters: ["Image (*.png)"]
onAccepted: {
- if(!walletManager.saveQrCode(TxUtils.makeQRCodeString(appWindow.current_address, amountToReceive.text), walletManager.urlToLocalPath(fileUrl))) {
+ if (!walletManager.saveQrCode(walletManager.make_uri(appWindow.current_address, walletManager.amountFromString(amountToReceive.text)), walletManager.urlToLocalPath(fileUrl))) {
console.log("Failed to save QrCode to file " + walletManager.urlToLocalPath(fileUrl) )
receivePageDialog.title = qsTr("Save QrCode") + translationManager.emptyString;
receivePageDialog.text = qsTr("Failed to save QrCode to ") + walletManager.urlToLocalPath(fileUrl) + translationManager.emptyString;