diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2012-02-17 15:26:20 +0100 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2012-02-27 12:28:39 -0500 |
commit | 33e0c3a8662a11566cbb7bd382b7f6737f8c96a2 (patch) | |
tree | 14233cd700b96a32dc502deacf77e3c47400da96 /src | |
parent | 82705af1eb521beefd63f81e3c5e39616fcf2076 (diff) | |
download | bitcoin-33e0c3a8662a11566cbb7bd382b7f6737f8c96a2.tar.xz |
Restructure IPC URL handling (fixes #851)
Diffstat (limited to 'src')
-rw-r--r-- | src/qt/guiutil.cpp | 14 | ||||
-rw-r--r-- | src/qt/guiutil.h | 1 | ||||
-rw-r--r-- | src/qt/sendcoinsdialog.cpp | 10 | ||||
-rw-r--r-- | src/qt/sendcoinsdialog.h | 1 |
4 files changed, 26 insertions, 0 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 158b84a285..bc443ceeb6 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -72,3 +72,17 @@ bool GUIUtil::parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out) } return true; } + +bool GUIUtil::parseBitcoinURL(QString url, SendCoinsRecipient *out) +{ + // Convert bitcoin:// to bitcoin: + // + // Cannot handle this later, because bitcoin:// will cause Qt to see the part after // as host, + // which will lowercase it (and thus invalidate the address). + if(url.startsWith("bitcoin://")) + { + url.replace(0, 10, "bitcoin:"); + } + QUrl urlInstance(url); + return parseBitcoinURL(&urlInstance, out); +} diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index bc4ddb8aae..129ab73038 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -29,6 +29,7 @@ public: // Parse "bitcoin:" URL into recipient object, return true on succesful parsing // See Bitcoin URL definition discussion here: https://bitcointalk.org/index.php?topic=33490.0 static bool parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out); + static bool parseBitcoinURL(QString url, SendCoinsRecipient *out); }; #endif // GUIUTIL_H diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 6d32891172..e465b4141a 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -265,6 +265,16 @@ void SendCoinsDialog::handleURL(const QUrl *url) pasteEntry(rv); } +void SendCoinsDialog::handleURL(const QString &url) +{ + SendCoinsRecipient rv; + if(!GUIUtil::parseBitcoinURL(url, &rv)) + { + return; + } + pasteEntry(rv); +} + void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance) { Q_UNUSED(unconfirmedBalance); diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h index a14f99e8b2..fdff05783e 100644 --- a/src/qt/sendcoinsdialog.h +++ b/src/qt/sendcoinsdialog.h @@ -30,6 +30,7 @@ public: void pasteEntry(const SendCoinsRecipient &rv); void handleURL(const QUrl *url); + void handleURL(const QString &url); public slots: void clear(); |