diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 04ad7a66d..f5a3d092e 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -62,6 +62,7 @@ CClib_methods[] = { (char *)"rogue", (char *)"highlander", (char *)"gametxid", 1, 1, 'H', EVAL_ROGUE }, { (char *)"rogue", (char *)"playerinfo", (char *)"playertxid", 1, 1, 'I', EVAL_ROGUE }, { (char *)"rogue", (char *)"players", (char *)"", 0, 0, 'D', EVAL_ROGUE }, + { (char *)"rogue", (char *)"games", (char *)"", 0, 0, 'F', EVAL_ROGUE }, #else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, @@ -85,6 +86,7 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #else bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); @@ -118,6 +120,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params) return(rogue_playerinfo(txfee,cp,params)); else if ( strcmp(method,"players") == 0 ) return(rogue_players(txfee,cp,params)); + else if ( strcmp(method,"games") == 0 ) + return(rogue_games(txfee,cp,params)); else { result.push_back(Pair("result","error")); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 450e40470..f1b21598a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -757,7 +757,6 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) CScript opretRegister = rogue_registeropret(gametxid, playertxid); if ( playertxid != zeroid ) { - //fprintf(stderr,"gametxid.%s playertxid.%s opR.%d\n",gametxid.GetHex().c_str(),playertxid.GetHex().c_str(),(int32_t)opretRegister.size()); voutPubkeysEmpty.push_back(burnpk); if ( GetTransaction(playertxid,playertx,hashBlock,false) != 0 ) { @@ -1045,6 +1044,28 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } +UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR); int64_t buyin; uint256 tokenid,gametxid,txid,hashBlock; CTransaction playertx,tx; int32_t maxplayers,vout,numvouts; std::vector playerdata; CPubKey roguepk,mypk,pk; char coinaddr[64]; + roguepk = GetUnspendable(cp,0); + mypk = pubkey2pk(Mypubkey()); + GetCCaddress1of2(cp,coinaddr,roguepk,mypk); + SetCCunspents(unspentOutputs,coinaddr); + rogue_univalue(result,"games",-1,-1); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + if ( vout == 0 ) + { + a.push_back(txid.GetHex()); + } + } + result.push_back(Pair("games",a)); + result.push_back(Pair("numgames",a.size())); +} + bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { return(true);