MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / parseBitcoinURI

Function parseBitcoinURI

src/qt/guiutil.cpp:126–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126bool 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 }

Callers 4

ipcParseCommandLineMethod · 0.85
handleURIOrFileMethod · 0.85
acceptMethod · 0.85
uriTestsMethod · 0.85

Calls 5

uriPrefixFunction · 0.85
parseFunction · 0.85
isValidMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by 1

uriTestsMethod · 0.68