Marmara transfer

This commit is contained in:
jl777
2019-01-13 03:36:14 -11:00
parent 8ae7b65569
commit c334d5c2e4
5 changed files with 30 additions and 4 deletions

View File

@@ -26,7 +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);
UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,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);

View File

@@ -356,7 +356,7 @@ 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)
UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,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;
@@ -391,7 +391,8 @@ UniValue MarmaraIssue(uint64_t txfee,CPubKey receiverpk,int64_t amount,std::stri
{
result.push_back(Pair("result",(char *)"success"));
result.push_back(Pair("rawtx",rawtx));
result.push_back(Pair("funcid","I"));
char str[2]; str[0] = funcid, str[1] = 0;
result.push_back(Pair("funcid",str));
result.push_back(Pair("createtxid",createtxid.GetHex()));
result.push_back(Pair("receiverpk",HexStr(receiverpk)));
result.push_back(Pair("amount",ValueFromAmount(amount)));

View File

@@ -446,6 +446,7 @@ static const CRPCCommand vRPCCommands[] =
{ "marmara", "marmarapoolpayout", &marmara_poolpayout, true },
{ "marmara", "marmarareceive", &marmara_receive, true },
{ "marmara", "marmaraissue", &marmara_issue, true },
{ "marmara", "marmaratransfer", &marmara_transfer, true },
// Payments
{ "payments", "paymentsaddress", &paymentsaddress, true },

View File

@@ -275,6 +275,7 @@ 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 marmara_transfer(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);

View File

@@ -5593,7 +5593,30 @@ UniValue marmara_issue(const UniValue& params, bool fHelp)
currency = params[2].get_str();
matures = atol(params[3].get_str().c_str());
createtxid = Parseuint256((char *)params[4].get_str().c_str());
return(MarmaraIssue(0,pubkey2pk(receiverpub),amount,currency,matures,createtxid));
return(MarmaraIssue(0,'I',pubkey2pk(receiverpub),amount,currency,matures,createtxid));
}
UniValue marmara_transfer(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 2693 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb
throw runtime_error("marmaratransfer 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());
createtxid = Parseuint256((char *)params[4].get_str().c_str());
return(MarmaraIssue(0,'T',pubkey2pk(receiverpub),amount,currency,matures,createtxid));
}
UniValue channelslist(const UniValue& params, bool fHelp)