Add checks for correct input data

This commit is contained in:
Mihailo Milenkovic
2018-10-08 17:45:53 +02:00
parent 0cb59663e2
commit 30743f7333
2 changed files with 33 additions and 4 deletions

View File

@@ -5146,8 +5146,23 @@ UniValue channelsopen(const UniValue& params, bool fHelp)
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
destpub = ParseHex(params[0].get_str().c_str());
if (destpub.size()!= 33)
{
ERR_RESULT("invalid destination pubkey");
return result;
}
numpayments = atoi(params[1].get_str().c_str());
if (numpayments <1)
{
ERR_RESULT("invalid number of payments, must be greater than 0");
return result;
}
payment = atol(params[2].get_str().c_str());
if (payment <1)
{
ERR_RESULT("invalid payment amount, must be greater than 0");
return result;
}
hex = ChannelOpen(0,pubkey2pk(destpub),numpayments,payment);
if ( hex.size() > 0 )
{
@@ -5169,6 +5184,11 @@ UniValue channelspayment(const UniValue& params, bool fHelp)
LOCK2(cs_main, pwalletMain->cs_wallet);
opentxid = Parseuint256((char *)params[0].get_str().c_str());
amount = atoi((char *)params[1].get_str().c_str());
if (amount <1)
{
ERR_RESULT("invalid payment amount, must be greater than 0");
return result;
}
if (params.size() > 2 && !params[2].isNull() && !params[2].get_str().empty())
{
secret = Parseuint256((char *)params[2].get_str().c_str());