23 #include <boost/algorithm/string/case_conv.hpp> 49 const unsigned c_minorProtocolVersion = 2;
50 const unsigned c_databaseBaseVersion = 9;
51 const unsigned c_databaseVersionModifier = 0;
54 const unsigned c_databaseVersion = c_databaseBaseVersion + (c_databaseVersionModifier << 8) + (23 << 9);
63 catch (eth::InvalidICAP&) {}
66 auto b =
fromHex(_s.substr(0, 2) ==
"0x" ? _s.substr(2) : _s, WhenError::Throw);
70 catch (BadHexCharacter&) {}
71 BOOST_THROW_EXCEPTION(InvalidAddress());
74 vector<pair<u256, string>>
const&
units()
76 static const vector<pair<u256, string>> s_units =
78 {exp10<54>(),
"Uether"},
79 {exp10<51>(),
"Vether"},
80 {exp10<48>(),
"Dether"},
81 {exp10<45>(),
"Nether"},
82 {exp10<42>(),
"Yether"},
83 {exp10<39>(),
"Zether"},
84 {exp10<36>(),
"Eether"},
85 {exp10<33>(),
"Pether"},
86 {exp10<30>(),
"Tether"},
87 {exp10<27>(),
"Gether"},
88 {exp10<24>(),
"Mether"},
89 {exp10<21>(),
"grand"},
90 {exp10<18>(),
"ether"},
91 {exp10<15>(),
"finney"},
92 {exp10<12>(),
"szabo"},
114 if (b >
units()[0].first * 1000)
116 ret << (b /
units()[0].first) <<
" " <<
units()[0].second;
119 ret << setprecision(5);
120 for (
auto const& i:
units())
121 if (i.first != 1 && b >= i.first)
123 ret << (double(b / (i.first / 1000)) / 1000.0) <<
" " << i.second;
130 static void badBlockInfo(
BlockHeader const& _bi,
string const& _err)
134 string const c_space = c_border + string(76,
' ') + c_border +
EthReset;
136 ss << c_line << endl;
137 ss << c_space << endl;
138 ss << c_border +
" Import Failure " + _err + string(max<int>(0, 53 - _err.size()),
' ') +
" " + c_border << endl;
139 ss << c_space << endl;
141 ss << c_border + (
" Guru Meditation #" + string(max<int>(0, 8 - bin.size()),
'0') + bin +
"." + _bi.
hash().
abridged() +
" ") + c_border << endl;
142 ss << c_space << endl;
144 cwarn <<
"\n" + ss.str();
151 badBlockInfo(bi, _err);
154 string TransactionSkeleton::userReadable(
bool _toProxy,
function<pair<bool, string>(
TransactionSkeleton const&)>
const& _getNatSpec,
function<
string(
Address const&)>
const& _formatAddress)
const 159 return string(
"ÐApp is attempting to create a contract; ") + (_toProxy ?
"(this transaction is not executed directly, but forwarded to another ÐApp) " :
"") +
"to be endowed with " +
formatBalance(value) +
", with additional network fees of up to " +
formatBalance(gas * gasPrice) +
".\n\nMaximum total cost is " +
formatBalance(value + gas * gasPrice) +
".";
164 tie(isContract, natSpec) = _getNatSpec(*
this);
168 return "ÐApp is attempting to send " +
formatBalance(value) +
" to a recipient " + _formatAddress(to) + (_toProxy ?
" (this transaction is not executed directly, but forwarded to another ÐApp)" :
"") +
", with additional network fees of up to " +
formatBalance(gas * gasPrice) +
".\n\nMaximum total cost is " +
formatBalance(value + gas * gasPrice) +
".";
172 return "ÐApp is attempting to call into an unknown contract at address " +
173 _formatAddress(to) +
".\n\n" +
174 (_toProxy ?
"This transaction is not executed directly, but forwarded to another ÐApp.\n\n" :
"") +
175 "Call involves sending " +
176 formatBalance(value) +
" to the recipient, with additional network fees of up to " +
178 "However, this also does other stuff which we don't understand, and does so in your name.\n\n" +
179 "WARNING: This is probably going to cost you at least " +
181 ", however this doesn't include any side-effects, which could be of far greater importance.\n\n" +
182 "REJECT UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!";
184 return "ÐApp attempting to conduct contract interaction with " +
186 ": <b>" + natSpec +
"</b>.\n\n" +
187 (_toProxy ?
"This transaction is not executed directly, but forwarded to another ÐApp.\n\n" :
"") +
189 "In addition, ÐApp is attempting to send " +
190 formatBalance(value) +
" to said recipient, with additional network fees of up to " +
194 "Additional network fees are at most" +
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
const unsigned c_protocolVersion
Current protocol version.
const unsigned c_databaseVersionModifier
boost::multiprecision::number< boost::multiprecision::cpp_int_backend<>> bigint
h160 Address
An Ethereum address: 20 bytes.
std::hash for asio::adress
std::string toString(string32 const &_s)
Make normal string from fixed-length string.
bytes fromHex(std::string const &_s, WhenError _throw=WhenError::DontThrow)
void badBlock(bytesConstRef _block, string const &_err)
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
Address toAddress(std::string const &_s)
Convert the given string into an address.
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
std::string formatBalance(bigint const &_b)
User-friendly string representation of the amount _b in wei.
Encapsulation of an ICAP address.
Address const & direct() const
const unsigned c_databaseBaseVersion
const unsigned c_minorProtocolVersion
Current minor protocol version.
std::string abridged() const
const unsigned c_databaseVersion
Current database version.
#define DEV_IGNORE_EXCEPTIONS(X)
vector< pair< u256, string > > const & units()
Get information concerning the currency denominations.