Update heir cc from upstream

This commit is contained in:
Duke Leto
2019-12-08 17:46:04 -05:00
parent 738e94c743
commit 0308fac481

View File

@@ -7959,7 +7959,6 @@ UniValue heirfund(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ);
uint256 tokenid = zeroid;
int64_t txfee;
int64_t amount;
int64_t inactivitytime;
std::string hex;
@@ -7969,51 +7968,47 @@ UniValue heirfund(const UniValue& params, bool fHelp)
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
if (fHelp || params.size() != 6 && params.size() != 7)
throw runtime_error("heirfund txfee funds heirname heirpubkey inactivitytime memo [tokenid]\n");
if (fHelp || params.size() != 5 && params.size() != 6)
throw runtime_error("heirfund funds heirname heirpubkey inactivitytime memo [tokenid]\n");
if (ensure_CCrequirements(EVAL_HEIR) < 0)
throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
txfee = atoll(params[0].get_str().c_str());
if (txfee < 0) {
result.push_back(Pair("result", "error"));
result.push_back(Pair("error", "incorrect txfee"));
return result;
}
if(params.size() == 7) // tokens in satoshis:
amount = atoll(params[1].get_str().c_str());
else // coins:
amount = atof(params[1].get_str().c_str()) * COIN;
if (params.size() == 6) // tokens in satoshis:
amount = atoll(params[0].get_str().c_str());
else { // coins:
amount = 0;
if (!ParseFixedPoint(params[0].get_str(), 8, &amount)) // using ParseFixedPoint instead atof to avoid small round errors
amount = -1; // set error
}
if (amount <= 0) {
result.push_back(Pair("result", "error"));
result.push_back(Pair("error", "incorrect amount"));
return result;
}
name = params[2].get_str();
name = params[1].get_str();
pubkey = ParseHex(params[3].get_str().c_str());
pubkey = ParseHex(params[2].get_str().c_str());
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());
inactivitytime = atoll(params[3].get_str().c_str());
if (inactivitytime <= 0) {
result.push_back(Pair("result", "error"));
result.push_back(Pair("error", "incorrect inactivity time"));
return result;
}
memo = params[5].get_str();
memo = params[4].get_str();
if (params.size() == 7) {
tokenid = Parseuint256((char*)params[6].get_str().c_str());
if (params.size() == 6) {
tokenid = Parseuint256((char*)params[5].get_str().c_str());
if (tokenid == zeroid) {
result.push_back(Pair("result", "error"));
result.push_back(Pair("error", "incorrect tokenid"));
@@ -8022,9 +8017,9 @@ UniValue heirfund(const UniValue& params, bool fHelp)
}
if( tokenid == zeroid )
result = HeirFundCoinCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, memo);
result = HeirFundCoinCaller(0, amount, name, pubkey2pk(pubkey), inactivitytime, memo);
else
result = HeirFundTokenCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, memo, tokenid);
result = HeirFundTokenCaller(0, amount, name, pubkey2pk(pubkey), inactivitytime, memo, tokenid);
return result;
}
@@ -8033,7 +8028,6 @@ UniValue heiradd(const UniValue& params, bool fHelp)
{
UniValue result;
uint256 fundingtxid;
int64_t txfee;
int64_t amount;
int64_t inactivitytime;
std::string hex;
@@ -8043,24 +8037,18 @@ UniValue heiradd(const UniValue& params, bool fHelp)
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
if (fHelp || params.size() != 3)
throw runtime_error("heiradd txfee funds fundingtxid\n");
if (fHelp || params.size() != 2)
throw runtime_error("heiradd funds fundingtxid\n");
if (ensure_CCrequirements(EVAL_HEIR) < 0)
throw runtime_error(CC_REQUIREMENTS_MSG);
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
txfee = atoll(params[0].get_str().c_str());
if (txfee < 0) {
result.push_back(Pair("result", "error"));
result.push_back(Pair("error", "incorrect txfee"));
return result;
}
std::string strAmount = params[0].get_str();
fundingtxid = Parseuint256((char*)params[1].get_str().c_str());
fundingtxid = Parseuint256((char*)params[2].get_str().c_str());
result = HeirAddCaller(fundingtxid, txfee, params[1].get_str());
result = HeirAddCaller(fundingtxid, 0, strAmount);
return result;
}
@@ -8085,16 +8073,9 @@ UniValue heirclaim(const UniValue& params, bool fHelp)
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
txfee = atoll(params[0].get_str().c_str());
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());
result = HeirClaimCaller(fundingtxid, txfee, params[1].get_str());
std::string strAmount = params[0].get_str();
fundingtxid = Parseuint256((char*)params[1].get_str().c_str());
result = HeirClaimCaller(fundingtxid, 0, strAmount);
return result;
}