openalias: handle address validation correctly

This commit is contained in:
mmbyday 2018-12-19 13:37:52 -08:00
parent 7c0a557e62
commit 67787421e1
3 changed files with 12 additions and 12 deletions

View file

@ -55,7 +55,7 @@ TextArea {
if(addressValidation){
// js replacement for `RegExpValidator { regExp: /[0-9A-Fa-f]{95}/g }`
textArea.text = textArea.text.replace(/[^a-z0-9.@]/gi,'');
var address_ok = TxUtils.checkAddress(textArea.text, appWindow.persistentSettings.nettype);
var address_ok = TxUtils.checkAddress(textArea.text, appWindow.persistentSettings.nettype) || TxUtils.isValidOpenAliasAddress(textArea.text);
if(!address_ok) error = true;
else error = false;
TextArea.cursorPosition = textArea.text.length;

View file

@ -56,3 +56,11 @@ function checkSignature(signature) {
return false;
}
function isValidOpenAliasAddress(address) {
address = address.trim()
var dot = address.indexOf('.')
if (dot < 0)
return false
// we can get an awful lot of valid domains, including non ASCII chars... accept anything
return true
}

View file

@ -35,6 +35,7 @@ import moneroComponents.Wallet 1.0
import "../components"
import "../components" as MoneroComponents
import "." 1.0
import "../js/TxUtils.js" as TxUtils
Rectangle {
@ -51,15 +52,6 @@ Rectangle {
Clipboard { id: clipboard }
function isValidOpenAliasAddress(address) {
address = address.trim()
var dot = address.indexOf('.')
if (dot < 0)
return false
// we can get an awful lot of valid domains, including non ASCII chars... accept anything
return true
}
function oa_message(text) {
oaPopup.title = qsTr("OpenAlias error") + translationManager.emptyString
oaPopup.text = text
@ -249,8 +241,8 @@ Rectangle {
id: resolveButton
width: 80
text: qsTr("Resolve") + translationManager.emptyString
visible: isValidOpenAliasAddress(addressLine.text)
enabled : isValidOpenAliasAddress(addressLine.text)
visible: TxUtils.isValidOpenAliasAddress(addressLine.text)
enabled : visible
onClicked: {
var result = walletManager.resolveOpenAlias(addressLine.text)
if (result) {