| 124 | } |
| 125 | |
| 126 | bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out) |
| 127 | { |
| 128 | // return if URI is not valid or is no bitcoin: URI |
| 129 | if(!uri.isValid() || uri.scheme() != uriPrefix()) |
| 130 | return false; |
| 131 | |
| 132 | SendCoinsRecipient rv; |
| 133 | rv.address = uri.path(); |
| 134 | // Trim any following forward slash which may have been added by the OS |
| 135 | if (rv.address.endsWith("/")) { |
| 136 | rv.address.truncate(rv.address.length() - 1); |
| 137 | } |
| 138 | rv.amount = 0; |
| 139 | |
| 140 | #if QT_VERSION < 0x050000 |
| 141 | QList<QPair<QString, QString> > items = uri.queryItems(); |
| 142 | #else |
| 143 | QUrlQuery uriQuery(uri); |
| 144 | QList<QPair<QString, QString> > items = uriQuery.queryItems(); |
| 145 | #endif |
| 146 | for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++) |
| 147 | { |
| 148 | bool fShouldReturnFalse = false; |
| 149 | if (i->first.startsWith("req-")) |
| 150 | { |
| 151 | i->first.remove(0, 4); |
| 152 | fShouldReturnFalse = true; |
| 153 | } |
| 154 | |
| 155 | if (i->first == "label") |
| 156 | { |
| 157 | rv.label = i->second; |
| 158 | fShouldReturnFalse = false; |
| 159 | } |
| 160 | if (i->first == "message") |
| 161 | { |
| 162 | rv.message = i->second; |
| 163 | fShouldReturnFalse = false; |
| 164 | } |
| 165 | else if (i->first == "amount") |
| 166 | { |
| 167 | if(!i->second.isEmpty()) |
| 168 | { |
| 169 | if(!BitcoinUnits::parse(BitcoinUnits::BTC, i->second, &rv.amount)) |
| 170 | { |
| 171 | return false; |
| 172 | } |
| 173 | } |
| 174 | fShouldReturnFalse = false; |
| 175 | } |
| 176 | |
| 177 | if (fShouldReturnFalse) |
| 178 | return false; |
| 179 | } |
| 180 | if(out) |
| 181 | { |
| 182 | *out = rv; |
| 183 | } |