'throw' changed to 'return result' on incorrect params
tx hex name = 'hex' heirlist returns simple txid array now
This commit is contained in:
@@ -657,13 +657,7 @@ template <typename Helper> UniValue _HeirFund(int64_t txfee, int64_t amount, std
|
||||
int64_t markerfee = 10000;
|
||||
|
||||
//std::cerr << "HeirFund() amount=" << amount << " txfee=" << txfee << " heirPubkey IsValid()=" << heirPubkey.IsValid() << " inactivityTime(sec)=" << inactivityTimeSec << " tokenid=" << tokenid.GetHex() << std::endl;
|
||||
|
||||
if (!heirPubkey.IsValid()) {
|
||||
std::cerr << "HeirFund() heirPubkey is not valid!" << std::endl;
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "invalid heir pubkey"));
|
||||
}
|
||||
|
||||
|
||||
CPubKey myPubkey = pubkey2pk(Mypubkey());
|
||||
|
||||
if (AddNormalinputs(mtx, myPubkey, markerfee, 3) > 0) {
|
||||
@@ -714,7 +708,7 @@ template <typename Helper> UniValue _HeirFund(int64_t txfee, int64_t amount, std
|
||||
Helper::makeCreateOpRet(tokenid, voutTokenPubkeys, myPubkey, heirPubkey, inactivityTimeSec, heirName));
|
||||
if (!rawhextx.empty()) {
|
||||
result.push_back(Pair("result", "success"));
|
||||
result.push_back(Pair("hextx", rawhextx));
|
||||
result.push_back(Pair("hex", rawhextx));
|
||||
}
|
||||
else {
|
||||
std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl;
|
||||
@@ -835,7 +829,7 @@ template <class Helper> UniValue _HeirAdd(uint256 fundingtxid, int64_t txfee, in
|
||||
Helper::makeAddOpRet(tokenid, voutTokenPubkeys, fundingtxid, hasHeirSpendingBegun)));
|
||||
|
||||
if (!rawhextx.empty()) {
|
||||
result.push_back(Pair("hextx", rawhextx));
|
||||
result.push_back(Pair("hex", rawhextx));
|
||||
}
|
||||
else {
|
||||
std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl;
|
||||
@@ -1008,7 +1002,7 @@ template <typename Helper>UniValue _HeirClaim(uint256 fundingtxid, int64_t txfee
|
||||
|
||||
if (!rawhextx.empty()) {
|
||||
result.push_back(Pair("result", "success"));
|
||||
result.push_back(Pair("hextx", rawhextx));
|
||||
result.push_back(Pair("hex", rawhextx));
|
||||
}
|
||||
else {
|
||||
std::cerr << "HeirAdd error in FinalizeCCtx" << std::endl;
|
||||
@@ -1273,7 +1267,7 @@ void _HeirList(struct CCcontract_info *cp, UniValue &result)
|
||||
// note: if it is not Heir token funcId would be equal to 0
|
||||
if (funcId == 'F') {
|
||||
//result.push_back(Pair("fundingtxid kind name", txid.GetHex() + std::string(" ") + (typeid(Helper) == typeid(TokenHelper) ? std::string("token") : std::string("coin")) + std::string(" ") + heirName));
|
||||
result.push_back( Pair("fundingtxid", txid.GetHex()) );
|
||||
result.push_back( txid.GetHex() );
|
||||
}
|
||||
else {
|
||||
std::cerr << "HeirList() this is not the initial F transaction=" << txid.GetHex() << std::endl;
|
||||
|
||||
@@ -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