Automatic flag -> lsb of matures

This commit is contained in:
jl777
2019-01-16 22:07:30 -11:00
parent d4bdc4d79f
commit 41b29fcc39
4 changed files with 13 additions and 5 deletions

View File

@@ -33,7 +33,7 @@ UniValue MarmaraCreditloop(uint256 txid);
UniValue MarmaraSettlement(uint64_t txfee,uint256 batontxid);
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 MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid,bool automaticflag);
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);

View File

@@ -168,7 +168,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
{
char coinaddr[64];
GetCCaddress1of2(cp,coinaddr,globalpk,pubkeys[i]);
fprintf(stderr,"%s + %s -> %s vs %s\n",HexStr(globalpk).c_str(),HexStr(pubkeys[i]).c_str(),coinaddr,destaddr);
//fprintf(stderr,"%s + %s -> %s vs %s\n",HexStr(globalpk).c_str(),HexStr(pubkeys[i]).c_str(),coinaddr,destaddr);
if ( strcmp(destaddr,coinaddr) == 0 )
{
privkey = cp->CCpriv;

View File

@@ -301,6 +301,10 @@ bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t
{
return(true); // iterate from issuer all remainder after maturity
}
else if ( funcid == 'D' ) // collect -> automatically spend issuers locked funds, given 'I'
{
return(true); // iterate from issuer all remainder after maturity
}
// staking only for locked utxo
}
return eval->Invalid("fall through error");
@@ -515,14 +519,17 @@ int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector<uint256> &issuanc
return(n);
}
UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid)
UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid,bool automaticflag)
{
CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight());
UniValue result(UniValue::VOBJ); CPubKey mypk; struct CCcontract_info *cp,C; std::string rawtx; char *errorstr=0; uint256 createtxid; int64_t batonamount; int32_t needbaton = 0;
cp = CCinit(&C,EVAL_MARMARA);
if ( txfee == 0 )
txfee = 10000;
// check for batonownership by senderpk and parameters match createtxid
if ( automaticflag != 0 && (matures & 1) == 0 )
matures++;
else if ( automaticflag == 0 && (matures & 1) != 0 )
matures++;
mypk = pubkey2pk(Mypubkey());
memset(&createtxid,0,sizeof(createtxid));
if ( batontxid != zeroid && MarmaraGetcreatetxid(createtxid,batontxid) < 0 )

View File

@@ -5553,6 +5553,7 @@ UniValue marmara_receive(const UniValue& params, bool fHelp)
UniValue result(UniValue::VOBJ); uint256 batontxid; std::vector<uint8_t> senderpub; int64_t amount; int32_t matures; std::string currency;
if ( fHelp || (params.size() != 5 && params.size() != 4) )
{
// automatic flag -> lsb of matures
// 1st marmarareceive 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 1440
// after marmarareceive 039433dc3749aece1bd568f374a45da3b0bc6856990d7da3cd175399577940a775 7.5 MARMARA 1168 d72d87aa0d50436de695c93e2bf3d7273c63c92ef6307913aa01a6ee6a16548b
throw runtime_error("marmarareceive senderpk amount currency matures batontxid\n");
@@ -5573,7 +5574,7 @@ UniValue marmara_receive(const UniValue& params, bool fHelp)
matures = atol(params[3].get_str().c_str());
batontxid = Parseuint256((char *)params[4].get_str().c_str());
} else matures = atol(params[3].get_str().c_str()) + chainActive.LastTip()->GetHeight() + 1;
return(MarmaraReceive(0,pubkey2pk(senderpub),amount,currency,matures,batontxid));
return(MarmaraReceive(0,pubkey2pk(senderpub),amount,currency,matures,batontxid,true));
}
UniValue marmara_issue(const UniValue& params, bool fHelp)