From c359ac9128b9b1a6fda29a2a49da0991f835ad0e Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Sun, 7 Aug 2011 16:16:49 +0200 Subject: [PATCH] allow empty/missing amounts in URL --- src/qt/guiutil.cpp | 13 +++++++++++-- src/qt/guiutil.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 3516d4f83..6329d51d0 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -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) { diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 012e49754..5f63c16e1 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -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); };