From aa60acbf2764632b9e0a206364a959f503f0c729 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 21:15:47 -1100 Subject: [PATCH 01/19] ROGUE_MAXTOTAL = strength*2, ISMANY -> 1 --- src/cc/rogue/init.c | 11 +++++++++-- src/cc/rogue/pack.c | 6 +++--- src/cc/rogue/rogue.h | 3 +++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index 30370f958..ffc0b3707 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -22,6 +22,13 @@ */ void rogue_restoreobject(THING *o,struct rogue_packitem *item); +int32_t rogue_total(THING *o) +{ + if ( (o->o_flags & ISMANY) != 0 ) + return(1); + else return(o->o_count); +} + void restore_player(struct rogue_state *rs) { int32_t i,total = 0; THING *obj; @@ -38,8 +45,8 @@ void restore_player(struct rogue_state *rs) { obj = new_item(); rogue_restoreobject(obj,&rs->P.roguepack[i]); - total += obj->o_count; - if ( total > pstats.s_str*3 ) + total += rogue_total(obj); + if ( total > ROGUE_MAXTOTAL ) break; add_pack(rs,obj,TRUE); } diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index e4ceee689..776669b3b 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -166,16 +166,16 @@ int32_t num_packitems(struct rogue_state *rs) if ( list->o_packch != 0 ) { n++; - total += list->o_count; + total += rogue_total(list); } } if ( rs->guiflag != 0 ) { char str[MAXSTR]; - sprintf(str,"strength*3 %d vs total.%d vs %d inventory letters\n",pstats.s_str*3,total,n); + sprintf(str,"strength*2 %d vs total.%d vs %d inventory letters\n",ROGUE_MAXTOTAL,total,n); add_line(rs,"%s",str); } - if ( total > pstats.s_str*3 ) + if ( total > ROGUE_MAXTOTAL ) return(MAXPACK); return(n); } diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 515c1d44a..9339b630f 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -381,6 +381,9 @@ void restore_player(struct rogue_state *rs); int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); void rogue_bailout(struct rogue_state *rs); +#define ROGUE_MAXTOTAL (pstats.s_str*2) +int32_t rogue_total(THING *o); + /* * Help list */ From f77c99d7817ea50bb83c6d1d3929434016a8fe3e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 21:16:32 -1100 Subject: [PATCH 02/19] int32_t rogue_total(THING *o); --- src/cc/rogue/rogue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 9339b630f..f687b170c 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -382,7 +382,6 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu void rogue_bailout(struct rogue_state *rs); #define ROGUE_MAXTOTAL (pstats.s_str*2) -int32_t rogue_total(THING *o); /* * Help list @@ -806,6 +805,7 @@ THING *new_item(void); THING *new_thing(struct rogue_state *rs); void end_line(struct rogue_state *rs); int32_t num_packitems(struct rogue_state *rs); +int32_t rogue_total(THING *o); void runners(struct rogue_state *rs,int); void land(struct rogue_state *rs,int); From 2c6640cdd4c7774a25cce074be62ea3fd772563f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 22:21:26 -1100 Subject: [PATCH 03/19] Change multiplayer payout to 2x, if amulet then 10x --- src/cc/rogue/rogue_player.h | 2 +- src/cc/rogue/state.c | 1 + src/cc/rogue_rpc.cpp | 8 +++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/rogue_player.h b/src/cc/rogue/rogue_player.h index 1319b3213..e6b7a69e6 100644 --- a/src/cc/rogue/rogue_player.h +++ b/src/cc/rogue/rogue_player.h @@ -25,7 +25,7 @@ struct rogue_packitem }; struct rogue_player { - int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; + int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,amulet; struct rogue_packitem roguepack[MAXPACK]; }; int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 778540b68..589f77422 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1452,6 +1452,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) rs->P.level = pstats.s_lvl; rs->P.experience = pstats.s_exp; rs->P.dungeonlevel = level; + rs->P.amulet = amulet; //fprintf(stderr,"%ld gold.%d hp.%d strength.%d/%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); } //fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d74bc9619..a7bbaa489 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -957,7 +957,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param else { funcid = 'H'; - mult = 1000000; + mult = 200000; } if ( (params= cclib_reparse(&n,params)) != 0 ) { @@ -1008,11 +1008,13 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param cpTokens = CCinit(&tokensC, EVAL_TOKENS); mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens,NULL))); // marker to token cc addr, burnable and validated mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); - fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); + fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet); + if ( P.amulet != 0 ) + mult *= 5; cashout = (uint64_t)P.gold * mult; if ( funcid == 'H' && maxplayers > 1 ) { - if ( numplayers != maxplayers || (numplayers - rogue_playersalive(tmp,gametxid,maxplayers)) > 1 && (P.dungeonlevel > 1 || P.gold < 10000 || P.level < 20) ) + if ( (numplayers != maxplayers || (numplayers - rogue_playersalive(tmp,gametxid,maxplayers)) > 1) && P.amulet == 0 ) return(cclib_error(result,"highlander must be a winner or last one standing")); cashout += numplayers * buyin; } From 1c85c52f49c17e7520ff253aaeee70d37a9233d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 23:04:17 -1100 Subject: [PATCH 04/19] You can ignore ./makerogue: shell: not found --- src/cc/makerogue | 1 + src/cc/rogue_rpc.cpp | 50 ++++++++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index 249e646f5..fb7a53cec 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,4 +1,5 @@ #!/bin/sh +echo "you can ignore ./makerogue: shell: not found" cd rogue; ./configure # only need this first time make; cd .. diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index a7bbaa489..1ca1bce88 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -325,18 +325,20 @@ uint64_t rogue_gamefields(UniValue &obj,int64_t maxplayers,int64_t buyin,uint256 return(seed); } -int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid) +int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransaction &tx,int64_t &buyin,int32_t &maxplayers,uint256 txid,int32_t unspentv0) { uint256 hashBlock; int32_t i,numvouts; char coinaddr[64]; CPubKey roguepk; uint64_t txfee = 10000; buyin = maxplayers = 0; if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { gameheight = komodo_blockheight(hashBlock); - if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) >= txfee && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,0) == 0 ) + if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(playertxid,0,1) == txfee) ) { if ( rogue_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' ) { - if ( numvouts > maxplayers+1 ) + if ( maxplayers < 1 || maxplayers > ROGUE_MAXPLAYERS || buyin < 0 ) + return(-6); + if ( numvouts > 2*maxplayers+1 ) { for (i=0; i 0 ) { gametxid = juint256(jitem(params,0)); - if ( (err= rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid)) == 0 ) + if ( (err= rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid,1)) == 0 ) { if ( n > 1 ) { @@ -803,7 +806,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,destaddr,roguepk,mypk); - if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid) == 0 ) + if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid,1) == 0 ) { if ( rogue_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr,numplayers,symbol,pname) == 0 ) { @@ -811,7 +814,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param result.push_back(Pair("playertxid",playertxid.GetHex())); if ( maxplayers == 1 || nextheight <= batonht+ROGUE_MAXKEYSTROKESGAP ) { - mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); + mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); // this validates user mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,batonvalue-txfee,roguepk,mypk)); Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,destaddr); @@ -830,7 +833,7 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat roguepk = GetUnspendable(cp,0); *numkeysp = 0; seed = 0; - if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) + if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) == 0 ) { if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,rogueaddr,numplayers,symbol,pname) == 0 ) { @@ -965,7 +968,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param { gametxid = juint256(jitem(params,0)); result.push_back(Pair("gametxid",gametxid.GetHex())); - if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) + if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,1)) == 0 ) { if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers,symbol,pname) == 0 ) { @@ -1078,7 +1081,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { txid = juint256(jitem(params,0)); result.push_back(Pair("gametxid",txid.GetHex())); - if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid) == 0 ) + if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid,0) == 0 ) { result.push_back(Pair("result","success")); result.push_back(Pair("gameheight",(int64_t)gameheight)); @@ -1118,7 +1121,7 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis != txfee || vout != 0 ) // reject any that are not highlander markers continue; - if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid) == 0 && nextheight <= gameheight+ROGUE_MAXKEYSTROKESGAP ) + if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid,1) == 0 && nextheight <= gameheight+ROGUE_MAXKEYSTROKESGAP ) { rogue_playersalive(numplayers,txid,maxplayers); if ( numplayers < maxplayers ) @@ -1182,7 +1185,7 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { if ( rogue_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) { - if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) + if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0) == 0 ) { if ( CCgettxout(txid,vout,1) < 0 ) b.push_back(gametxid.GetHex()); @@ -1262,7 +1265,7 @@ int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid,ptxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errs,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid,ptxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 21274 ) return(true); if ( (numvouts= tx.vout.size()) > 1 ) @@ -1291,13 +1294,12 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C switch ( funcid ) { case 'G': - if ( (funcid= rogue_newgameopreturndecode(buyin,maxplayers,scriptPubKey)) != 'G' ) + if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) != 0 ) { - //fprintf(stderr,"height.%d couldnt decode newgame opret\n",height); + fprintf(stderr,"height.%d rogue_isvalidgame error.%d\n",height,err); //if ( height > 20000 ) - return eval->Invalid("couldnt decode newgame opret"); + return eval->Invalid("invalid gametxid"); } - // validate newgame tx return(true); break; case 'R': @@ -1307,6 +1309,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C //if ( height > 20000 ) return eval->Invalid("couldnt decode register opret"); } + // baton is created // validation is done below break; case 'K': @@ -1316,7 +1319,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C //if ( height > 20000 ) return eval->Invalid("couldnt decode keystrokes opret"); } - // validate keystrokes are from the correct pk. might need to add vin + // spending the baton proves it is the user if the pk is the signer return(true); break; case 'H': case 'Q': @@ -1326,7 +1329,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C //if ( height > 20000 ) return eval->Invalid("couldnt decode H/Q opret"); } - // validation is done below + // spending the baton proves it is the user if the pk is the signer + // rest of validation is done below break; default: return eval->Invalid("illegal rogue non-decoded funcid"); @@ -1353,7 +1357,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } else // 'H' { - // verify vin/vout + // verify vin/vout and proper payouts } return(true); break; From fed6024ee745bf526d543ba70f9253239b09a6c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 23:05:43 -1100 Subject: [PATCH 05/19] err --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 1ca1bce88..b5e44aad5 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -332,7 +332,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { gameheight = komodo_blockheight(hashBlock); - if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(playertxid,0,1) == txfee) ) + if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(txid,0,1) == txfee) ) { if ( rogue_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' ) { @@ -1265,7 +1265,7 @@ int32_t rogue_playerdata_validate(uint256 &playertxid,struct CCcontract_info *cp bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { - CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errs,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid,ptxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,err,dispflag,gameheight,score,numvouts; CTransaction vintx,gametx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid,ptxid; int64_t buyin; std::vector playerdata,keystrokes; std::string symbol,pname; if ( strcmp(ASSETCHAINS_SYMBOL,"ROGUE") == 0 && height < 21274 ) return(true); if ( (numvouts= tx.vout.size()) > 1 ) From 9377ec6542066c435b6660797d38ccd92393175d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 23:06:36 -1100 Subject: [PATCH 06/19] Ignore --- src/cc/makerogue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index fb7a53cec..d737f39fa 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,9 +1,8 @@ #!/bin/sh -echo "you can ignore ./makerogue: shell: not found" cd rogue; ./configure # only need this first time +echo "you can ignore ./makerogue: shell: not found" make; cd .. gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -#gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so cp librogue.so ../libcc.so From 0ca1b888c395737651ddf73b4592d4021e3c7c30 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 23:10:55 -1100 Subject: [PATCH 07/19] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b5e44aad5..510b67727 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1297,7 +1297,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) != 0 ) { fprintf(stderr,"height.%d rogue_isvalidgame error.%d\n",height,err); - //if ( height > 20000 ) + if ( height > 30000 ) return eval->Invalid("invalid gametxid"); } return(true); From 60e6554848eacda156de40263806f6966ca315a1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 23:16:24 -1100 Subject: [PATCH 08/19] Test --- src/cc/rogue_rpc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 510b67727..d4ee66b57 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1294,12 +1294,14 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C switch ( funcid ) { case 'G': + gametxid = tx.GetHash(); if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) != 0 ) { - fprintf(stderr,"height.%d rogue_isvalidgame error.%d\n",height,err); + fprintf(stderr,"height.%d %s rogue_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); if ( height > 30000 ) return eval->Invalid("invalid gametxid"); } + fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); return(true); break; case 'R': From 79e09db7e6a8a0b1c35fc5a3d75bd54f2ae9497d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 23:28:25 -1100 Subject: [PATCH 09/19] +print --- src/cc/rogue_rpc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d4ee66b57..f7ac0162a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -814,7 +814,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param result.push_back(Pair("playertxid",playertxid.GetHex())); if ( maxplayers == 1 || nextheight <= batonht+ROGUE_MAXKEYSTROKESGAP ) { - mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); // this validates user + mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); //this validates user if pk mtx.vout.push_back(MakeCC1of2vout(cp->evalcode,batonvalue-txfee,roguepk,mypk)); Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,destaddr); @@ -1293,7 +1293,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { switch ( funcid ) { - case 'G': + case 'G': // seems just need to make sure no vout abuse is left to do gametxid = tx.GetHash(); if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) != 0 ) { @@ -1301,7 +1301,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( height > 30000 ) return eval->Invalid("invalid gametxid"); } - fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); + //fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); return(true); break; case 'R': @@ -1342,6 +1342,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C switch ( funcid ) { case 'R': // register + // verify vout amounts are as they should be and no vins that shouldnt be return(true); case 'H': // win case 'Q': // bailout From 961a1eb0a2b1967cfdb74fe548f661fd3b5a7713 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 23:28:46 -1100 Subject: [PATCH 10/19] Enforce new game --- src/cc/rogue_rpc.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f7ac0162a..ec1b669dc 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1298,8 +1298,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) != 0 ) { fprintf(stderr,"height.%d %s rogue_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); - if ( height > 30000 ) - return eval->Invalid("invalid gametxid"); + return eval->Invalid("invalid gametxid"); } //fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); return(true); From f3c28c684a58e4601e439be6200f8365aac0d6fa Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 00:07:07 -1100 Subject: [PATCH 11/19] -print --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ec1b669dc..9cef26d83 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1288,7 +1288,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } if ( e == EVAL_ROGUE ) { - fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); + //fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); if ( decoded == 0 ) { switch ( funcid ) From d0888260aa142faab3044a6ea0876a2ed5849a61 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 01:24:08 -1100 Subject: [PATCH 12/19] +print validgame --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9cef26d83..d1c63f592 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1300,7 +1300,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C fprintf(stderr,"height.%d %s rogue_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); return eval->Invalid("invalid gametxid"); } - //fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); + fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); return(true); break; case 'R': From ef05677ec88427b56d6083c6711a0de05af00297 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 01:24:32 -1100 Subject: [PATCH 13/19] -print --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d1c63f592..9cef26d83 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1300,7 +1300,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C fprintf(stderr,"height.%d %s rogue_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); return eval->Invalid("invalid gametxid"); } - fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); + //fprintf(stderr,"height.%d %s rogue_isvalidgame\n",height,gametxid.GetHex().c_str()); return(true); break; case 'R': From ee5d656a2c1c7df3160281939ebebeab3fbeba8a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 01:31:02 -1100 Subject: [PATCH 14/19] Rework game validation --- src/cc/rogue_rpc.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9cef26d83..78541b63c 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -329,9 +329,10 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa { uint256 hashBlock; int32_t i,numvouts; char coinaddr[64]; CPubKey roguepk; uint64_t txfee = 10000; buyin = maxplayers = 0; - if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) + if ( (txid == zeroid || myGetTransaction(txid,tx,hashBlock) != 0) && (numvouts= tx.vout.size()) > 1 ) { - gameheight = komodo_blockheight(hashBlock); + if ( txid != zeroid ) + gameheight = komodo_blockheight(hashBlock); if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(txid,0,1) == txfee) ) { if ( rogue_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' ) @@ -1295,7 +1296,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { case 'G': // seems just need to make sure no vout abuse is left to do gametxid = tx.GetHash(); - if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0)) != 0 ) + gameheight = height; + if ( (err= rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,zerotxid,0)) != 0 ) { fprintf(stderr,"height.%d %s rogue_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); return eval->Invalid("invalid gametxid"); From 67eb2929d63534398efdea4007c7d6192b598634 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 01:31:56 -1100 Subject: [PATCH 15/19] Zeroed --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 78541b63c..9d493e5ae 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1297,7 +1297,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'G': // seems just need to make sure no vout abuse is left to do gametxid = tx.GetHash(); gameheight = height; - if ( (err= rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,zerotxid,0)) != 0 ) + if ( (err= rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,zeroid,0)) != 0 ) { fprintf(stderr,"height.%d %s rogue_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); return eval->Invalid("invalid gametxid"); From 92c9825cdea8ad8be5a00b7f74412556840d69a3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 01:41:28 -1100 Subject: [PATCH 16/19] Test --- src/cc/rogue_rpc.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9d493e5ae..50492e2cf 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -333,6 +333,11 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa { if ( txid != zeroid ) gameheight = komodo_blockheight(hashBlock); + else + { + txid = tx.GetHash(); + fprintf(stderr,"set txid %s %llu\n",txid.GetHex().c_str(),(long long)CCgettxout(txid,0,1)); + } if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(txid,0,1) == txfee) ) { if ( rogue_newgameopreturndecode(buyin,maxplayers,tx.vout[numvouts-1].scriptPubKey) == 'G' ) From fbe6061dc6e76a292ae49e284a1354dc2de4f8b0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 01:42:45 -1100 Subject: [PATCH 17/19] Test --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 50492e2cf..2496d6a5e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1300,9 +1300,10 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C switch ( funcid ) { case 'G': // seems just need to make sure no vout abuse is left to do + gametx = tx; gametxid = tx.GetHash(); gameheight = height; - if ( (err= rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,zeroid,0)) != 0 ) + if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,zeroid,0)) != 0 ) { fprintf(stderr,"height.%d %s rogue_isvalidgame error.%d\n",height,gametxid.GetHex().c_str(),err); return eval->Invalid("invalid gametxid"); From 180114697aaf5f7ff6ee96ec51722e1150aeea42 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Feb 2019 01:44:36 -1100 Subject: [PATCH 18/19] -print --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 2496d6a5e..3d89e0568 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -336,7 +336,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa else { txid = tx.GetHash(); - fprintf(stderr,"set txid %s %llu\n",txid.GetHex().c_str(),(long long)CCgettxout(txid,0,1)); + //fprintf(stderr,"set txid %s %llu\n",txid.GetHex().c_str(),(long long)CCgettxout(txid,0,1)); } if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) == txfee && (unspentv0 == 0 || CCgettxout(txid,0,1) == txfee) ) { From 2ca8d1eedaef49bccd8622bc8f61a6d6fa4c6dc9 Mon Sep 17 00:00:00 2001 From: ca333 Date: Tue, 19 Feb 2019 14:15:09 +0100 Subject: [PATCH 19/19] resolve conflict PR for multi OS build will follow this PR --- src/cc/makerogue | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/makerogue b/src/cc/makerogue index d737f39fa..a38eab6a4 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -1,8 +1,11 @@ #!/bin/sh cd rogue; -./configure # only need this first time -echo "you can ignore ./makerogue: shell: not found" +./configure make; cd .. -gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -cp librogue.so ../libcc.so +if make -f Makefile_rogue "$@"; then + echo ROGUE BUILD SUCCESSFUL +else + echo ROGUE BUILD FAILED + exit 1 +fi