marmara_creditloop
This commit is contained in:
@@ -27,12 +27,12 @@
|
||||
uint64_t komodo_block_prg(uint32_t nHeight);
|
||||
int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid);
|
||||
int32_t MarmaraGetbatontxid(std::vector<uint256> &creditloop,uint256 &batontxid,uint256 txid);
|
||||
UniValue MarmaraCreditloop(uint256 txid);
|
||||
|
||||
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 batontxid);
|
||||
UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 approvaltxid,uint256 batontxid);
|
||||
UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency);
|
||||
UniValue MarmaraCrediloop(uint256 batontxid);
|
||||
|
||||
bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn);
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ int32_t MarmaraGetbatontxid(std::vector<uint256> &creditloop,uint256 &batontxid,
|
||||
{
|
||||
batontxid = spenttxid;
|
||||
fprintf(stderr,"got baton %s %.8f\n",batontxid.GetHex().c_str(),(double)value/COIN);
|
||||
return(0);
|
||||
return(n);
|
||||
}
|
||||
txid = spenttxid;
|
||||
}
|
||||
@@ -211,7 +211,6 @@ int32_t MarmaraGetbatontxid(std::vector<uint256> &creditloop,uint256 &batontxid,
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
CScript Marmara_scriptPubKey(int32_t height,CPubKey pk)
|
||||
{
|
||||
CTxOut ccvout;
|
||||
@@ -476,8 +475,8 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a
|
||||
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";
|
||||
else if ( matures <= chainActive.LastTip()->GetHeight() )
|
||||
errorstr = (char *)"it must mature in the future";
|
||||
if ( errorstr == 0 )
|
||||
{
|
||||
mtx.vin.push_back(CTxIn(approvaltxid,0,CScript()));
|
||||
@@ -547,6 +546,35 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a
|
||||
return(result);
|
||||
}*/
|
||||
|
||||
UniValue MarmaraCreditloop(uint256 txid)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector<uint256> creditloop; uint256 batontxid,createtxid; uint8_t funcid; int32_t numvouts,matures; int64_t amount; CPubKey senderpk; std::string currency;
|
||||
if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 )
|
||||
{
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 )
|
||||
{
|
||||
if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,senderpk,amount,matures,currency)) != 0 )
|
||||
{
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("txid",txid.GetHex()));
|
||||
obj.push_back(Pair("createtxid",createtxid.GetHex()));
|
||||
obj.push_back(Pair("senderpk",HexStr(senderpk)));
|
||||
obj.push_back(Pair("amount",ValueFromAmount(amount)));
|
||||
obj.push_back(Pair("matures",matures));
|
||||
obj.push_back(Pair("currency",currency));
|
||||
a.push_back(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
result.push_back(Pair("result",(char *)"success"));
|
||||
result.push_back("creditloop",a);
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,matches; int64_t totalamount=0; std::vector<uint256> issuances;
|
||||
|
||||
@@ -5656,14 +5656,15 @@ UniValue marmara_info(const UniValue& params, bool fHelp)
|
||||
UniValue marmara_creditloop(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 )
|
||||
if ( fHelp || params.size() != 1 )
|
||||
{
|
||||
// marmaratransfer 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 2693 e5b1ef8ec90e981d3011c8e024cef869b69af2d4dd6837d1ab1d394d3730b7cb
|
||||
throw runtime_error("marmaratransfer receiverpk amount currency matures batontxid\n");
|
||||
// marmaracreditloop 010ff7f9256cefe3b5dee3d72c0eeae9fc6f34884e6f32ffe5b60916df54a9be
|
||||
throw runtime_error("marmaracreditloop txid\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");
|
||||
//UniValue MarmaraCrediloop(uint256 batontxid);
|
||||
txid = Parseuint256((char *)params[0].get_str().c_str());
|
||||
result = MarmaraCreditloop(txid);
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user