mirror of
https://github.com/monero-project/monero-gui.git
synced 2026-04-21 15:07:27 -04:00
main: use WalletManager URI parser in handler
This commit is contained in:
44
main.qml
44
main.qml
@@ -445,43 +445,25 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onUriHandler(uri){
|
function onUriHandler(uri){
|
||||||
if(uri.startsWith("monero://")){
|
if (uri && (uri.startsWith("monero://") || uri.startsWith("monero:"))) {
|
||||||
var address = uri.substring("monero://".length);
|
const normalizedUri = uri.replace("monero://", "monero:");
|
||||||
|
const parsed = walletManager.parse_uri_to_object(normalizedUri);
|
||||||
|
|
||||||
var params = {}
|
if (parsed.error) {
|
||||||
if(address.length === 0) return;
|
console.log("Invalid Monero URI: " + parsed.error);
|
||||||
var spl = address.split("?");
|
} else {
|
||||||
|
middlePanel.transferView.sendTo(
|
||||||
|
parsed.address || "",
|
||||||
|
parsed.payment_id || "",
|
||||||
|
parsed.tx_description || "",
|
||||||
|
parsed.amount || ""
|
||||||
|
);
|
||||||
|
|
||||||
if(spl.length > 2) return;
|
|
||||||
if(spl.length >= 1) {
|
|
||||||
// parse additional params
|
|
||||||
address = spl[0];
|
|
||||||
|
|
||||||
if(spl.length === 2){
|
|
||||||
spl.shift();
|
|
||||||
var item = spl[0];
|
|
||||||
|
|
||||||
var _spl = item.split("&");
|
|
||||||
for (var param in _spl){
|
|
||||||
var _item = _spl[param];
|
|
||||||
if(!_item.indexOf("=") > 0) continue;
|
|
||||||
|
|
||||||
var __spl = _item.split("=");
|
|
||||||
if(__spl.length !== 2) continue;
|
|
||||||
|
|
||||||
params[__spl[0]] = __spl[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill fields
|
|
||||||
middlePanel.transferView.sendTo(address, params["tx_payment_id"], params["tx_description"], params["tx_amount"]);
|
|
||||||
|
|
||||||
// Raise window
|
|
||||||
appWindow.raise();
|
appWindow.raise();
|
||||||
appWindow.show();
|
appWindow.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onWalletConnectionStatusChanged(status){
|
function onWalletConnectionStatusChanged(status){
|
||||||
console.log("Wallet connection status changed " + status)
|
console.log("Wallet connection status changed " + status)
|
||||||
|
|||||||
Reference in New Issue
Block a user