mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-23 12:09:57 +00:00
Merge pull request #304
7cca8b8
Transfer: support OpenAlias addresses (moneromooo.monero)
This commit is contained in:
commit
ff274721f6
3 changed files with 100 additions and 8 deletions
|
@ -27,6 +27,8 @@
|
|||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.Dialogs 1.2
|
||||
import moneroComponents.PendingTransaction 1.0
|
||||
import "../components"
|
||||
import moneroComponents.Wallet 1.0
|
||||
|
@ -50,6 +52,35 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
oaPopup.icon = StandardIcon.Information
|
||||
oaPopup.onCloseCallback = null
|
||||
oaPopup.open()
|
||||
}
|
||||
|
||||
// Information dialog
|
||||
StandardDialog {
|
||||
// dynamically change onclose handler
|
||||
property var onCloseCallback
|
||||
id: oaPopup
|
||||
cancelVisible: false
|
||||
onAccepted: {
|
||||
if (onCloseCallback) {
|
||||
onCloseCallback()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: pageRoot
|
||||
|
@ -204,23 +235,74 @@ Rectangle {
|
|||
onLinkActivated: appWindow.showPageRequest("AddressBook")
|
||||
}
|
||||
// recipient address input
|
||||
LineEdit {
|
||||
id: addressLine
|
||||
RowLayout {
|
||||
id: addressLineRow
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: addressLabel.bottom
|
||||
anchors.leftMargin: 17
|
||||
anchors.rightMargin: 17
|
||||
anchors.topMargin: 5
|
||||
placeholderText: "4..."
|
||||
// validator: RegExpValidator { regExp: /[0-9A-Fa-f]{95}/g }
|
||||
|
||||
LineEdit {
|
||||
id: addressLine
|
||||
anchors.left: parent.left
|
||||
anchors.right: resolveButton.left
|
||||
anchors.leftMargin: 17
|
||||
anchors.topMargin: 5
|
||||
placeholderText: "4..."
|
||||
// validator: RegExpValidator { regExp: /[0-9A-Fa-f]{95}/g }
|
||||
}
|
||||
|
||||
StandardButton {
|
||||
id: resolveButton
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 17
|
||||
anchors.topMargin: 17
|
||||
anchors.rightMargin: 17
|
||||
width: 60
|
||||
text: qsTr("RESOLVE") + translationManager.emptyString
|
||||
shadowReleasedColor: "#FF4304"
|
||||
shadowPressedColor: "#B32D00"
|
||||
releasedColor: "#FF6C3C"
|
||||
pressedColor: "#FF4304"
|
||||
enabled : isValidOpenAliasAddress(addressLine.text)
|
||||
onClicked: {
|
||||
var result = walletManager.resolveOpenAlias(addressLine.text)
|
||||
if (result) {
|
||||
var parts = result.split("|")
|
||||
if (parts.length == 2) {
|
||||
var address_ok = walletManager.addressValid(parts[1], appWindow.persistentSettings.testnet)
|
||||
if (parts[0] === "true") {
|
||||
if (address_ok) {
|
||||
addressLine.text = parts[1]
|
||||
addressLine.cursorPosition = 0
|
||||
}
|
||||
else
|
||||
oa_message(qsTr("No valid address found at this OpenAlias address"))
|
||||
} else if (parts[0] === "false") {
|
||||
if (address_ok) {
|
||||
addressLine.text = parts[1]
|
||||
addressLine.cursorPosition = 0
|
||||
oa_message(qsTr("Address found, but the DNSSEC signatures could not be verified, so this address may be spoofed"))
|
||||
} else {
|
||||
oa_message(qsTr("No valid address found at this OpenAlias address, but the DNSSEC signatures could not be verified, so this may be spoofed"))
|
||||
}
|
||||
} else {
|
||||
oa_message(qsTr("Internal error"))
|
||||
}
|
||||
} else {
|
||||
oa_message(qsTr("Internal error"))
|
||||
}
|
||||
} else {
|
||||
oa_message(qsTr("No address found"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
id: paymentIdLabel
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: addressLine.bottom
|
||||
anchors.top: addressLineRow.bottom
|
||||
anchors.leftMargin: 17
|
||||
anchors.rightMargin: 17
|
||||
anchors.topMargin: 17
|
||||
|
|
|
@ -227,6 +227,14 @@ double WalletManager::miningHashRate() const
|
|||
return m_pimpl->miningHashRate();
|
||||
}
|
||||
|
||||
QString WalletManager::resolveOpenAlias(const QString &address) const
|
||||
{
|
||||
bool dnssec_valid = false;
|
||||
std::string res = m_pimpl->resolveOpenAlias(address.toStdString(), dnssec_valid);
|
||||
res = std::string(dnssec_valid ? "true" : "false") + "|" + res;
|
||||
return QString::fromStdString(res);
|
||||
}
|
||||
|
||||
void WalletManager::setLogLevel(int logLevel)
|
||||
{
|
||||
Monero::WalletManagerFactory::setLogLevel(logLevel);
|
||||
|
|
|
@ -116,6 +116,8 @@ public:
|
|||
|
||||
Q_INVOKABLE double getPasswordStrength(const QString &password) const;
|
||||
|
||||
Q_INVOKABLE QString resolveOpenAlias(const QString &address) const;
|
||||
|
||||
signals:
|
||||
|
||||
void walletOpened(Wallet * wallet);
|
||||
|
|
Loading…
Reference in a new issue