'throw' changed to 'return result' on incorrect params
tx hex name = 'hex' heirlist returns simple txid array now
This commit is contained in:
@@ -7382,30 +7382,45 @@ UniValue heirfund(const UniValue& params, bool fHelp)
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
txfee = atoll(params[0].get_str().c_str());
|
||||
if (txfee < 0)
|
||||
throw runtime_error("incorrect txfee param\n");
|
||||
if (txfee < 0) {
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "incorrect txfee"));
|
||||
return result;
|
||||
}
|
||||
|
||||
if(params.size() == 6) // tokens in satoshis:
|
||||
amount = atoll(params[1].get_str().c_str());
|
||||
else // coins:
|
||||
amount = atof(params[1].get_str().c_str()) * COIN;
|
||||
|
||||
if( amount <= 0 )
|
||||
throw runtime_error("incorrect amount\n");
|
||||
if (amount <= 0) {
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "incorrect amount"));
|
||||
return result;
|
||||
}
|
||||
|
||||
name = params[2].get_str();
|
||||
pubkey = ParseHex(params[3].get_str().c_str());
|
||||
if( !pubkey2pk(pubkey).IsValid() )
|
||||
throw runtime_error("incorrect pubkey\n");
|
||||
if (!pubkey2pk(pubkey).IsValid()) {
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "incorrect pubkey"));
|
||||
return result;
|
||||
}
|
||||
|
||||
inactivitytime = atoll(params[4].get_str().c_str());
|
||||
if (inactivitytime <= 0)
|
||||
throw runtime_error("incorrect inactivity time param\n");
|
||||
if (inactivitytime <= 0) {
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "incorrect inactivity time"));
|
||||
return result;
|
||||
}
|
||||
|
||||
if (params.size() == 6) {
|
||||
tokenid = Parseuint256((char*)params[5].get_str().c_str());
|
||||
if(tokenid == zeroid)
|
||||
throw runtime_error("incorrect tokenid\n");
|
||||
if (tokenid == zeroid) {
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "incorrect tokenid"));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if( tokenid == zeroid )
|
||||
@@ -7439,8 +7454,11 @@ UniValue heiradd(const UniValue& params, bool fHelp)
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
txfee = atoll(params[0].get_str().c_str());
|
||||
if (txfee < 0)
|
||||
throw runtime_error("incorrect txfee param\n");
|
||||
if (txfee < 0) {
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "incorrect txfee"));
|
||||
return result;
|
||||
}
|
||||
|
||||
fundingtxid = Parseuint256((char*)params[2].get_str().c_str());
|
||||
|
||||
@@ -7450,7 +7468,7 @@ UniValue heiradd(const UniValue& params, bool fHelp)
|
||||
|
||||
UniValue heirclaim(const UniValue& params, bool fHelp)
|
||||
{
|
||||
UniValue result; // result(UniValue::VOBJ);
|
||||
UniValue result;
|
||||
uint256 fundingtxid;
|
||||
int64_t txfee;
|
||||
int64_t inactivitytime;
|
||||
@@ -7458,7 +7476,6 @@ UniValue heirclaim(const UniValue& params, bool fHelp)
|
||||
std::vector<unsigned char> pubkey;
|
||||
std::string name;
|
||||
|
||||
// do we need this?
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
@@ -7471,8 +7488,11 @@ UniValue heirclaim(const UniValue& params, bool fHelp)
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
txfee = atoll(params[0].get_str().c_str());
|
||||
if (txfee < 0)
|
||||
throw runtime_error("incorrect txfee param\n");
|
||||
if (txfee < 0) {
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "incorrect txfee"));
|
||||
return result;
|
||||
}
|
||||
|
||||
fundingtxid = Parseuint256((char*)params[2].get_str().c_str());
|
||||
|
||||
@@ -7483,8 +7503,9 @@ UniValue heirclaim(const UniValue& params, bool fHelp)
|
||||
UniValue heirinfo(const UniValue& params, bool fHelp)
|
||||
{
|
||||
uint256 fundingtxid;
|
||||
if (fHelp || params.size() != 1) // or 0?
|
||||
if (fHelp || params.size() != 1)
|
||||
throw runtime_error("heirinfo fundingtxid\n");
|
||||
|
||||
// if ( ensure_CCrequirements() < 0 )
|
||||
// throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
|
||||
|
||||
@@ -7494,7 +7515,7 @@ UniValue heirinfo(const UniValue& params, bool fHelp)
|
||||
|
||||
UniValue heirlist(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 0) // or 0?
|
||||
if (fHelp || params.size() != 0)
|
||||
throw runtime_error("heirlist\n");
|
||||
|
||||
// if ( ensure_CCrequirements() < 0 )
|
||||
|
||||
Reference in New Issue
Block a user