allow empty/missing amounts in URL
authorWladimir J. van der Laan <laanwj@gmail.com>
Sun, 7 Aug 2011 14:16:49 +0000 (16:16 +0200)
committerWladimir J. van der Laan <laanwj@gmail.com>
Sun, 7 Aug 2011 14:17:02 +0000 (16:17 +0200)
src/qt/guiutil.cpp
src/qt/guiutil.h

index 3516d4f..6329d51 100644 (file)
@@ -53,9 +53,18 @@ bool GUIUtil::parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out)
     SendCoinsRecipient rv;
     rv.address = url->path();
     rv.label = url->queryItemValue("label");
-    if(!BitcoinUnits::parse(BitcoinUnits::BTC, url->queryItemValue("amount"), &rv.amount))
+
+    QString amount = url->queryItemValue("amount");
+    if(amount.isEmpty())
     {
-        return false;
+        rv.amount = 0;
+    }
+    else // Amount is non-empty
+    {
+        if(!BitcoinUnits::parse(BitcoinUnits::BTC, amount, &rv.amount))
+        {
+            return false;
+        }
     }
     if(out)
     {
index 012e497..5f63c16 100644 (file)
@@ -27,6 +27,7 @@ public:
     static void setupAmountWidget(QLineEdit *widget, QWidget *parent);
 
     // 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);
 };