marmara_issue
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
uint64_t komodo_block_prg(uint32_t nHeight);
|
||||
UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...]
|
||||
UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid);
|
||||
UniValue MarmaraIssue(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid);
|
||||
|
||||
bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn);
|
||||
|
||||
|
||||
@@ -356,6 +356,51 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri
|
||||
return(result);
|
||||
}
|
||||
|
||||
UniValue MarmaraIssue(uint64_t txfee,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 createtxid)
|
||||
{
|
||||
CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight());
|
||||
UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0;
|
||||
cp = CCinit(&C,EVAL_MARMARA);
|
||||
if ( txfee == 0 )
|
||||
txfee = 10000;
|
||||
mypk = pubkey2pk(Mypubkey());
|
||||
if ( currency != "MARMARA" )
|
||||
errorstr = (char *)"for now, only MARMARA loops are supported";
|
||||
else if ( amount < txfee )
|
||||
errorstr = (char *)"amount must be for more than txfee";
|
||||
else if ( matures <= chainActive.LastTip()->GetHeight() )
|
||||
errorstr = (char *)"it must mature in the future";
|
||||
if ( errorstr == 0 )
|
||||
{
|
||||
if ( AddNormalinputs(mtx,mypk,2*txfee,1) > 0 )
|
||||
{
|
||||
errorstr = (char *)"couldnt finalize CCtx";
|
||||
mtx.vout.push_back(MakeCC1vout(EVAL_MARMARA,txfee,receiverpk));
|
||||
rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,MarmaraLoopOpret('I',createtxid,receiverpk,amount,matures,currency));
|
||||
if ( rawtx.size() > 0 )
|
||||
errorstr = 0;
|
||||
} else errorstr = (char *)"dont have enough normal inputs for 2*txfee";
|
||||
}
|
||||
if ( rawtx.size() == 0 || errorstr != 0 )
|
||||
{
|
||||
result.push_back(Pair("result","error"));
|
||||
if ( errorstr != 0 )
|
||||
result.push_back(Pair("error",errorstr));
|
||||
}
|
||||
else
|
||||
{
|
||||
result.push_back(Pair("result",(char *)"success"));
|
||||
result.push_back(Pair("rawtx",rawtx));
|
||||
result.push_back(Pair("funcid","R"));
|
||||
result.push_back(Pair("createtxid",createtxid.GetHex()));
|
||||
result.push_back(Pair("receiverpk",HexStr(receiverpk)));
|
||||
result.push_back(Pair("amount",ValueFromAmount(amount)));
|
||||
result.push_back(Pair("matures",matures));
|
||||
result.push_back(Pair("currency",currency));
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
std::string MarmaraFund(uint64_t txfee,int64_t funds)
|
||||
{
|
||||
CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight());
|
||||
|
||||
@@ -445,6 +445,7 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "marmara", "marmaraaddress", &marmaraaddress, true },
|
||||
{ "marmara", "marmarapoolpayout", &marmara_poolpayout, true },
|
||||
{ "marmara", "marmarareceive", &marmara_receive, true },
|
||||
{ "marmara", "marmaraissue", &marmara_issue, true },
|
||||
|
||||
// Payments
|
||||
{ "payments", "paymentsaddress", &paymentsaddress, true },
|
||||
|
||||
@@ -274,6 +274,7 @@ extern UniValue pegsaddress(const UniValue& params, bool fHelp);
|
||||
extern UniValue marmaraaddress(const UniValue& params, bool fHelp);
|
||||
extern UniValue marmara_poolpayout(const UniValue& params, bool fHelp);
|
||||
extern UniValue marmara_receive(const UniValue& params, bool fHelp);
|
||||
extern UniValue marmara_issue(const UniValue& params, bool fHelp);
|
||||
extern UniValue paymentsaddress(const UniValue& params, bool fHelp);
|
||||
extern UniValue gatewaysaddress(const UniValue& params, bool fHelp);
|
||||
extern UniValue gatewayslist(const UniValue& params, bool fHelp);
|
||||
|
||||
@@ -5573,6 +5573,29 @@ UniValue marmara_receive(const UniValue& params, bool fHelp)
|
||||
return(MarmaraReceive(0,pubkey2pk(senderpub),amount,currency,matures,createtxid));
|
||||
}
|
||||
|
||||
UniValue marmara_issue(const UniValue& params, bool fHelp)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ); uint256 createtxid; std::vector<uint8_t> receiverpub; int64_t amount; int32_t matures; std::string currency;
|
||||
if ( fHelp || params.size() != 5 )
|
||||
{
|
||||
// marmaraissue 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1440 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb
|
||||
throw runtime_error("marmarareceive receiverpk amount currency matures createtxid\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");
|
||||
receiverpub = ParseHex(params[0].get_str().c_str());
|
||||
if (receiverpub.size()!= 33)
|
||||
{
|
||||
ERR_RESULT("invalid receiverpub pubkey");
|
||||
return result;
|
||||
}
|
||||
amount = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999;
|
||||
currency = params[2].get_str();
|
||||
matures = atol(params[3].get_str().c_str()) + chainActive.LastTip()->GetHeight() + 1;
|
||||
createtxid = Parseuint256((char *)params[4].get_str().c_str());
|
||||
return(MarmaraIssue(0,pubkey2pk(receiverpub),amount,currency,matures,createtxid));
|
||||
}
|
||||
|
||||
UniValue channelslist(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if ( fHelp || params.size() > 0 )
|
||||
|
||||
Reference in New Issue
Block a user