Fabcoin Core  0.16.2
P2P Digital Currency
CommonJS.h
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
24 #pragma once
25 
26 #include <string>
27 #include <libdevcore/CommonJS.h>
28 #include <libdevcrypto/Common.h>
29 #include "Common.h"
30 
31 // devcrypto
32 
33 namespace dev
34 {
35 
37 inline Public jsToPublic(std::string const& _s) { return jsToFixed<sizeof(dev::Public)>(_s); }
38 
40 inline Secret jsToSecret(std::string const& _s) { h256 d = jsToFixed<sizeof(dev::Secret)>(_s); Secret ret(d); d.ref().cleanse(); return ret; }
41 
43 inline Address jsToAddress(std::string const& _s) { return eth::toAddress(_s); }
44 
46 std::string prettyU256(u256 _n, bool _abridged = true);
47 
48 }
49 
50 
51 // ethcore
52 namespace dev
53 {
54 namespace eth
55 {
56 
58 BlockNumber jsToBlockNumber(std::string const& _js);
59 
60 }
61 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
void cleanse()
Securely overwrite the memory.
Definition: vector_ref.h:74
unsigned BlockNumber
Definition: Common.h:72
BlockNumber jsToBlockNumber(std::string const &_js)
Convert to a block number, a bit like jsToInt, except that it correctly recognises "pending" and "lat...
Definition: CommonJS.cpp:62
std::string prettyU256(u256 _n, bool _abridged)
Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHa...
Definition: CommonJS.cpp:29
bytesRef ref()
Definition: FixedHash.h:133
Address jsToAddress(std::string const &_s)
Leniently convert string to Address (h160). Accepts integers, "0x" prefixing, non-exact length...
Definition: CommonJS.h:43
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
Definition: FixedHash.h:47
Public jsToPublic(std::string const &_s)
Leniently convert string to Public (h512). Accepts integers, "0x" prefixing, non-exact length...
Definition: CommonJS.h:37
Address toAddress(std::string const &_s)
Convert the given string into an address.
Definition: Common.cpp:56
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
Definition: Common.h:125
#define d(i)
Definition: sha.cpp:732
Secret jsToSecret(std::string const &_s)
Leniently convert string to Secret (h256). Accepts integers, "0x" prefixing, non-exact length...
Definition: CommonJS.h:40