MCPcopy Create free account
hub / github.com/ElementsProject/elements / parseBitcoinURI

Function parseBitcoinURI

src/qt/guiutil.cpp:143–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
144{
145 // return if URI is not valid or incorrect scheme
146 bool valid_liquid = g_con_elementsmode && (uri.scheme() == QString("liquidnetwork") || uri.scheme() == QString("liquidtestnet"));
147 bool valid_bitcoin = !g_con_elementsmode && (uri.scheme() == QString("bitcoin"));
148 if (!uri.isValid() || !(valid_liquid || valid_bitcoin))
149 return false;
150
151 SendCoinsRecipient rv;
152 rv.address = uri.path();
153 // Trim any following forward slash which may have been added by the OS
154 if (rv.address.endsWith("/")) {
155 rv.address.truncate(rv.address.length() - 1);
156 }
157 rv.amount = 0;
158
159 QUrlQuery uriQuery(uri);
160 QList<QPair<QString, QString> > items = uriQuery.queryItems();
161 for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++)
162 {
163 bool fShouldReturnFalse = false;
164 if (i->first.startsWith("req-"))
165 {
166 i->first.remove(0, 4);
167 fShouldReturnFalse = true;
168 }
169
170 if (i->first == "label")
171 {
172 rv.label = i->second;
173 fShouldReturnFalse = false;
174 }
175 if (i->first == "message")
176 {
177 rv.message = i->second;
178 fShouldReturnFalse = false;
179 }
180 else if (i->first == "amount")
181 {
182 if(!i->second.isEmpty())
183 {
184 if(!BitcoinUnits::parse(BitcoinUnits::BTC, i->second, &rv.amount))
185 {
186 return false;
187 }
188 }
189 fShouldReturnFalse = false;
190 }
191
192 if (fShouldReturnFalse)
193 return false;
194 }
195 if(out)
196 {
197 *out = rv;
198 }
199 return true;
200}

Callers 4

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

Calls 6

parseFunction · 0.85
pathMethod · 0.80
isValidMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
removeMethod · 0.45

Tested by 1

uriTestsMethod · 0.68