Browse Source

Merge branch 'develop' of github.com:ethereum/cpp-ethereum into develop

cl-refactor
Gav Wood 10 years ago
parent
commit
b4fb58053b
  1. 6
      CMakeLists.txt
  2. 8
      alethzero/MainWin.cpp
  3. 118
      eth/main.cpp
  4. 2
      ethkey/KeyAux.h
  5. 5
      libdevcore/Base64.h
  6. 10
      libdevcore/Common.h
  7. 7
      libdevcore/Worker.h
  8. 21
      libdevcrypto/Common.cpp
  9. 6
      libdevcrypto/Common.h
  10. 163
      libdevcrypto/WordList.cpp
  11. 21
      libethcore/CommonJS.cpp
  12. 5
      libethcore/CommonJS.h
  13. 17
      libethcore/ICAP.cpp
  14. 5
      libethcore/ICAP.h
  15. 2
      libethcore/KeyManager.h
  16. 3
      libethereum/Block.cpp
  17. 1
      libethereum/BlockChainSync.cpp
  18. 1
      libethereum/DownloadMan.cpp
  19. 3
      libethereum/DownloadMan.h
  20. 2
      libethereum/Executive.cpp
  21. 3
      libethereum/State.cpp
  22. 1
      libethereum/TransactionQueue.cpp
  23. 9
      libethereum/TransactionQueue.h
  24. 2
      libethereum/VerifiedBlock.h
  25. 17
      libevmasm/SourceLocation.h
  26. 6
      libjsconsole/JSConsole.h
  27. 14
      libp2p/Common.h
  28. 4
      libp2p/Host.cpp
  29. 3
      libp2p/RLPXSocket.h
  30. 1
      libsolidity/Token.h
  31. 4
      libsolidity/Types.cpp
  32. 4
      libsolidity/Types.h
  33. 1
      libweb3jsonrpc/JsonHelper.cpp
  34. 6
      libweb3jsonrpc/JsonHelper.h
  35. 3
      libweb3jsonrpc/WebThreeStubServer.cpp
  36. 21
      new.sh
  37. 41
      templates/dockplugin.cpp
  38. 56
      templates/dockplugin.h
  39. 36
      templates/dockplugin.ui
  40. 37
      templates/plugin.cpp
  41. 46
      templates/plugin.h
  42. 5
      test/TestUtils.cpp
  43. 8
      test/TestUtils.h
  44. 54
      test/libdevcore/Base36.cpp
  45. 2
      test/libdevcrypto/SecretStore.cpp
  46. 2
      test/libdevcrypto/crypto.cpp
  47. 80
      test/libethcore/icap.cpp
  48. 28
      test/libsolidity/SolidityNameAndTypeResolution.cpp

6
CMakeLists.txt

@ -527,8 +527,8 @@ endif ()
if (WIN32) if (WIN32)
# packaging stuff # packaging stuff
include(InstallRequiredSystemLibraries) include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_NAME "Ethereum (++)") set(CPACK_PACKAGE_NAME "Ethereum")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Ethereum (++) Toolset") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Ethereum Toolset")
set(CPACK_PACKAGE_VENDOR "ethereum.org") set(CPACK_PACKAGE_VENDOR "ethereum.org")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
@ -557,7 +557,7 @@ if (WIN32)
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}") set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
endif() endif()
set(CPACK_NSIS_DISPLAY_NAME "Ethereum (++)") set(CPACK_NSIS_DISPLAY_NAME "Ethereum")
set(CPACK_NSIS_HELP_LINK "https://github.com/ethereum/cpp-ethereum") set(CPACK_NSIS_HELP_LINK "https://github.com/ethereum/cpp-ethereum")
set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/ethereum/cpp-ethereum") set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/ethereum/cpp-ethereum")
set(CPACK_NSIS_CONTACT "ethereum.org") set(CPACK_NSIS_CONTACT "ethereum.org")

8
alethzero/MainWin.cpp

@ -159,7 +159,7 @@ Main::Main(QWidget* _parent):
QMessageBox::warning(nullptr, "Try again", "You entered two different passwords - please enter the same password twice.", QMessageBox::Ok); QMessageBox::warning(nullptr, "Try again", "You entered two different passwords - please enter the same password twice.", QMessageBox::Ok);
} }
m_keyManager.create(password.toStdString()); m_keyManager.create(password.toStdString());
m_keyManager.import(Secret::random(), "Default identity"); m_keyManager.import(ICAP::createDirect(), "Default identity");
} }
#if ETH_DEBUG #if ETH_DEBUG
@ -317,9 +317,7 @@ void Main::install(AccountNamer* _adopt)
void Main::uninstall(AccountNamer* _kill) void Main::uninstall(AccountNamer* _kill)
{ {
auto it = m_namers.find(_kill); m_namers.erase(_kill);
if (it != m_namers.end())
m_namers.erase(it);
refreshAll(); refreshAll();
} }
@ -411,7 +409,7 @@ NetworkPreferences Main::netPrefs() const
ret = NetworkPreferences(listenIP, ui->port->value(), ui->upnp->isChecked()); ret = NetworkPreferences(listenIP, ui->port->value(), ui->upnp->isChecked());
ret.discovery = m_privateChain.isEmpty() && !ui->hermitMode->isChecked(); ret.discovery = m_privateChain.isEmpty() && !ui->hermitMode->isChecked();
ret.pin = m_privateChain.isEmpty() || ui->hermitMode->isChecked(); ret.pin = !ret.discovery;
return ret; return ret;
} }

118
eth/main.cpp

@ -38,7 +38,7 @@
#include <libethereum/All.h> #include <libethereum/All.h>
#include <libethereum/BlockChainSync.h> #include <libethereum/BlockChainSync.h>
#include <libethcore/KeyManager.h> #include <libethcore/KeyManager.h>
#include <libethcore/ICAP.h>
#include <libwebthree/WebThree.h> #include <libwebthree/WebThree.h>
#if ETH_JSCONSOLE || !ETH_TRUE #if ETH_JSCONSOLE || !ETH_TRUE
#include <libjsconsole/JSLocalConsole.h> #include <libjsconsole/JSLocalConsole.h>
@ -68,58 +68,17 @@ using dev::eth::Instruction;
static std::atomic<bool> g_silence = {false}; static std::atomic<bool> g_silence = {false};
void interactiveHelp()
{
cout
<< "Commands:" << endl
<< " netstart <port> Starts the network subsystem on a specific port." << endl
<< " netstop Stops the network subsystem." << endl
<< " connect <addr> <port> Connects to a specific peer." << endl
<< " verbosity (<level>) Gets or sets verbosity level." << endl
<< " minestart Starts mining." << endl
<< " minestop Stops mining." << endl
<< " mineforce <enable> Forces mining, even when there are no transactions." << endl
<< " block Gives the current block height." << endl
<< " blockhashfromnumber <number> Gives the block hash with the givne number." << endl
<< " numberfromblockhash <hash> Gives the block number with the given hash." << endl
<< " blockqueue Gives the current block queue status." << endl
<< " findblock <hash> Searches for the block in the blockchain and blockqueue." << endl
<< " firstunknown Gives the first unknown block from the blockqueue." << endl
<< " retryunknown retries to import all unknown blocks from the blockqueue." << endl
<< " accounts Gives information on all owned accounts (balances, mining beneficiary and default signer)." << endl
<< " newaccount <name> Creates a new account with the given name." << endl
<< " transact Execute a given transaction." << endl
<< " transactnonce Execute a given transaction with a specified nonce." << endl
<< " txcreate Execute a given contract creation transaction." << endl
<< " send Execute a given transaction with current secret." << endl
<< " contract Create a new contract with current secret." << endl
<< " peers List the peers that are connected" << endl
#if ETH_FATDB || !ETH_TRUE
<< " listaccounts List the accounts on the network." << endl
<< " listcontracts List the contracts on the network." << endl
<< " balanceat <address> Gives the balance of the given account." << endl
<< " balanceatblock <address> <blocknumber> Gives the balance of the given account." << endl
<< " storageat <address> Gives the storage of the given account." << endl
<< " storageatblock <address> <blocknumber> Gives the storahe of the given account at a given blocknumber." << endl
<< " codeat <address> Gives the code of the given account." << endl
#endif
<< " setsigningkey <addr> Set the address with which to sign transactions." << endl
<< " setaddress <addr> Set the coinbase (mining payout) address." << endl
<< " exportconfig <path> Export the config (.RLP) to the path provided." << endl
<< " importconfig <path> Import the config (.RLP) from the path provided." << endl
<< " inspect <contract> Dumps a contract to <APPDATA>/<contract>.evm." << endl
<< " reprocess <block> Reprocess a given block." << endl
<< " dumptrace <block> <index> <filename> <format> Dumps a transaction trace" << endl << "to <filename>. <format> should be one of pretty, standard, standard+." << endl
<< " dumpreceipt <block> <index> Dumps a transation receipt." << endl
<< " hashrate Print the current hashrate in hashes per second if the client is mining." << endl
<< " exit Exits the application." << endl;
}
void help() void help()
{ {
cout cout
<< "Usage eth [OPTIONS]" << endl << "Usage eth [OPTIONS]" << endl
<< "Options:" << endl << endl << "Options:" << endl << endl
<< "Operating mode (default is non-interactive node):" << endl
#if ETH_JSCONSOLE || !ETH_TRUE
<< " console Enter interactive console mode (default: non-interactive)." << endl
<< " import <file> Import file as a concatenated series of blocks." << endl
<< " export <file> Export file as a concatenated series of blocks." << endl
#endif
<< "Client mode (default):" << endl << "Client mode (default):" << endl
<< " --olympic Use the Olympic (0.9) protocol." << endl << " --olympic Use the Olympic (0.9) protocol." << endl
<< " --frontier Use the Frontier (1.0) protocol." << endl << " --frontier Use the Frontier (1.0) protocol." << endl
@ -127,9 +86,6 @@ void help()
<< " --genesis-json <file> Import the genesis block information from the given json file." << endl << " --genesis-json <file> Import the genesis block information from the given json file." << endl
<< endl << endl
<< " -o,--mode <full/peer> Start a full node or a peer node (default: full)." << endl << " -o,--mode <full/peer> Start a full node or a peer node (default: full)." << endl
#if ETH_JSCONSOLE || !ETH_TRUE
<< " -i,--interactive Enter interactive mode (default: non-interactive)." << endl
#endif
<< endl << endl
#if ETH_JSONRPC || !ETH_TRUE #if ETH_JSONRPC || !ETH_TRUE
<< " -j,--json-rpc Enable JSON-RPC server (default: off)." << endl << " -j,--json-rpc Enable JSON-RPC server (default: off)." << endl
@ -169,7 +125,8 @@ void help()
<< endl << endl
<< "Client networking:" << endl << "Client networking:" << endl
<< " --client-name <name> Add a name to your client's version string (default: blank)." << endl << " --client-name <name> Add a name to your client's version string (default: blank)." << endl
<< " -b,--bootstrap Connect to the default Ethereum peerserver." << endl << " --bootstrap Connect to the default Ethereum peerservers (default unless --no-discovery used)." << endl
<< " --no-bootstrap Do not connect to the default Ethereum peerservers (default only when --no-discovery is used)." << endl
<< " -x,--peers <number> Attempt to connect to given number of peers (default: 11)." << endl << " -x,--peers <number> Attempt to connect to given number of peers (default: 11)." << endl
<< " --peer-stretch <number> Accepted connection multiplier (default: 7)." << endl << " --peer-stretch <number> Accepted connection multiplier (default: 7)." << endl
@ -187,7 +144,7 @@ void help()
// << " trusted Keep connected at all times." << endl // << " trusted Keep connected at all times." << endl
// << " --trust-peers <filename> Text list of publickeys." << endl // << " --trust-peers <filename> Text list of publickeys." << endl
<< " --no-discovery Disable Node discovery." << endl << " --no-discovery Disable Node discovery, implies --no-bootstrap." << endl
<< " --pin Only accept or connect to trusted peers." << endl << " --pin Only accept or connect to trusted peers." << endl
<< " --hermit Equivalent to --no-discovery --pin." << endl << " --hermit Equivalent to --no-discovery --pin." << endl
<< " --sociable Forces discovery and no pinning." << endl << " --sociable Forces discovery and no pinning." << endl
@ -198,9 +155,8 @@ void help()
<< " --structured-logging Enable structured logging (default output to stdout)." << endl << " --structured-logging Enable structured logging (default output to stdout)." << endl
<< " --structured-logging-format <format> Set the structured logging time format." << endl << " --structured-logging-format <format> Set the structured logging time format." << endl
<< " --structured-logging-url <URL> Set the structured logging destination (currently only file:// supported)." << endl << " --structured-logging-url <URL> Set the structured logging destination (currently only file:// supported)." << endl
<< endl
<< "Import/export modes:" << endl << "Import/export modes:" << endl
<< " -I,--import <file> Import file as a concatenated series of blocks and exit." << endl
<< " -E,--export <file> Export file as a concatenated series of blocks and exit." << endl
<< " --from <n> Export only from block n; n may be a decimal, a '0x' prefixed hash, or 'latest'." << endl << " --from <n> Export only from block n; n may be a decimal, a '0x' prefixed hash, or 'latest'." << endl
<< " --to <n> Export only to block n (inclusive); n may be a decimal, a '0x' prefixed hash, or 'latest'." << endl << " --to <n> Export only to block n (inclusive); n may be a decimal, a '0x' prefixed hash, or 'latest'." << endl
<< " --only <n> Equivalent to --export-from n --export-to n." << endl << " --only <n> Equivalent to --export-from n --export-to n." << endl
@ -310,13 +266,17 @@ void stopMiningAfterXBlocks(eth::Client* _c, unsigned _start, unsigned& io_minin
this_thread::sleep_for(chrono::milliseconds(100)); this_thread::sleep_for(chrono::milliseconds(100));
} }
void interactiveMode(eth::Client*, std::shared_ptr<eth::TrivialGasPricer>, WebThreeDirect&, KeyManager&, string&, string&, function<string(string const&)>, function<string(Address const&)>, NetworkPreferences, Address, Address, TransactionPriority) {}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
// Init defaults // Init defaults
Defaults::get(); Defaults::get();
#if ETH_DEBUG
g_logVerbosity = 4;
#else
g_logVerbosity = 1;
#endif
/// Operating mode. /// Operating mode.
OperationMode mode = OperationMode::Node; OperationMode mode = OperationMode::Node;
string dbPath; string dbPath;
@ -359,7 +319,7 @@ int main(int argc, char** argv)
HostPeerPreferences hprefs; HostPeerPreferences hprefs;
unsigned peers = hprefs.idealPeerCount; unsigned peers = hprefs.idealPeerCount;
unsigned peerStretch = hprefs.stretchPeerCount; unsigned peerStretch = hprefs.stretchPeerCount;
bool bootstrap = false; bool bootstrap = true;
bool disableDiscovery = false; bool disableDiscovery = false;
bool pinning = false; bool pinning = false;
bool enableDiscovery = false; bool enableDiscovery = false;
@ -381,7 +341,7 @@ int main(int argc, char** argv)
string structuredLoggingURL; string structuredLoggingURL;
/// Transaction params /// Transaction params
TransactionPriority priority = TransactionPriority::Medium; // TransactionPriority priority = TransactionPriority::Medium;
// double etherPrice = 30.679; // double etherPrice = 30.679;
// double blockFees = 15.0; // double blockFees = 15.0;
u256 askPrice = c_defaultGasPrice; u256 askPrice = c_defaultGasPrice;
@ -444,14 +404,14 @@ int main(int argc, char** argv)
passwordsToNote.push_back(argv[++i]); passwordsToNote.push_back(argv[++i]);
else if (arg == "--master" && i + 1 < argc) else if (arg == "--master" && i + 1 < argc)
masterPassword = argv[++i]; masterPassword = argv[++i];
else if ((arg == "-I" || arg == "--import") && i + 1 < argc) else if ((arg == "-I" || arg == "--import" || arg == "import") && i + 1 < argc)
{ {
mode = OperationMode::Import; mode = OperationMode::Import;
filename = argv[++i]; filename = argv[++i];
} }
else if (arg == "--dont-check") else if (arg == "--dont-check")
safeImport = true; safeImport = true;
else if ((arg == "-E" || arg == "--export") && i + 1 < argc) else if ((arg == "-E" || arg == "--export" || arg == "export") && i + 1 < argc)
{ {
mode = OperationMode::Export; mode = OperationMode::Export;
filename = argv[++i]; filename = argv[++i];
@ -645,7 +605,7 @@ int main(int argc, char** argv)
return -1; return -1;
} }
} }
else if ((arg == "-P" || arg == "--priority") && i + 1 < argc) /* else if ((arg == "-P" || arg == "--priority") && i + 1 < argc)
{ {
string m = boost::to_lower_copy(string(argv[++i])); string m = boost::to_lower_copy(string(argv[++i]));
if (m == "lowest") if (m == "lowest")
@ -666,7 +626,7 @@ int main(int argc, char** argv)
cerr << "Unknown " << arg << " option: " << m << endl; cerr << "Unknown " << arg << " option: " << m << endl;
return -1; return -1;
} }
} }*/
else if ((arg == "-m" || arg == "--mining") && i + 1 < argc) else if ((arg == "-m" || arg == "--mining") && i + 1 < argc)
{ {
string m = argv[++i]; string m = argv[++i];
@ -685,8 +645,13 @@ int main(int argc, char** argv)
} }
else if (arg == "-b" || arg == "--bootstrap") else if (arg == "-b" || arg == "--bootstrap")
bootstrap = true; bootstrap = true;
else if (arg == "--no-bootstrap")
bootstrap = false;
else if (arg == "--no-discovery") else if (arg == "--no-discovery")
{
disableDiscovery = true; disableDiscovery = true;
bootstrap = false;
}
else if (arg == "--pin") else if (arg == "--pin")
pinning = true; pinning = true;
else if (arg == "--hermit") else if (arg == "--hermit")
@ -708,7 +673,7 @@ int main(int argc, char** argv)
jsonAdmin = argv[++i]; jsonAdmin = argv[++i];
#endif #endif
#if ETH_JSCONSOLE || !ETH_TRUE #if ETH_JSCONSOLE || !ETH_TRUE
else if (arg == "-i" || arg == "--interactive" || arg == "--console") else if (arg == "-i" || arg == "--interactive" || arg == "--console" || arg == "console")
useConsole = true; useConsole = true;
#endif #endif
else if ((arg == "-v" || arg == "--verbosity") && i + 1 < argc) else if ((arg == "-v" || arg == "--verbosity") && i + 1 < argc)
@ -780,7 +745,7 @@ int main(int argc, char** argv)
if (c_network == eth::Network::Olympic) if (c_network == eth::Network::Olympic)
cout << "Welcome to Olympic!" << endl; cout << "Welcome to Olympic!" << endl;
else if (c_network == eth::Network::Frontier) else if (c_network == eth::Network::Frontier)
cout << "Welcome to the " EthMaroonBold "Frontier" EthReset "!" << endl; cout << "Beware. You're entering the " EthMaroonBold "Frontier" EthReset "!" << endl;
} }
m.execute(); m.execute();
@ -996,7 +961,7 @@ int main(int argc, char** argv)
if (keyManager.accounts().empty()) if (keyManager.accounts().empty())
{ {
h128 uuid = keyManager.import(Secret::random(), "Default key"); h128 uuid = keyManager.import(ICAP::createDirect(), "Default key");
if (!beneficiary) if (!beneficiary)
beneficiary = keyManager.address(uuid); beneficiary = keyManager.address(uuid);
if (!signingKey) if (!signingKey)
@ -1022,8 +987,14 @@ int main(int argc, char** argv)
c->setNetworkId(networkId); c->setNetworkId(networkId);
} }
cout << "Transaction Signer: " << signingKey << endl; auto renderFullAddress = [&](Address const& _a) -> std::string
cout << "Mining Benefactor: " << beneficiary << endl; {
return ICAP(_a).encoded() + " (" + toUUID(keyManager.uuid(_a)) + " - " + toHex(_a.ref().cropped(0, 4)) + ")";
};
cout << "Transaction Signer: " << renderFullAddress(signingKey) << endl;
cout << "Mining Beneficiary: " << renderFullAddress(beneficiary) << endl;
cout << "Foundation: " << renderFullAddress(Address("de0b295669a9fd93d5f28d9ec85e40f4cb697bae")) << endl;
if (bootstrap || !remoteHost.empty() || disableDiscovery) if (bootstrap || !remoteHost.empty() || disableDiscovery)
{ {
@ -1031,7 +1002,7 @@ int main(int argc, char** argv)
cout << "Node ID: " << web3.enode() << endl; cout << "Node ID: " << web3.enode() << endl;
} }
else else
cout << "Networking disabled. To start, use netstart or pass -b or a remote host." << endl; cout << "Networking disabled. To start, use netstart or pass --bootstrap or a remote host." << endl;
if (useConsole && jsonRPCURL == -1) if (useConsole && jsonRPCURL == -1)
jsonRPCURL = SensibleHttpPort; jsonRPCURL = SensibleHttpPort;
@ -1064,9 +1035,7 @@ int main(int argc, char** argv)
signal(SIGTERM, &sighandler); signal(SIGTERM, &sighandler);
signal(SIGINT, &sighandler); signal(SIGINT, &sighandler);
if (interactive) if (c)
interactiveMode(c, gasPricer, web3, keyManager, logbuf, additional, getPassword, getAccountPassword, netPrefs, beneficiary, signingKey, priority);
else if (c)
{ {
unsigned n = c->blockChain().details().number; unsigned n = c->blockChain().details().number;
if (mining) if (mining)
@ -1078,11 +1047,8 @@ int main(int argc, char** argv)
shared_ptr<dev::WebThreeStubServer> rpcServer = make_shared<dev::WebThreeStubServer>(*console.connector(), web3, make_shared<SimpleAccountHolder>([&](){ return web3.ethereum(); }, getAccountPassword, keyManager), vector<KeyPair>(), keyManager, *gasPricer); shared_ptr<dev::WebThreeStubServer> rpcServer = make_shared<dev::WebThreeStubServer>(*console.connector(), web3, make_shared<SimpleAccountHolder>([&](){ return web3.ethereum(); }, getAccountPassword, keyManager), vector<KeyPair>(), keyManager, *gasPricer);
string sessionKey = rpcServer->newSession(SessionPermissions{{Privilege::Admin}}); string sessionKey = rpcServer->newSession(SessionPermissions{{Privilege::Admin}});
console.eval("web3.admin.setSessionKey('" + sessionKey + "')"); console.eval("web3.admin.setSessionKey('" + sessionKey + "')");
while (!g_exit) while (console.readExpression())
{
console.readExpression();
stopMiningAfterXBlocks(c, n, mining); stopMiningAfterXBlocks(c, n, mining);
}
rpcServer->StopListening(); rpcServer->StopListening();
#endif #endif
} }

2
ethkey/KeyAux.h

@ -505,7 +505,7 @@ public:
if (Address a = wallet.address(u)) if (Address a = wallet.address(u))
{ {
cout << toUUID(u) << " " << a.abridged(); cout << toUUID(u) << " " << a.abridged();
cout << " (Not ICAP) "; cout << " " << ICAP(a).encoded();
cout << " " << wallet.accountName(a) << endl; cout << " " << wallet.accountName(a) << endl;
} }
for (auto const& u: bare) for (auto const& u: bare)

5
libdevcore/Base64.h

@ -44,7 +44,10 @@ template <size_t N> inline std::string toBase36(FixedHash<N> const& _h)
typename FixedHash<N>::Arith a = _h; typename FixedHash<N>::Arith a = _h;
std::string ret; std::string ret;
for (; a > 0; a /= 36) for (; a > 0; a /= 36)
ret = c_alphabet[(unsigned)a % 36] + ret; {
unsigned r = (unsigned)(a - a / 36 * 36); // boost's % is broken
ret = c_alphabet[r] + ret;
}
return ret; return ret;
} }

10
libdevcore/Common.h

@ -92,7 +92,15 @@ public:
explicit secure_vector(vector_ref<const T> _c): m_data(_c.data(), _c.data() + _c.size()) {} explicit secure_vector(vector_ref<const T> _c): m_data(_c.data(), _c.data() + _c.size()) {}
~secure_vector() { ref().cleanse(); } ~secure_vector() { ref().cleanse(); }
secure_vector<T>& operator=(secure_vector<T> const& _c) { ref().cleanse(); m_data = _c.m_data; return *this; } secure_vector<T>& operator=(secure_vector<T> const& _c)
{
if (&_c == this)
return *this;
ref().cleanse();
m_data = _c.m_data;
return *this;
}
std::vector<T>& writable() { clear(); return m_data; } std::vector<T>& writable() { clear(); return m_data; }
std::vector<T> const& makeInsecure() const { return m_data; } std::vector<T> const& makeInsecure() const { return m_data; }

7
libdevcore/Worker.h

@ -54,7 +54,12 @@ protected:
Worker(Worker&& _m) { std::swap(m_name, _m.m_name); } Worker(Worker&& _m) { std::swap(m_name, _m.m_name); }
/// Move-assignment. /// Move-assignment.
Worker& operator=(Worker&& _m) { std::swap(m_name, _m.m_name); return *this; } Worker& operator=(Worker&& _m)
{
assert(&_m != this);
std::swap(m_name, _m.m_name);
return *this;
}
virtual ~Worker() { terminate(); } virtual ~Worker() { terminate(); }

21
libdevcrypto/Common.cpp

@ -308,33 +308,14 @@ h256 crypto::kdf(Secret const& _priv, h256 const& _hash)
return s; return s;
} }
string const& Nonce::seedFilePath(string const& _filePath)
{
static mutex x_seedFile;
static string s_seedFile;
Guard l(x_seedFile);
if (s_seedFile.empty())
s_seedFile = _filePath.empty() ? getDataDir() + "/seed" : _filePath;
return s_seedFile;
}
Secret Nonce::next() Secret Nonce::next()
{ {
Guard l(x_value); Guard l(x_value);
if (!m_value) if (!m_value)
{ {
bytesSec b = contentsSec(seedFilePath()); m_value = Secret::random();
if (b.size() == 32)
b.ref().populate(m_value.writable().ref());
else
m_value = Secret::random();
if (!m_value) if (!m_value)
BOOST_THROW_EXCEPTION(InvalidState()); BOOST_THROW_EXCEPTION(InvalidState());
// prevent seed reuse if process terminates abnormally
// this might throw
writeFile(seedFilePath(), bytes());
} }
m_value = sha3Secure(m_value.ref()); m_value = sha3Secure(m_value.ref());
return sha3(~m_value); return sha3(~m_value);

6
libdevcrypto/Common.h

@ -203,14 +203,8 @@ public:
/// Returns the next nonce (might be read from a file). /// Returns the next nonce (might be read from a file).
static Secret get() { static Nonce s; return s.next(); } static Secret get() { static Nonce s; return s.next(); }
/// @returns path of the seed file. FOR TESTS ONLY: optionally set path to @_filePath.
static std::string const& seedFilePath(std::string const& _filePath = std::string());
private: private:
Nonce() = default; Nonce() = default;
/// Destructor. IO operation may throw.
~Nonce() { if (m_value && next()) dev::writeFile(seedFilePath(), m_value.ref()); }
/// @returns the next nonce. /// @returns the next nonce.
Secret next(); Secret next();

163
libdevcrypto/WordList.cpp

@ -35,7 +35,7 @@ strings const WordList =
"have", "have",
"to", "to",
"it", "it",
"I", "i",
"that", "that",
"for", "for",
"you", "you",
@ -198,7 +198,7 @@ strings const WordList =
"start", "start",
"hand", "hand",
"might", "might",
"American", "american",
"show", "show",
"part", "part",
"about", "about",
@ -233,7 +233,7 @@ strings const WordList =
"like", "like",
"night", "night",
"live", "live",
"Mr", "mr",
"point", "point",
"believe", "believe",
"hold", "hold",
@ -567,7 +567,7 @@ strings const WordList =
"court", "court",
"produce", "produce",
"eat", "eat",
"American", "american",
"teach", "teach",
"oil", "oil",
"half", "half",
@ -617,7 +617,7 @@ strings const WordList =
"attention", "attention",
"draw", "draw",
"film", "film",
"Republican", "republican",
"tree", "tree",
"source", "source",
"red", "red",
@ -661,7 +661,7 @@ strings const WordList =
"administration", "administration",
"south", "south",
"husband", "husband",
"Congress", "congress",
"floor", "floor",
"campaign", "campaign",
"material", "material",
@ -819,7 +819,7 @@ strings const WordList =
"region", "region",
"television", "television",
"box", "box",
"TV", "tv",
"training", "training",
"pretty", "pretty",
"trade", "trade",
@ -849,7 +849,7 @@ strings const WordList =
"answer", "answer",
"skill", "skill",
"sister", "sister",
"PM", "pm",
"professor", "professor",
"operation", "operation",
"financial", "financial",
@ -928,7 +928,7 @@ strings const WordList =
"that", "that",
"spring", "spring",
"firm", "firm",
"Democrat", "democrat",
"radio", "radio",
"visit", "visit",
"management", "management",
@ -1060,7 +1060,7 @@ strings const WordList =
"reality", "reality",
"coach", "coach",
"step", "step",
"Mrs", "mrs",
"yard", "yard",
"beat", "beat",
"violence", "violence",
@ -1137,7 +1137,7 @@ strings const WordList =
"forest", "forest",
"video", "video",
"global", "global",
"Senate", "senate",
"reform", "reform",
"access", "access",
"restaurant", "restaurant",
@ -1209,7 +1209,7 @@ strings const WordList =
"spirit", "spirit",
"experience", "experience",
"replace", "replace",
"British", "british",
"encourage", "encourage",
"lot", "lot",
"lot", "lot",
@ -1222,7 +1222,7 @@ strings const WordList =
"brain", "brain",
"feature", "feature",
"afternoon", "afternoon",
"AM", "am",
"weekend", "weekend",
"dozen", "dozen",
"possibility", "possibility",
@ -1233,7 +1233,7 @@ strings const WordList =
"beginning", "beginning",
"date", "date",
"generally", "generally",
"African", "african",
"very", "very",
"sorry", "sorry",
"crisis", "crisis",
@ -1248,7 +1248,7 @@ strings const WordList =
"vision", "vision",
"status", "status",
"normal", "normal",
"Chinese", "chinese",
"ship", "ship",
"solution", "solution",
"stone", "stone",
@ -1278,7 +1278,7 @@ strings const WordList =
"tradition", "tradition",
"winter", "winter",
"village", "village",
"Soviet", "soviet",
"refuse", "refuse",
"sales", "sales",
"roll", "roll",
@ -1295,16 +1295,16 @@ strings const WordList =
"potential", "potential",
"increase", "increase",
"middle", "middle",
"European", "european",
"presence", "presence",
"independent", "independent",
"district", "district",
"shape", "shape",
"reader", "reader",
"Ms", "ms",
"contract", "contract",
"crowd", "crowd",
"Christian", "christian",
"express", "express",
"apartment", "apartment",
"willing", "willing",
@ -1395,8 +1395,8 @@ strings const WordList =
"insist", "insist",
"failure", "failure",
"annual", "annual",
"French", "french",
"Christmas", "christmas",
"comment", "comment",
"responsible", "responsible",
"affair", "affair",
@ -1467,7 +1467,7 @@ strings const WordList =
"smile", "smile",
"location", "location",
"clothes", "clothes",
"Indian", "indian",
"quiet", "quiet",
"dress", "dress",
"promise", "promise",
@ -1494,14 +1494,14 @@ strings const WordList =
"dangerous", "dangerous",
"remind", "remind",
"moral", "moral",
"United", "united",
"category", "category",
"relatively", "relatively",
"victory", "victory",
"key", "key",
"academic", "academic",
"visit", "visit",
"Internet", "internet",
"healthy", "healthy",
"fire", "fire",
"negative", "negative",
@ -1597,7 +1597,7 @@ strings const WordList =
"leaf", "leaf",
"direct", "direct",
"dry", "dry",
"Russian", "russian",
"instruction", "instruction",
"fight", "fight",
"pool", "pool",
@ -1653,7 +1653,7 @@ strings const WordList =
"presidential", "presidential",
"emotional", "emotional",
"commitment", "commitment",
"Supreme", "supreme",
"bear", "bear",
"pocket", "pocket",
"thin", "thin",
@ -1688,7 +1688,7 @@ strings const WordList =
"organize", "organize",
"jury", "jury",
"breast", "breast",
"Iraqi", "iraqi",
"human", "human",
"acknowledge", "acknowledge",
"theme", "theme",
@ -1757,7 +1757,7 @@ strings const WordList =
"prefer", "prefer",
"truly", "truly",
"earth", "earth",
"Japanese", "japanese",
"chest", "chest",
"search", "search",
"thick", "thick",
@ -1795,7 +1795,7 @@ strings const WordList =
"sheet", "sheet",
"ought", "ought",
"ensure", "ensure",
"Catholic", "catholic",
"extremely", "extremely",
"extent", "extent",
"component", "component",
@ -1822,7 +1822,7 @@ strings const WordList =
"guide", "guide",
"circumstance", "circumstance",
"snow", "snow",
"English", "english",
"politician", "politician",
"steal", "steal",
"pursue", "pursue",
@ -1835,7 +1835,7 @@ strings const WordList =
"influence", "influence",
"surgery", "surgery",
"correct", "correct",
"Jewish", "jewish",
"blame", "blame",
"estimate", "estimate",
"due", "due",
@ -1863,7 +1863,7 @@ strings const WordList =
"rating", "rating",
"golden", "golden",
"motion", "motion",
"German", "german",
"gender", "gender",
"solve", "solve",
"fee", "fee",
@ -1943,7 +1943,7 @@ strings const WordList =
"clean", "clean",
"except", "except",
"beer", "beer",
"English", "english",
"reference", "reference",
"tear", "tear",
"doubt", "doubt",
@ -2047,8 +2047,8 @@ strings const WordList =
"towards", "towards",
"expose", "expose",
"rural", "rural",
"AIDS", "aids",
"Jew", "jew",
"narrow", "narrow",
"cream", "cream",
"secretary", "secretary",
@ -2128,7 +2128,7 @@ strings const WordList =
"forever", "forever",
"fun", "fun",
"regard", "regard",
"Israeli", "israeli",
"association", "association",
"twenty", "twenty",
"knock", "knock",
@ -2247,11 +2247,11 @@ strings const WordList =
"error", "error",
"release", "release",
"cop", "cop",
"Arab", "arab",
"double", "double",
"walk", "walk",
"sand", "sand",
"Spanish", "spanish",
"rule", "rule",
"hit", "hit",
"print", "print",
@ -2294,7 +2294,7 @@ strings const WordList =
"present", "present",
"joke", "joke",
"coat", "coat",
"Mexican", "mexican",
"symptom", "symptom",
"contact", "contact",
"manufacturer", "manufacturer",
@ -2366,7 +2366,7 @@ strings const WordList =
"another", "another",
"attach", "attach",
"for", "for",
"Indian", "indian",
"disaster", "disaster",
"parking", "parking",
"prospect", "prospect",
@ -2397,7 +2397,7 @@ strings const WordList =
"illustrate", "illustrate",
"boot", "boot",
"monitor", "monitor",
"Asian", "asian",
"entertainment", "entertainment",
"bean", "bean",
"evaluation", "evaluation",
@ -2536,7 +2536,7 @@ strings const WordList =
"occasionally", "occasionally",
"mayor", "mayor",
"consideration", "consideration",
"CEO", "ceo",
"secure", "secure",
"pink", "pink",
"smoke", "smoke",
@ -2575,13 +2575,13 @@ strings const WordList =
"quit", "quit",
"absence", "absence",
"roll", "roll",
"Latin", "latin",
"rapidly", "rapidly",
"jail", "jail",
"comment", "comment",
"diversity", "diversity",
"honest", "honest",
"Palestinian", "palestinian",
"pace", "pace",
"employment", "employment",
"speaker", "speaker",
@ -2641,11 +2641,11 @@ strings const WordList =
"phrase", "phrase",
"ingredient", "ingredient",
"stake", "stake",
"Muslim", "muslim",
"dream", "dream",
"fiber", "fiber",
"activist", "activist",
"Islamic", "islamic",
"snap", "snap",
"terrorism", "terrorism",
"refugee", "refugee",
@ -2686,8 +2686,8 @@ strings const WordList =
"wonder", "wonder",
"clock", "clock",
"chocolate", "chocolate",
"Italian", "italian",
"Canadian", "canadian",
"ceiling", "ceiling",
"sweep", "sweep",
"advertising", "advertising",
@ -2786,13 +2786,13 @@ strings const WordList =
"though", "though",
"expansion", "expansion",
"elite", "elite",
"Olympic", "olympic",
"dirt", "dirt",
"odd", "odd",
"rice", "rice",
"bullet", "bullet",
"tight", "tight",
"Bible", "bible",
"chart", "chart",
"solar", "solar",
"decline", "decline",
@ -2878,7 +2878,7 @@ strings const WordList =
"assistant", "assistant",
"offense", "offense",
"counter", "counter",
"DNA", "dna",
"smell", "smell",
"potentially", "potentially",
"transfer", "transfer",
@ -2981,7 +2981,7 @@ strings const WordList =
"radical", "radical",
"stress", "stress",
"adapt", "adapt",
"Irish", "irish",
"honey", "honey",
"correspondent", "correspondent",
"pale", "pale",
@ -3072,7 +3072,7 @@ strings const WordList =
"fund", "fund",
"ski", "ski",
"limitation", "limitation",
"OK", "ok",
"trace", "trace",
"appointment", "appointment",
"preference", "preference",
@ -3105,7 +3105,7 @@ strings const WordList =
"mall", "mall",
"derive", "derive",
"scandal", "scandal",
"PC", "pc",
"helpful", "helpful",
"impress", "impress",
"heel", "heel",
@ -3125,7 +3125,7 @@ strings const WordList =
"examination", "examination",
"publisher", "publisher",
"strengthen", "strengthen",
"French", "french",
"proposed", "proposed",
"myth", "myth",
"sophisticated", "sophisticated",
@ -3153,7 +3153,7 @@ strings const WordList =
"narrative", "narrative",
"photographer", "photographer",
"helicopter", "helicopter",
"Catholic", "catholic",
"modest", "modest",
"provider", "provider",
"delay", "delay",
@ -3181,7 +3181,7 @@ strings const WordList =
"assignment", "assignment",
"restriction", "restriction",
"across", "across",
"Palestinian", "palestinian",
"laboratory", "laboratory",
"workshop", "workshop",
"differently", "differently",
@ -3216,19 +3216,19 @@ strings const WordList =
"versus", "versus",
"manufacturing", "manufacturing",
"risk", "risk",
"Christian", "christian",
"complex", "complex",
"absolute", "absolute",
"chef", "chef",
"discrimination", "discrimination",
"offensive", "offensive",
"German", "german",
"suit", "suit",
"boom", "boom",
"register", "register",
"appoint", "appoint",
"heritage", "heritage",
"God", "god",
"terrorist", "terrorist",
"dominant", "dominant",
"successfully", "successfully",
@ -3366,7 +3366,7 @@ strings const WordList =
"rope", "rope",
"concrete", "concrete",
"prescription", "prescription",
"African-American", "african-american",
"chase", "chase",
"document", "document",
"brick", "brick",
@ -3547,7 +3547,7 @@ strings const WordList =
"cold", "cold",
"classical", "classical",
"estimated", "estimated",
"T-shirt", "t-shirt",
"online", "online",
"unemployment", "unemployment",
"civilization", "civilization",
@ -3564,16 +3564,16 @@ strings const WordList =
"reliable", "reliable",
"excitement", "excitement",
"beef", "beef",
"Islam", "islam",
"Roman", "roman",
"stretch", "stretch",
"architecture", "architecture",
"occasional", "occasional",
"administrative", "administrative",
"elbow", "elbow",
"deadly", "deadly",
"Muslim", "muslim",
"Hispanic", "hispanic",
"allegation", "allegation",
"tip", "tip",
"confuse", "confuse",
@ -3581,7 +3581,7 @@ strings const WordList =
"monthly", "monthly",
"duck", "duck",
"dose", "dose",
"Korean", "korean",
"plead", "plead",
"initiate", "initiate",
"lecture", "lecture",
@ -3762,7 +3762,7 @@ strings const WordList =
"freshman", "freshman",
"sweat", "sweat",
"outer", "outer",
"European", "european",
"drunk", "drunk",
"survey", "survey",
"research", "research",
@ -3837,7 +3837,7 @@ strings const WordList =
"shame", "shame",
"meaningful", "meaningful",
"sidewalk", "sidewalk",
"Olympics", "olympics",
"technological", "technological",
"signature", "signature",
"pleasant", "pleasant",
@ -3919,7 +3919,7 @@ strings const WordList =
"pastor", "pastor",
"jazz", "jazz",
"opera", "opera",
"Japanese", "japanese",
"bite", "bite",
"frame", "frame",
"evil", "evil",
@ -3945,7 +3945,7 @@ strings const WordList =
"gym", "gym",
"oral", "oral",
"clerk", "clerk",
"Israeli", "israeli",
"envelope", "envelope",
"reporting", "reporting",
"destination", "destination",
@ -4027,7 +4027,7 @@ strings const WordList =
"enroll", "enroll",
"diminish", "diminish",
"prevention", "prevention",
"Arab", "arab",
"value", "value",
"minimize", "minimize",
"chop", "chop",
@ -4063,7 +4063,7 @@ strings const WordList =
"representative", "representative",
"content", "content",
"realistic", "realistic",
"Russian", "russian",
"hidden", "hidden",
"command", "command",
"tender", "tender",
@ -4126,19 +4126,15 @@ strings const WordList =
"cart", "cart",
"oversee", "oversee",
"stem", "stem",
"o'clock",
"elder", "elder",
"o'clock",
"o'clock",
"o'clock",
"pro", "pro",
"inspiration", "inspiration",
"Dutch", "dutch",
"quantity", "quantity",
"trailer", "trailer",
"mate", "mate",
"o'clock", "o'clock",
"Greek", "greek",
"genius", "genius",
"monument", "monument",
"bid", "bid",
@ -4264,7 +4260,7 @@ strings const WordList =
"rent", "rent",
"calm", "calm",
"jewelry", "jewelry",
"Cuban", "cuban",
"haul", "haul",
"concede", "concede",
"trace", "trace",
@ -4366,7 +4362,7 @@ strings const WordList =
"breeze", "breeze",
"costly", "costly",
"ambitious", "ambitious",
"Christianity", "christianity",
"presumably", "presumably",
"influential", "influential",
"translation", "translation",
@ -4547,7 +4543,7 @@ strings const WordList =
"ideal", "ideal",
"constitution", "constitution",
"trainer", "trainer",
"Thanksgiving", "thanksgiving",
"scent", "scent",
"stack", "stack",
"eyebrow", "eyebrow",
@ -4614,7 +4610,7 @@ strings const WordList =
"dip", "dip",
"likewise", "likewise",
"informal", "informal",
"Persian", "persian",
"feather", "feather",
"sphere", "sphere",
"tighten", "tighten",
@ -4689,7 +4685,6 @@ strings const WordList =
"toll", "toll",
"rim", "rim",
"embarrassed", "embarrassed",
"fucking",
"cling", "cling",
"isolated", "isolated",
"blink", "blink",

21
libethcore/CommonJS.cpp

@ -22,16 +22,27 @@
*/ */
#include "CommonJS.h" #include "CommonJS.h"
#include "ICAP.h"
namespace dev namespace dev
{ {
Address toAddress(std::string const& _sn) Address jsToAddress(std::string const& _s)
{ {
if (_sn.size() == 40) try
return Address(fromHex(_sn)); {
else eth::ICAP i = eth::ICAP::decoded(_s);
return Address(); return i.direct();
}
catch (eth::InvalidICAP&) {}
try
{
auto b = fromHex(_s.substr(0, 2) == "0x" ? _s.substr(2) : _s, WhenError::Throw);
if (b.size() == 20)
return Address(b);
}
catch (BadHexCharacter&) {}
BOOST_THROW_EXCEPTION(InvalidAddress());
} }
std::string prettyU256(u256 _n, bool _abridged) std::string prettyU256(u256 _n, bool _abridged)

5
libethcore/CommonJS.h

@ -33,8 +33,7 @@
namespace dev namespace dev
{ {
/// Strictly convert unprefixed hex string string to Address (h160). @returns empty address if (_a.size != 40). DEV_SIMPLE_EXCEPTION(InvalidAddress);
Address toAddress(std::string const& _a);
/// Leniently convert string to Public (h512). Accepts integers, "0x" prefixing, non-exact length. /// Leniently convert string to Public (h512). Accepts integers, "0x" prefixing, non-exact length.
inline Public jsToPublic(std::string const& _s) { return jsToFixed<sizeof(dev::Public)>(_s); } inline Public jsToPublic(std::string const& _s) { return jsToFixed<sizeof(dev::Public)>(_s); }
@ -43,7 +42,7 @@ inline Public jsToPublic(std::string const& _s) { return jsToFixed<sizeof(dev::P
inline Secret jsToSecret(std::string const& _s) { h256 d = jsToFixed<sizeof(dev::Secret)>(_s); Secret ret(d); d.ref().cleanse(); return ret; } inline Secret jsToSecret(std::string const& _s) { h256 d = jsToFixed<sizeof(dev::Secret)>(_s); Secret ret(d); d.ref().cleanse(); return ret; }
/// Leniently convert string to Address (h160). Accepts integers, "0x" prefixing, non-exact length. /// Leniently convert string to Address (h160). Accepts integers, "0x" prefixing, non-exact length.
inline Address jsToAddress(std::string const& _s) { return jsToFixed<sizeof(dev::Address)>(_s); } Address jsToAddress(std::string const& _s);
/// Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHash. As a fallback try to handle input as h256. /// Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHash. As a fallback try to handle input as h256.
std::string prettyU256(u256 _n, bool _abridged = true); std::string prettyU256(u256 _n, bool _abridged = true);

17
libethcore/ICAP.cpp

@ -64,6 +64,17 @@ std::pair<string, string> ICAP::fromIBAN(std::string _iban)
return make_pair(c, d); return make_pair(c, d);
} }
Secret ICAP::createDirect()
{
Secret ret;
while (true)
{
ret = Secret::random();
if (!toAddress(ret)[0])
return ret;
}
}
ICAP ICAP::decoded(std::string const& _encoded) ICAP ICAP::decoded(std::string const& _encoded)
{ {
ICAP ret; ICAP ret;
@ -72,7 +83,7 @@ ICAP ICAP::decoded(std::string const& _encoded)
std::tie(country, data) = fromIBAN(_encoded); std::tie(country, data) = fromIBAN(_encoded);
if (country != "XE") if (country != "XE")
BOOST_THROW_EXCEPTION(InvalidICAP()); BOOST_THROW_EXCEPTION(InvalidICAP());
if (data.size() == 30) if (data.size() == 30 || data.size() == 31)
{ {
ret.m_type = Direct; ret.m_type = Direct;
// Direct ICAP // Direct ICAP
@ -100,10 +111,8 @@ std::string ICAP::encoded() const
{ {
if (m_type == Direct) if (m_type == Direct)
{ {
if (!!m_direct[0])
BOOST_THROW_EXCEPTION(InvalidICAP());
std::string d = toBase36<Address::size>(m_direct); std::string d = toBase36<Address::size>(m_direct);
while (d.size() < 30) while (d.size() < 30) // always 34, sometimes 35.
d = "0" + d; d = "0" + d;
return iban("XE", d); return iban("XE", d);
} }

5
libethcore/ICAP.h

@ -36,7 +36,7 @@ namespace dev
namespace eth namespace eth
{ {
struct InvalidICAP: virtual public dev::Exception {}; DEV_SIMPLE_EXCEPTION(InvalidICAP);
/** /**
* @brief Encapsulation of an ICAP address. * @brief Encapsulation of an ICAP address.
@ -62,6 +62,9 @@ public:
Indirect Indirect
}; };
/// Create a direct address for ICAP.
static Secret createDirect();
/// @returns IBAN encoding of client and data. /// @returns IBAN encoding of client and data.
static std::string iban(std::string _c, std::string _d); static std::string iban(std::string _c, std::string _d);
/// @returns Client and data from given IBAN address. /// @returns Client and data from given IBAN address.

2
libethcore/KeyManager.h

@ -36,7 +36,7 @@ class PasswordUnknown: public Exception {};
struct KeyInfo struct KeyInfo
{ {
KeyInfo() = default; KeyInfo() = default;
KeyInfo(h256 const& _passHash, std::string const& _accountName, std::string const& _passwordHint): passHash(_passHash), accountName(_accountName), passwordHint(_passwordHint) {} KeyInfo(h256 const& _passHash, std::string const& _accountName, std::string const& _passwordHint = std::string()): passHash(_passHash), accountName(_accountName), passwordHint(_passwordHint) {}
/// Hash of the password or h256() / UnknownPassword if unknown. /// Hash of the password or h256() / UnknownPassword if unknown.
h256 passHash; h256 passHash;

3
libethereum/Block.cpp

@ -80,6 +80,9 @@ Block::Block(Block const& _s):
Block& Block::operator=(Block const& _s) Block& Block::operator=(Block const& _s)
{ {
if (&_s == this)
return *this;
m_state = _s.m_state; m_state = _s.m_state;
m_transactions = _s.m_transactions; m_transactions = _s.m_transactions;
m_receipts = _s.m_receipts; m_receipts = _s.m_receipts;

1
libethereum/BlockChainSync.cpp

@ -833,7 +833,6 @@ void PV60Sync::abortSync()
void PV60Sync::onPeerAborting() void PV60Sync::onPeerAborting()
{ {
RecursiveGuard l(x_sync); RecursiveGuard l(x_sync);
DEV_INVARIANT_CHECK;
// Can't check invariants here since the peers is already removed from the list and the state is not updated yet. // Can't check invariants here since the peers is already removed from the list and the state is not updated yet.
if (m_syncer.expired() && m_state != SyncState::Idle) if (m_syncer.expired() && m_state != SyncState::Idle)
{ {

1
libethereum/DownloadMan.cpp

@ -44,6 +44,7 @@ DownloadSub::DownloadSub(DownloadMan& _man): m_man(&_man)
DownloadSub::~DownloadSub() DownloadSub::~DownloadSub()
{ {
Guard fl(m_fetch);
if (m_man) if (m_man)
{ {
WriteGuard l(m_man->x_subs); WriteGuard l(m_man->x_subs);

3
libethereum/DownloadMan.h

@ -93,7 +93,10 @@ public:
~DownloadMan() ~DownloadMan()
{ {
for (auto i: m_subs) for (auto i: m_subs)
{
Guard l(i->m_fetch);
i->m_man = nullptr; i->m_man = nullptr;
}
} }
void appendToChain(h256s const& _hashes) void appendToChain(h256s const& _hashes)

2
libethereum/Executive.cpp

@ -383,7 +383,7 @@ bool Executive::go(OnOpFunc const& _onOp)
} }
catch (VMException const& _e) catch (VMException const& _e)
{ {
cnote/*clog(StateSafeExceptions)*/ << "Safe VM Exception. " << diagnostic_information(_e); clog(StateSafeExceptions) << "Safe VM Exception. " << diagnostic_information(_e);
m_gas = 0; m_gas = 0;
m_excepted = toTransactionException(_e); m_excepted = toTransactionException(_e);
m_ext->revert(); m_ext->revert();

3
libethereum/State.cpp

@ -136,6 +136,9 @@ void State::paranoia(std::string const& _when, bool _enforceRefs) const
State& State::operator=(State const& _s) State& State::operator=(State const& _s)
{ {
if (&_s == this)
return *this;
m_db = _s.m_db; m_db = _s.m_db;
m_state.open(&m_db, _s.m_state.root(), Verification::Skip); m_state.open(&m_db, _s.m_state.root(), Verification::Skip);
m_cache = _s.m_cache; m_cache = _s.m_cache;

1
libethereum/TransactionQueue.cpp

@ -402,4 +402,3 @@ void TransactionQueue::verifierBody()
} }
} }
} }

9
libethereum/TransactionQueue.h

@ -140,7 +140,14 @@ private:
UnverifiedTransaction() {} UnverifiedTransaction() {}
UnverifiedTransaction(bytesConstRef const& _t, h512 const& _nodeId): transaction(_t.toBytes()), nodeId(_nodeId) {} UnverifiedTransaction(bytesConstRef const& _t, h512 const& _nodeId): transaction(_t.toBytes()), nodeId(_nodeId) {}
UnverifiedTransaction(UnverifiedTransaction&& _t): transaction(std::move(_t.transaction)) {} UnverifiedTransaction(UnverifiedTransaction&& _t): transaction(std::move(_t.transaction)) {}
UnverifiedTransaction& operator=(UnverifiedTransaction&& _other) { transaction = std::move(_other.transaction); nodeId = std::move(_other.nodeId); return *this; } UnverifiedTransaction& operator=(UnverifiedTransaction&& _other)
{
assert(&_other != this);
transaction = std::move(_other.transaction);
nodeId = std::move(_other.nodeId);
return *this;
}
UnverifiedTransaction(UnverifiedTransaction const&) = delete; UnverifiedTransaction(UnverifiedTransaction const&) = delete;
UnverifiedTransaction& operator=(UnverifiedTransaction const&) = delete; UnverifiedTransaction& operator=(UnverifiedTransaction const&) = delete;

2
libethereum/VerifiedBlock.h

@ -58,6 +58,8 @@ struct VerifiedBlock
VerifiedBlock& operator=(VerifiedBlock&& _other) VerifiedBlock& operator=(VerifiedBlock&& _other)
{ {
assert(&_other != this);
verified = (std::move(_other.verified)); verified = (std::move(_other.verified));
blockData = (std::move(_other.blockData)); blockData = (std::move(_other.blockData));
return *this; return *this;

17
libevmasm/SourceLocation.h

@ -41,8 +41,21 @@ struct SourceLocation
SourceLocation(): start(-1), end(-1) { } SourceLocation(): start(-1), end(-1) { }
SourceLocation(SourceLocation const& _other): SourceLocation(SourceLocation const& _other):
start(_other.start), end(_other.end), sourceName(_other.sourceName) {} start(_other.start),
SourceLocation& operator=(SourceLocation const& _other) { start = _other.start; end = _other.end; sourceName = _other.sourceName; return *this;} end(_other.end),
sourceName(_other.sourceName)
{}
SourceLocation& operator=(SourceLocation const& _other)
{
if (&_other == this)
return *this;
start = _other.start;
end = _other.end;
sourceName = _other.sourceName;
return *this;
}
bool operator==(SourceLocation const& _other) const { return start == _other.start && end == _other.end;} bool operator==(SourceLocation const& _other) const { return start == _other.start && end == _other.end;}
bool operator!=(SourceLocation const& _other) const { return !operator==(_other); } bool operator!=(SourceLocation const& _other) const { return !operator==(_other); }

6
libjsconsole/JSConsole.h

@ -41,7 +41,7 @@ public:
JSConsole(): m_engine(Engine()), m_printer(Printer(m_engine)) {} JSConsole(): m_engine(Engine()), m_printer(Printer(m_engine)) {}
~JSConsole() {} ~JSConsole() {}
void readExpression() const bool readExpression() const
{ {
std::string cmd = ""; std::string cmd = "";
g_logPost = [](std::string const& a, char const*) g_logPost = [](std::string const& a, char const*)
@ -83,6 +83,9 @@ public:
} }
} while (openBrackets > 0); } while (openBrackets > 0);
if (cmd == "quit")
return false;
if (!isEmpty) if (!isEmpty)
{ {
#if ETH_READLINE #if ETH_READLINE
@ -92,6 +95,7 @@ public:
std::string result = m_printer.prettyPrint(value).cstr(); std::string result = m_printer.prettyPrint(value).cstr();
std::cout << result << std::endl; std::cout << result << std::endl;
} }
return true;
} }
void eval(std::string const& _expression) { m_engine.eval(_expression.c_str()); } void eval(std::string const& _expression) { m_engine.eval(_expression.c_str()); }

14
libp2p/Common.h

@ -78,9 +78,9 @@ struct InvalidPublicIPAddress: virtual dev::Exception {};
struct InvalidHostIPAddress: virtual dev::Exception {}; struct InvalidHostIPAddress: virtual dev::Exception {};
struct NetWarn: public LogChannel { static const char* name(); static const int verbosity = 0; }; struct NetWarn: public LogChannel { static const char* name(); static const int verbosity = 0; };
struct NetNote: public LogChannel { static const char* name(); static const int verbosity = 1; }; struct NetNote: public LogChannel { static const char* name(); static const int verbosity = 2; };
struct NetImpolite: public LogChannel { static const char* name(); static const int verbosity = 2; }; struct NetImpolite: public LogChannel { static const char* name(); static const int verbosity = 3; };
struct NetMessageSummary: public LogChannel { static const char* name(); static const int verbosity = 3; }; struct NetMessageSummary: public LogChannel { static const char* name(); static const int verbosity = 4; };
struct NetConnect: public LogChannel { static const char* name(); static const int verbosity = 10; }; struct NetConnect: public LogChannel { static const char* name(); static const int verbosity = 10; };
struct NetMessageDetail: public LogChannel { static const char* name(); static const int verbosity = 5; }; struct NetMessageDetail: public LogChannel { static const char* name(); static const int verbosity = 5; };
struct NetTriviaSummary: public LogChannel { static const char* name(); static const int verbosity = 10; }; struct NetTriviaSummary: public LogChannel { static const char* name(); static const int verbosity = 10; };
@ -224,7 +224,13 @@ class DeadlineOps
~DeadlineOp() {} ~DeadlineOp() {}
DeadlineOp(DeadlineOp&& _s): m_timer(_s.m_timer.release()) {} DeadlineOp(DeadlineOp&& _s): m_timer(_s.m_timer.release()) {}
DeadlineOp& operator=(DeadlineOp&& _s) { m_timer.reset(_s.m_timer.release()); return *this; } DeadlineOp& operator=(DeadlineOp&& _s)
{
assert(&_s != this);
m_timer.reset(_s.m_timer.release());
return *this;
}
bool expired() { Guard l(x_timer); return m_timer->expires_from_now().total_nanoseconds() <= 0; } bool expired() { Guard l(x_timer); return m_timer->expires_from_now().total_nanoseconds() <= 0; }
void wait() { Guard l(x_timer); m_timer->wait(); } void wait() { Guard l(x_timer); m_timer->wait(); }

4
libp2p/Host.cpp

@ -396,7 +396,7 @@ void Host::runAcceptor()
clog(NetConnect) << "Listening on local port " << m_listenPort << " (public: " << m_tcpPublic << ")"; clog(NetConnect) << "Listening on local port " << m_listenPort << " (public: " << m_tcpPublic << ")";
m_accepting = true; m_accepting = true;
auto socket = make_shared<RLPXSocket>(new bi::tcp::socket(m_ioService)); auto socket = make_shared<RLPXSocket>(m_ioService);
m_tcp4Acceptor.async_accept(socket->ref(), [=](boost::system::error_code ec) m_tcp4Acceptor.async_accept(socket->ref(), [=](boost::system::error_code ec)
{ {
m_accepting = false; m_accepting = false;
@ -552,7 +552,7 @@ void Host::connect(std::shared_ptr<Peer> const& _p)
bi::tcp::endpoint ep(_p->endpoint); bi::tcp::endpoint ep(_p->endpoint);
clog(NetConnect) << "Attempting connection to node" << _p->id << "@" << ep << "from" << id(); clog(NetConnect) << "Attempting connection to node" << _p->id << "@" << ep << "from" << id();
auto socket = make_shared<RLPXSocket>(new bi::tcp::socket(m_ioService)); auto socket = make_shared<RLPXSocket>(m_ioService);
socket->ref().async_connect(ep, [=](boost::system::error_code const& ec) socket->ref().async_connect(ep, [=](boost::system::error_code const& ec)
{ {
_p->m_lastAttempted = std::chrono::system_clock::now(); _p->m_lastAttempted = std::chrono::system_clock::now();

3
libp2p/RLPXSocket.h

@ -39,8 +39,7 @@ namespace p2p
class RLPXSocket: public std::enable_shared_from_this<RLPXSocket> class RLPXSocket: public std::enable_shared_from_this<RLPXSocket>
{ {
public: public:
/// Constructor. Dereferences and takes ownership of _socket. RLPXSocket(ba::io_service& _ioService): m_socket(_ioService) {}
RLPXSocket(bi::tcp::socket* _socket): m_socket(std::move(*_socket)) {}
~RLPXSocket() { close(); } ~RLPXSocket() { close(); }
bool isConnected() const { return m_socket.is_open(); } bool isConnected() const { return m_socket.is_open(); }

1
libsolidity/Token.h

@ -366,6 +366,7 @@ public:
} }
static bool isBitOp(Value op) { return (BitOr <= op && op <= SHR) || op == BitNot; } static bool isBitOp(Value op) { return (BitOr <= op && op <= SHR) || op == BitNot; }
static bool isBooleanOp(Value op) { return (Or <= op && op <= And) || op == Not; }
static bool isUnaryOp(Value op) { return (Not <= op && op <= Delete) || op == Add || op == Sub || op == After; } static bool isUnaryOp(Value op) { return (Not <= op && op <= Delete) || op == Add || op == Sub || op == After; }
static bool isCountOp(Value op) { return op == Inc || op == Dec; } static bool isCountOp(Value op) { return op == Inc || op == Dec; }
static bool isShiftOp(Value op) { return (SHL <= op) && (op <= SHR); } static bool isShiftOp(Value op) { return (SHL <= op) && (op <= SHR); }

4
libsolidity/Types.cpp

@ -79,6 +79,8 @@ pair<u256, unsigned> const* StorageOffsets::getOffset(size_t _index) const
MemberList& MemberList::operator=(MemberList&& _other) MemberList& MemberList::operator=(MemberList&& _other)
{ {
assert(&_other != this);
m_memberTypes = std::move(_other.m_memberTypes); m_memberTypes = std::move(_other.m_memberTypes);
m_storageOffsets = std::move(_other.m_storageOffsets); m_storageOffsets = std::move(_other.m_storageOffsets);
return *this; return *this;
@ -311,6 +313,8 @@ TypePointer IntegerType::binaryOperatorResult(Token::Value _operator, TypePointe
// All integer types can be compared // All integer types can be compared
if (Token::isCompareOp(_operator)) if (Token::isCompareOp(_operator))
return commonType; return commonType;
if (Token::isBooleanOp(_operator))
return TypePointer();
// Nothing else can be done with addresses // Nothing else can be done with addresses
if (commonType->isAddress()) if (commonType->isAddress())
return TypePointer(); return TypePointer();

4
libsolidity/Types.h

@ -409,6 +409,10 @@ public:
DataLocation location() const { return m_location; } DataLocation location() const { return m_location; }
virtual TypePointer unaryOperatorResult(Token::Value _operator) const override; virtual TypePointer unaryOperatorResult(Token::Value _operator) const override;
virtual TypePointer binaryOperatorResult(Token::Value, TypePointer const&) const override
{
return TypePointer();
}
virtual unsigned memoryHeadSize() const override { return 32; } virtual unsigned memoryHeadSize() const override { return 32; }
/// @returns a copy of this type with location (recursively) changed to @a _location, /// @returns a copy of this type with location (recursively) changed to @a _location,

1
libweb3jsonrpc/JsonHelper.cpp

@ -27,6 +27,7 @@
#include <libethereum/Client.h> #include <libethereum/Client.h>
#include <libwebthree/WebThree.h> #include <libwebthree/WebThree.h>
#include <libethcore/CommonJS.h> #include <libethcore/CommonJS.h>
#include <libethcore/ICAP.h>
#include <libwhisper/Message.h> #include <libwhisper/Message.h>
#include <libwhisper/WhisperHost.h> #include <libwhisper/WhisperHost.h>
using namespace std; using namespace std;

6
libweb3jsonrpc/JsonHelper.h

@ -69,6 +69,12 @@ TransactionSkeleton toTransactionSkeleton(Json::Value const& _json);
LogFilter toLogFilter(Json::Value const& _json); LogFilter toLogFilter(Json::Value const& _json);
LogFilter toLogFilter(Json::Value const& _json, Interface const& _client); // commented to avoid warning. Uncomment once in use @ PoC-7. LogFilter toLogFilter(Json::Value const& _json, Interface const& _client); // commented to avoid warning. Uncomment once in use @ PoC-7.
class AddressResolver
{
public:
static Address fromJS(std::string const& _address);
};
template <class BlockInfoSub> template <class BlockInfoSub>
Json::Value toJson(BlockHeaderPolished<BlockInfoSub> const& _bh) Json::Value toJson(BlockHeaderPolished<BlockInfoSub> const& _bh)
{ {

3
libweb3jsonrpc/WebThreeStubServer.cpp

@ -28,6 +28,7 @@
#include <libdevcore/FileSystem.h> #include <libdevcore/FileSystem.h>
#include <libdevcore/CommonJS.h> #include <libdevcore/CommonJS.h>
#include <libethcore/KeyManager.h> #include <libethcore/KeyManager.h>
#include <libethcore/ICAP.h>
#include <libethereum/Executive.h> #include <libethereum/Executive.h>
#include <libethereum/Block.h> #include <libethereum/Block.h>
#include <libwebthree/WebThree.h> #include <libwebthree/WebThree.h>
@ -189,7 +190,7 @@ Json::Value WebThreeStubServer::admin_eth_newAccount(Json::Value const& _info, s
if (!_info.isMember("name")) if (!_info.isMember("name"))
throw jsonrpc::JsonRpcException("No member found: name"); throw jsonrpc::JsonRpcException("No member found: name");
string name = _info["name"].asString(); string name = _info["name"].asString();
auto s = Secret::random(); auto s = ICAP::createDirect();
h128 uuid; h128 uuid;
if (_info.isMember("password")) if (_info.isMember("password"))
{ {

21
new.sh

@ -0,0 +1,21 @@
#!/bin/bash
type="$1"
path="$2"
name="$3"
if ! [[ -n $type ]] || ! [[ -n $path ]] || ! [[ -n $name ]]; then
echo "Usage new.sh <type> <path> <name>"
echo "e.g. new.sh plugin alethzero MyPlugin"
exit
fi
cd templates
for i in $type.*; do
n="../$path/${i/$type/$name}"
cp "$i" "$n"
perl -i -p -e "s/\\\$NAME/$name/gc" "$n"
done

41
templates/dockplugin.cpp

@ -0,0 +1,41 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file $NAME.h
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/
#include "$NAME.h"
#include <libdevcore/Log.h>
#include <libethereum/Client.h>
#include "ui_$NAME.h"
using namespace std;
using namespace dev;
using namespace az;
using namespace eth;
$NAME::$NAME(MainFace* _m):
Plugin(_m, "$NAME"),
m_ui(new Ui::$NAME)
{
dock(Qt::RightDockWidgetArea, "$NAME")->setWidget(new QWidget());
m_ui->setupUi(dock()->widget());
}
$NAME::~$NAME()
{
}

56
templates/dockplugin.h

@ -0,0 +1,56 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file $NAME.h
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/
#pragma once
#include <QListWidget>
#include <QPlainTextEdit>
#include "MainFace.h"
namespace Ui
{
class $NAME;
}
namespace dev
{
namespace az
{
class $NAME: public QObject, public Plugin
{
Q_OBJECT
public:
AllAccounts(MainFace* _m);
~AllAccounts();
private:
void onAllChange() override {}
void readSettings(QSettings const&) override {}
void writeSettings(QSettings&) override {}
private:
Ui::$NAME* m_ui;
};
}
}

36
templates/dockplugin.ui

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>$NAME</class>
<widget class="QWidget" name="NAME">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>405</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
<resources/>
<connections/>
</ui>

37
templates/plugin.cpp

@ -0,0 +1,37 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file $NAME.h
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/
#include "$NAME.h"
#include <libdevcore/Log.h>
#include <libethereum/Client.h>
using namespace std;
using namespace dev;
using namespace az;
using namespace eth;
$NAME::$NAME(MainFace* _m):
Plugin(_m, "$NAME")
{
}
$NAME::~$NAME()
{
}

46
templates/plugin.h

@ -0,0 +1,46 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file $NAME.h
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/
#pragma once
#include "MainFace.h"
namespace dev
{
namespace az
{
class $NAME: public QObject, public Plugin
{
Q_OBJECT
public:
$NAME(MainFace* _m);
~$NAME();
private:
void onAllChange() override {}
void readSettings(QSettings const&) override {}
void writeSettings(QSettings&) override {}
};
}
}

5
test/TestUtils.cpp

@ -120,8 +120,3 @@ void ParallelClientBaseFixture::enumerateClients(std::function<void(Json::Value
}); });
} }
MoveNonceToTempDir::MoveNonceToTempDir()
{
crypto::Nonce::seedFilePath(m_dir.path() + "/seed");
}

8
test/TestUtils.h

@ -79,13 +79,5 @@ struct JsonRpcFixture: public ClientBaseFixture
}; };
struct MoveNonceToTempDir
{
MoveNonceToTempDir();
~MoveNonceToTempDir() {}
private:
TransientDirectory m_dir;
};
} }
} }

54
test/libdevcore/Base36.cpp

@ -0,0 +1,54 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file Base36.cpp
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
*/
#include <boost/test/unit_test.hpp>
#include <libdevcore/Base64.h>
#include <libethcore/ICAP.h>
using namespace std;
using namespace dev;
using namespace dev::eth;
BOOST_AUTO_TEST_SUITE(Base36Tests)
BOOST_AUTO_TEST_CASE(basicEncoding)
{
FixedHash<2> value("0x0048");
string encoded = toBase36<2>(value);
BOOST_CHECK_EQUAL(encoded, "20");
}
BOOST_AUTO_TEST_CASE(basicEncoding2)
{
FixedHash<2> value("0x0072");
string encoded = toBase36<2>(value);
BOOST_CHECK_EQUAL(encoded, "36");
}
BOOST_AUTO_TEST_CASE(basicEncoding3)
{
FixedHash<2> value("0xffff");
string encoded = toBase36<2>(value);
BOOST_CHECK_EQUAL(encoded, "1EKF");
}
BOOST_AUTO_TEST_SUITE_END()

2
test/libdevcrypto/SecretStore.cpp

@ -37,8 +37,6 @@ using namespace dev::test;
namespace js = json_spirit; namespace js = json_spirit;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
BOOST_GLOBAL_FIXTURE( MoveNonceToTempDir )
BOOST_AUTO_TEST_SUITE(KeyStore) BOOST_AUTO_TEST_SUITE(KeyStore)
BOOST_AUTO_TEST_CASE(basic_tests) BOOST_AUTO_TEST_CASE(basic_tests)

2
test/libdevcrypto/crypto.cpp

@ -40,8 +40,6 @@ using namespace dev::test;
using namespace dev::crypto; using namespace dev::crypto;
using namespace CryptoPP; using namespace CryptoPP;
BOOST_GLOBAL_FIXTURE( MoveNonceToTempDir )
BOOST_AUTO_TEST_SUITE(devcrypto) BOOST_AUTO_TEST_SUITE(devcrypto)
static Secp256k1PP s_secp256k1; static Secp256k1PP s_secp256k1;

80
test/libethcore/icap.cpp

@ -0,0 +1,80 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file icap.cpp
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
*/
#include <boost/test/unit_test.hpp>
#include <libethcore/ICAP.h>
using namespace std;
using namespace dev;
using namespace dev::eth;
BOOST_AUTO_TEST_SUITE(IcapTests)
BOOST_AUTO_TEST_CASE(addressEncoding)
{
Address address("0x52dc504a422f0e2a9e7632a34a50f1a82f8224c7");
ICAP icap(address);
BOOST_CHECK_EQUAL(icap.encoded(), "XE499OG1EH8ZZI0KXC6N83EKGT1BM97P2O7");
}
BOOST_AUTO_TEST_CASE(addressEncodingRandomString)
{
Address address("0x11c5496aee77c1ba1f0854206a26dda82a81d6d8");
ICAP icap(address);
BOOST_CHECK_EQUAL(icap.encoded(), "XE1222Q908LN1QBBU6XUQSO1OHWJIOS46OO");
}
BOOST_AUTO_TEST_CASE(addressEncodingWithZeroPrefix)
{
Address address("0x00c5496aee77c1ba1f0854206a26dda82a81d6d8");
ICAP icap(address);
BOOST_CHECK_EQUAL(icap.encoded(), "XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS");
}
BOOST_AUTO_TEST_CASE(addressDecoding)
{
Address address("0x52dc504a422f0e2a9e7632a34a50f1a82f8224c7");
ICAP icap = ICAP::decoded("XE499OG1EH8ZZI0KXC6N83EKGT1BM97P2O7");
BOOST_CHECK_EQUAL(icap.direct(), address);
}
BOOST_AUTO_TEST_CASE(addressDecodingRandomString)
{
Address address("0x11c5496aee77c1ba1f0854206a26dda82a81d6d8");
ICAP icap = ICAP::decoded("XE1222Q908LN1QBBU6XUQSO1OHWJIOS46OO");
BOOST_CHECK_EQUAL(icap.direct(), address);
}
BOOST_AUTO_TEST_CASE(addressDecodingWithZeroPrefix)
{
Address address("0x00c5496aee77c1ba1f0854206a26dda82a81d6d8");
ICAP icap = ICAP::decoded("XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS");
BOOST_CHECK_EQUAL(icap.direct(), address);
}
BOOST_AUTO_TEST_CASE(addressDecodingAndEncoding)
{
std::string encoded = "XE499OG1EH8ZZI0KXC6N83EKGT1BM97P2O7";
ICAP icap = ICAP::decoded(encoded);
BOOST_CHECK_EQUAL(icap.encoded(), encoded);
}
BOOST_AUTO_TEST_SUITE_END()

28
test/libsolidity/SolidityNameAndTypeResolution.cpp

@ -1883,6 +1883,34 @@ BOOST_AUTO_TEST_CASE(positive_integers_to_unsigned_out_of_bound)
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
} }
BOOST_AUTO_TEST_CASE(integer_boolean_operators)
{
char const* sourceCode1 = R"(
contract test { function() { uint x = 1; uint y = 2; x || y; } }
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode1), TypeError);
char const* sourceCode2 = R"(
contract test { function() { uint x = 1; uint y = 2; x && y; } }
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode2), TypeError);
char const* sourceCode3 = R"(
contract test { function() { uint x = 1; !x; } }
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode3), TypeError);
}
BOOST_AUTO_TEST_CASE(reference_compare_operators)
{
char const* sourceCode1 = R"(
contract test { bytes a; bytes b; function() { a == b; } }
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode1), TypeError);
char const* sourceCode2 = R"(
contract test { struct s {uint a;}; s x; s y; function() { x == y; } }
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode2), TypeError);
}
BOOST_AUTO_TEST_CASE(overwrite_memory_location_external) BOOST_AUTO_TEST_CASE(overwrite_memory_location_external)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(

Loading…
Cancel
Save