MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / parse

Method parse

src/qt/bitcoinunits.cpp:156–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154
155
156bool BitcoinUnits::parse(int unit, const QString &value, CAmount *val_out)
157{
158 if(!valid(unit) || value.isEmpty())
159 return false; // Refuse to parse invalid unit or empty string
160 int num_decimals = decimals(unit);
161
162 // Ignore spaces and thin spaces when parsing
163 QStringList parts = removeSpaces(value).split(".");
164
165 if(parts.size() > 2)
166 {
167 return false; // More than one dot
168 }
169 QString whole = parts[0];
170 QString decimals;
171
172 if(parts.size() > 1)
173 {
174 decimals = parts[1];
175 }
176 if(decimals.size() > num_decimals)
177 {
178 return false; // Exceeds max precision
179 }
180 bool ok = false;
181 QString str = whole + decimals.leftJustified(num_decimals, '0');
182
183 if(str.size() > 18)
184 {
185 return false; // Longer numbers will exceed 63 bits
186 }
187 CAmount retvalue(str.toLongLong(&ok));
188 if(val_out)
189 {
190 *val_out = retvalue;
191 }
192 return ok;
193}
194
195QString BitcoinUnits::getAmountColumnTitle(int unit)
196{

Callers 5

SerializationOpFunction · 0.45
netRequestFinishedMethod · 0.45
toHTMLMethod · 0.45
paymentServerTestsMethod · 0.45

Calls 1

sizeMethod · 0.45

Tested by 1

paymentServerTestsMethod · 0.36