|
|
@ -1032,6 +1032,67 @@ int main(int argc, char** argv) |
|
|
|
else |
|
|
|
cwarn << "Require parameters: submitTransaction ADDRESS AMOUNT GASPRICE GAS SECRET DATA"; |
|
|
|
} |
|
|
|
else if (c && cmd == "cretract") |
|
|
|
{ |
|
|
|
auto const& bc =c->blockChain(); |
|
|
|
auto h = bc.currentHash(); |
|
|
|
auto blockData = bc.block(h); |
|
|
|
BlockInfo info(blockData); |
|
|
|
if (iss.peek() != -1) |
|
|
|
{ |
|
|
|
u256 amount; |
|
|
|
u256 gasPrice; |
|
|
|
u256 gas; |
|
|
|
string sechex; |
|
|
|
string sdata; |
|
|
|
|
|
|
|
iss >> amount >> gasPrice >> gas >> sechex >> sdata; |
|
|
|
|
|
|
|
if (!gasPrice) |
|
|
|
gasPrice = gasPricer->bid(priority); |
|
|
|
|
|
|
|
cnote << "Data:"; |
|
|
|
cnote << sdata; |
|
|
|
bytes data = dev::eth::parseData(sdata); |
|
|
|
cnote << "Bytes:"; |
|
|
|
string sbd = asString(data); |
|
|
|
bytes bbd = asBytes(sbd); |
|
|
|
stringstream ssbd; |
|
|
|
ssbd << bbd; |
|
|
|
cnote << ssbd.str(); |
|
|
|
int ssize = sechex.length(); |
|
|
|
u256 minGas = (u256)Transaction::gasRequired(data, 0); |
|
|
|
if (gas < minGas) |
|
|
|
cwarn << "Minimum gas amount is" << minGas; |
|
|
|
else if (ssize < 40) |
|
|
|
{ |
|
|
|
if (ssize > 0) |
|
|
|
cwarn << "Invalid secret length:" << ssize; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
Secret secret = h256(fromHex(sechex)); |
|
|
|
c->submitTransaction(secret, amount, data, gas, gasPrice); |
|
|
|
|
|
|
|
//Address dest = h160(fromHex(hexAddr));
|
|
|
|
//c->submitTransaction(secret, amount, dest, data, gas, gasPrice);
|
|
|
|
} |
|
|
|
catch (BadHexCharacter& _e) |
|
|
|
{ |
|
|
|
cwarn << "invalid hex character, transaction rejected"; |
|
|
|
cwarn << boost::diagnostic_information(_e); |
|
|
|
} |
|
|
|
catch (...) |
|
|
|
{ |
|
|
|
cwarn << "transaction rejected"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
cwarn << "Require parameters: submitTransaction ADDRESS AMOUNT GASPRICE GAS SECRET DATA"; |
|
|
|
} |
|
|
|
#if ETH_FATDB |
|
|
|
else if (c && cmd == "listcontracts") |
|
|
|
{ |
|
|
|