| 164 | } |
| 165 | |
| 166 | bool parseBitcoinURI(const QUrl& uri, SendCoinsRecipient* out) |
| 167 | { |
| 168 | // return if URI is not valid or is no LUX: URI |
| 169 | if (!uri.isValid() || uri.scheme() != QString(URI_SCHEME)) |
| 170 | return false; |
| 171 | |
| 172 | SendCoinsRecipient rv; |
| 173 | rv.address = uri.path(); |
| 174 | // Trim any following forward slash which may have been added by the OS |
| 175 | if (rv.address.endsWith("/")) { |
| 176 | rv.address.truncate(rv.address.length() - 1); |
| 177 | } |
| 178 | rv.amount = 0; |
| 179 | |
| 180 | #if QT_VERSION < 0x050000 |
| 181 | QList<QPair<QString, QString> > items = uri.queryItems(); |
| 182 | #else |
| 183 | QUrlQuery uriQuery(uri); |
| 184 | QList<QPair<QString, QString> > items = uriQuery.queryItems(); |
| 185 | #endif |
| 186 | for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++) { |
| 187 | bool fShouldReturnFalse = false; |
| 188 | if (i->first.startsWith("req-")) { |
| 189 | i->first.remove(0, 4); |
| 190 | fShouldReturnFalse = true; |
| 191 | } |
| 192 | |
| 193 | if (i->first == "label") { |
| 194 | rv.label = i->second; |
| 195 | fShouldReturnFalse = false; |
| 196 | } |
| 197 | if (i->first == "message") { |
| 198 | rv.message = i->second; |
| 199 | fShouldReturnFalse = false; |
| 200 | } else if (i->first == "amount") { |
| 201 | if (!i->second.isEmpty()) { |
| 202 | if (!BitcoinUnits::parse(BitcoinUnits::LUX, i->second, &rv.amount)) { |
| 203 | return false; |
| 204 | } |
| 205 | } |
| 206 | fShouldReturnFalse = false; |
| 207 | } |
| 208 | |
| 209 | if (fShouldReturnFalse) |
| 210 | return false; |
| 211 | } |
| 212 | if (out) { |
| 213 | *out = rv; |
| 214 | } |
| 215 | return true; |
| 216 | } |
| 217 | |
| 218 | bool parseBitcoinURI(QString uri, SendCoinsRecipient* out) |
| 219 | { |