diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 2629b7dfd..681689a6e 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -548,38 +548,63 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a UniValue MarmaraCreditloop(uint256 txid) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,hashBlock; uint8_t funcid; int32_t i,n,numvouts,matures; int64_t amount; CPubKey senderpk; std::string currency; CTransaction tx; + UniValue result(UniValue::VOBJ),a(UniValue::VARR); std::vector creditloop; uint256 batontxid,createtxid,refcreatetxid,hashBlock; uint8_t funcid; int32_t i,n,numvouts,matures,refmatures; int64_t amount,refamount; CPubKey senderpk; std::string currency,refcurrency; CTransaction tx; char batonaddr[64]; if ( (n= MarmaraGetbatontxid(creditloop,batontxid,txid)) > 0 ) { - for (i=0; i 1 ) { - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + result.push_back(Pair("result",(char *)"success")); + result.push_back(Pair("batontxid",batontxid.GetHex())); + if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,refcreatetxid,senderpk,refamount,refmatures,refcurrency)) != 0 ) { - if ( (funcid= MarmaraDecodeLoopOpret(tx.vout[numvouts-1].scriptPubKey,createtxid,senderpk,amount,matures,currency)) != 0 ) + obj.push_back(Pair("funcid",funcid)); + obj.push_back(Pair("createtxid",createtxid.GetHex())); + obj.push_back(Pair("amount",ValueFromAmount(amount))); + obj.push_back(Pair("matures",matures)); + obj.push_back(Pair("currency",currency)); + GetScriptaddr(batonaddr,tx.vout[0].scriptPubKey); + obj.push_back(Pair("batonaddress",batonaddr)); + for (i=0; i 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("funcid",funcid)); + obj.push_back(Pair("senderpk",HexStr(senderpk))); + a.push_back(obj); + } + } } + result.push_back(Pair("n",n)); + result.push_back(Pair("creditloop",a)); + } + else + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"couldnt get batontxid opret")); } } - result.push_back(Pair("result",(char *)"success")); - result.push_back(Pair("n",n)); - result.push_back(Pair("creditloop",a)); + else + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"couldnt find batontxid")); + } + } + else + { + result.push_back(Pair("result",(char *)"error")); + result.push_back(Pair("error",(char *)"couldnt get creditloop")); } - 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 issuances; + + { UniValue result(UniValue::VOBJ),a(UniValue::VARR); int32_t i,n,matches; int64_t totalamount=0; std::vector issuances; CPubKey Marmarapk; struct CCcontract_info *cp,C; result.push_back(Pair("result","success")); if ( refpk.size() == 33 )