corr heir rpc coins -> satoshi conversion

This commit is contained in:
dimxy
2019-01-21 21:04:56 +05:00
parent 50b9f4fe83
commit 9c526cce7d
3 changed files with 87 additions and 39 deletions

View File

@@ -7362,7 +7362,7 @@ UniValue heirfund(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ);
uint256 tokenid = zeroid;
uint64_t txfee;
int64_t txfee;
int64_t amount;
int64_t inactivitytime;
std::string hex;
@@ -7373,21 +7373,34 @@ UniValue heirfund(const UniValue& params, bool fHelp)
return NullUniValue;
if (fHelp || params.size() != 5 && params.size() != 6)
throw runtime_error("heirfundtokens fee funds heirname heirpubkey inactivitytime [tokenid]\n");
throw runtime_error("heirfund txfee funds heirname heirpubkey inactivitytime [tokenid]\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");
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
txfee = atoll((char*)params[0].get_str().c_str());
amount = atoll((char*)params[1].get_str().c_str());
txfee = atoll(params[0].get_str().c_str());
if (txfee < 0)
throw runtime_error("incorrect txfee param\n");
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");
name = params[2].get_str();
pubkey = ParseHex(params[3].get_str().c_str());
if( !pubkey2pk(pubkey).IsValid() )
throw runtime_error("incorrect pubkey\n");
inactivitytime = atof((char*)params[4].get_str().c_str());
inactivitytime = atoll(params[4].get_str().c_str());
if (inactivitytime <= 0)
throw runtime_error("incorrect inactivity time param\n");
if (params.size() == 6) {
tokenid = Parseuint256((char*)params[5].get_str().c_str());
if(tokenid == zeroid)
@@ -7406,7 +7419,7 @@ UniValue heiradd(const UniValue& params, bool fHelp)
{
UniValue result;
uint256 fundingtxid;
uint64_t txfee;
int64_t txfee;
int64_t amount;
int64_t inactivitytime;
std::string hex;
@@ -7417,18 +7430,20 @@ UniValue heiradd(const UniValue& params, bool fHelp)
return NullUniValue;
if (fHelp || params.size() != 3)
throw runtime_error("heiraddtokens fee funds fundingtxid\n");
throw runtime_error("heiradd txfee funds 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");
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
txfee = atoll((char*)params[0].get_str().c_str());
amount = atoll((char*)params[1].get_str().c_str());
txfee = atoll(params[0].get_str().c_str());
if (txfee < 0)
throw runtime_error("incorrect txfee param\n");
fundingtxid = Parseuint256((char*)params[2].get_str().c_str());
result = HeirAddCaller(fundingtxid, txfee, amount);
result = HeirAddCaller(fundingtxid, txfee, params[1].get_str());
return result;
}
@@ -7437,7 +7452,6 @@ UniValue heirclaim(const UniValue& params, bool fHelp)
UniValue result; // result(UniValue::VOBJ);
uint256 fundingtxid;
int64_t txfee;
int64_t amount;
int64_t inactivitytime;
std::string hex;
std::vector<unsigned char> pubkey;
@@ -7448,18 +7462,20 @@ UniValue heirclaim(const UniValue& params, bool fHelp)
return NullUniValue;
if (fHelp || params.size() != 3)
throw runtime_error("heirclaimtokens fee funds fundingtxid\n");
throw runtime_error("heirclaim txfee funds 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");
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
txfee = atoll((char*)params[0].get_str().c_str());
amount = atoll((char*)params[1].get_str().c_str());
txfee = atoll(params[0].get_str().c_str());
if (txfee < 0)
throw runtime_error("incorrect txfee param\n");
fundingtxid = Parseuint256((char*)params[2].get_str().c_str());
result = HeirClaimCaller(fundingtxid, txfee, amount);
result = HeirClaimCaller(fundingtxid, txfee, params[1].get_str());
return result;
}