Browse Source

allow empty/missing amounts in URL

0.8
Wladimir J. van der Laan 13 years ago
parent
commit
c359ac9128
  1. 11
      src/qt/guiutil.cpp
  2. 1
      src/qt/guiutil.h

11
src/qt/guiutil.cpp

@ -53,10 +53,19 @@ bool GUIUtil::parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out)
SendCoinsRecipient rv; SendCoinsRecipient rv;
rv.address = url->path(); rv.address = url->path();
rv.label = url->queryItemValue("label"); rv.label = url->queryItemValue("label");
if(!BitcoinUnits::parse(BitcoinUnits::BTC, url->queryItemValue("amount"), &rv.amount))
QString amount = url->queryItemValue("amount");
if(amount.isEmpty())
{
rv.amount = 0;
}
else // Amount is non-empty
{
if(!BitcoinUnits::parse(BitcoinUnits::BTC, amount, &rv.amount))
{ {
return false; return false;
} }
}
if(out) if(out)
{ {
*out = rv; *out = rv;

1
src/qt/guiutil.h

@ -27,6 +27,7 @@ public:
static void setupAmountWidget(QLineEdit *widget, QWidget *parent); static void setupAmountWidget(QLineEdit *widget, QWidget *parent);
// Parse "bitcoin:" URL into recipient object, return true on succesful parsing // 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(const QUrl *url, SendCoinsRecipient *out);
}; };

Loading…
Cancel
Save