MCPcopy Create free account
hub / github.com/LUX-Core/lux / parse

Method parse

src/qt/bitcoinunits.cpp:223–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223bool BitcoinUnits::parse(int unit, const QString& value, CAmount* val_out)
224{
225 if (!valid(unit) || value.isEmpty())
226 return false; // Refuse to parse invalid unit or empty string
227 int num_decimals = decimals(unit);
228
229 // Ignore spaces and thin spaces when parsing
230 QStringList parts = removeSpaces(value).split(".");
231
232 if (parts.size() > 2) {
233 return false; // More than one dot
234 }
235 QString whole = parts[0];
236 QString decimals;
237
238 if (parts.size() > 1) {
239 decimals = parts[1];
240 }
241 if (decimals.size() > num_decimals) {
242 return false; // Exceeds max precision
243 }
244 bool ok = false;
245 QString str = whole + decimals.leftJustified(num_decimals, '0');
246
247 if (str.size() > 18) {
248 return false; // Longer numbers will exceed 63 bits
249 }
250 CAmount retvalue(str.toLongLong(&ok));
251 if(val_out)
252 {
253 *val_out = retvalue;
254 }
255 return ok;
256}
257
258bool BitcoinUnits::parseToken(int decimal_units, const QString &value, int256_t *val_out)
259{

Callers 7

loadJsonFromFileMethod · 0.45
traceTransactionMethod · 0.45
admin_eth_vmTraceMethod · 0.45
SerializationOpFunction · 0.45
netRequestFinishedMethod · 0.45
Q_FOREACHFunction · 0.45

Calls 2

isEmptyMethod · 0.45
sizeMethod · 0.45

Tested by 1

loadJsonFromFileMethod · 0.36