|
@ -83,6 +83,7 @@ void interactiveHelp() |
|
|
<< " balance Gives the current balance." << endl |
|
|
<< " balance Gives the current balance." << endl |
|
|
<< " transact <secret> <dest> <amount> Executes a given transaction." << endl |
|
|
<< " transact <secret> <dest> <amount> Executes a given transaction." << endl |
|
|
<< " send <dest> <amount> Executes a given transaction with current secret." << endl |
|
|
<< " send <dest> <amount> Executes a given transaction with current secret." << endl |
|
|
|
|
|
<< " inspect <contract> Dumps a contract to <APPDATA>/<contract>.evm." << endl |
|
|
<< " exit Exits the application." << endl; |
|
|
<< " exit Exits the application." << endl; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -288,6 +289,62 @@ int main(int argc, char** argv) |
|
|
Address dest = h160(fromHex(rechex)); |
|
|
Address dest = h160(fromHex(rechex)); |
|
|
c.transact(us.secret(), dest, amount); |
|
|
c.transact(us.secret(), dest, amount); |
|
|
} |
|
|
} |
|
|
|
|
|
else if (cmd == "inspect") |
|
|
|
|
|
{ |
|
|
|
|
|
string rechex; |
|
|
|
|
|
iss >> rechex; |
|
|
|
|
|
|
|
|
|
|
|
c.lock(); |
|
|
|
|
|
auto hba = h160(fromHex(rechex)); |
|
|
|
|
|
auto h = h160((byte const*)hba.data(), h160::ConstructFromPointer); |
|
|
|
|
|
|
|
|
|
|
|
stringstream s; |
|
|
|
|
|
auto mem = c.state().contractMemory(h); |
|
|
|
|
|
u256 next = 0; |
|
|
|
|
|
unsigned numerics = 0; |
|
|
|
|
|
bool unexpectedNumeric = false; |
|
|
|
|
|
for (auto i: mem) |
|
|
|
|
|
{ |
|
|
|
|
|
if (next < i.first) |
|
|
|
|
|
{ |
|
|
|
|
|
unsigned j; |
|
|
|
|
|
for (j = 0; j <= numerics && next + j < i.first; ++j) |
|
|
|
|
|
s << (j < numerics || unexpectedNumeric ? " 0" : " STOP"); |
|
|
|
|
|
unexpectedNumeric = false; |
|
|
|
|
|
numerics -= min(numerics, j); |
|
|
|
|
|
if (next + j < i.first) |
|
|
|
|
|
s << "\n@" << showbase << hex << i.first << " "; |
|
|
|
|
|
} |
|
|
|
|
|
else if (!next) |
|
|
|
|
|
{ |
|
|
|
|
|
s << "@" << showbase << hex << i.first << " "; |
|
|
|
|
|
} |
|
|
|
|
|
auto iit = c_instructionInfo.find((Instruction)(unsigned)i.second); |
|
|
|
|
|
if (numerics || iit == c_instructionInfo.end() || (u256)(unsigned)iit->first != i.second) // not an instruction or expecting an argument...
|
|
|
|
|
|
{ |
|
|
|
|
|
if (numerics) |
|
|
|
|
|
numerics--; |
|
|
|
|
|
else |
|
|
|
|
|
unexpectedNumeric = true; |
|
|
|
|
|
s << " " << showbase << hex << i.second; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
auto const& ii = iit->second; |
|
|
|
|
|
s << " " << ii.name; |
|
|
|
|
|
numerics = ii.additional; |
|
|
|
|
|
} |
|
|
|
|
|
next = i.first + 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string outFile = getDataDir() + "/" + rechex + ".evm"; |
|
|
|
|
|
ofstream ofs; |
|
|
|
|
|
ofs.open(outFile, ofstream::binary); |
|
|
|
|
|
ofs.write(s.str().c_str(), s.str().length()); |
|
|
|
|
|
ofs.close(); |
|
|
|
|
|
|
|
|
|
|
|
c.unlock(); |
|
|
|
|
|
} |
|
|
else if (cmd == "help") |
|
|
else if (cmd == "help") |
|
|
{ |
|
|
{ |
|
|
interactiveHelp(); |
|
|
interactiveHelp(); |
|
|