diff --git a/src/assetchains.json b/src/assetchains.json index 9e7307a31..27bf3bd56 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -182,7 +182,7 @@ "190.114.254.104" ] }, - { + { "ac_name": "DION", "ac_supply": "3900000000", "ac_reward": "22260000000", @@ -247,4 +247,5 @@ "ac_cc": "2", "addnode": ["51.75.122.83"] } + ] diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 6e3fd5909..6e57e816b 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -146,6 +146,13 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti numvouts = tx.vout.size(); outputsDummy = inputs = 0; preventCCvins = preventCCvouts = -1; + + // add specific chains exceptions for old token support: + if (strcmp(ASSETCHAINS_SYMBOL, "SEC") == 0 && chainActive.Height() <= 144073) + return true; + + if (strcmp(ASSETCHAINS_SYMBOL, "MGNX") == 0 && chainActive.Height() <= 210190) + return true; // add specific chains exceptions for old token support: if (strcmp(ASSETCHAINS_SYMBOL, "SEC") == 0 && chainActive.Height() <= 144073) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 1bb44af18..4f2b421aa 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1213,6 +1213,9 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } else { return(0); } + //fprintf(stderr,"numentropy tx %d: %.8f\n",n,(double)totalinputs/COIN); + entropytxs = n; + return(totalinputs); } bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontract_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 4841eb981..e36ea807e 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -2929,26 +2929,28 @@ int32_t main(void) void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen); char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); -int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,std::vector voutpubtxids) +int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,int32_t numvouts,std::vector voutpubtxids) { - CScript data; uint256 hash; int32_t i,numvins,numvouts,len = 0; std::vector vintxids; std::vector vinprevns; std::vector vouts; + CScript data; uint256 hash; int32_t i,numvins,len = 0; std::vector vintxids; std::vector vinprevns; std::vector vouts; numvins = tx.vin.size(); - numvouts = tx.vout.size(); - if ( tx.vout[numvouts-1].scriptPubKey[0] == 0x6a ) + for (i=0; i bigpub) @@ -3367,7 +3369,10 @@ UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params voutpubtxids.push_back(mypubtxid); } tx = mtx; - dilithium_Qmsghash(msg,tx,voutpubtxids); + dilithium_Qmsghash(msg,tx,(int32_t)voutpubtxids.size(),voutpubtxids); + //for (i=0; i<32; i++) + // fprintf(stderr,"%02x",msg[i]); + //fprintf(stderr," msg\n"); sig.resize(32+CRYPTO_BYTES); if ( dilithium_bigpubget(handle,destpub33,pk2,mypubtxid) < 0 ) return(cclib_error(result,"couldnt get bigpub")); @@ -3423,7 +3428,7 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co numvouts = tx.vout.size(); if ( dilithium_Qsendopretdecode(destpubtxid,sig,voutpubtxids,tx.vout[numvouts-1].scriptPubKey) == 'Q' && destpubtxid == signerpubtxid && sig.size() == smlen ) { - if ( dilithium_Qmsghash(msg,tx,voutpubtxids) < 0 ) + if ( dilithium_Qmsghash(msg,tx,numvouts-1,voutpubtxids) < 0 ) return eval->Invalid("couldnt get Qmsghash"); else if ( dilithium_bigpubget(handle,destpub33,pk,signerpubtxid) < 0 ) return eval->Invalid("couldnt get bigpub"); @@ -3432,7 +3437,15 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co if ( _dilithium_verify(msg2,&mlen,&sig[0],smlen,pk) < 0 ) return eval->Invalid("failed dilithium verify"); else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 ) + { + for (i=0; i<32; i++) + fprintf(stderr,"%02x",msg[i]); + fprintf(stderr," vs "); + for (i=0; iInvalid("failed dilithium msg verify"); + } else return true; } } else return eval->Invalid("failed decode Qsend"); diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 7b68aa49e..4e6221aa1 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -235,6 +235,7 @@ int32_t safecopy(char *dest,char *src,long len) #endif int32_t rogue_replay(uint64_t seed,int32_t sleeptime); +char *rogue_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter); int rogue(int argc, char **argv, char **envp); void *OS_loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep) @@ -741,7 +742,7 @@ int32_t rogue_sendrawtransaction(char *rawtx) void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num) { - char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx; int32_t i; cJSON *retjson; + char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys; int32_t i,numpastkeys; cJSON *retjson; //fprintf(stderr,"rogue_progress num.%d\n",num); if ( rs->guiflag != 0 && Gametxidstr[0] != 0 ) { @@ -762,6 +763,11 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char * } free(rs->keystrokeshex), rs->keystrokeshex = 0; } + if ( (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 ) + { + free(pastkeys); + } + for (i=0; iisconn[j] = FALSE; - r1->ingraph = FALSE; + for (j = 0; j < MAXROOMS; j++) + r1->isconn[j] = FALSE; + r1->ingraph = FALSE; } - + /* * starting with one room, connect it to a random adjacent room and * then pick a new room to start with. @@ -61,65 +61,65 @@ do_passages(struct rogue_state *rs) r1->ingraph = TRUE; do { - /* - * find a room to connect with - */ - j = 0; - for (i = 0; i < MAXROOMS; i++) - if (r1->conn[i] && !rdes[i].ingraph && rnd(++j) == 0) - r2 = &rdes[i]; - /* - * if no adjacent rooms are outside the graph, pick a new room - * to look from - */ - if (j == 0) - { - do - r1 = &rdes[rnd(MAXROOMS)]; - until (r1->ingraph); - } - /* - * otherwise, connect new room to the graph, and draw a tunnel - * to it - */ - else - { - r2->ingraph = TRUE; - i = (int)(r1 - rdes); - j = (int)(r2 - rdes); - conn(rs,i, j); - r1->isconn[j] = TRUE; - r2->isconn[i] = TRUE; - roomcount++; - } + /* + * find a room to connect with + */ + j = 0; + for (i = 0; i < MAXROOMS; i++) + if (r1->conn[i] && !rdes[i].ingraph && rnd(++j) == 0) + r2 = &rdes[i]; + /* + * if no adjacent rooms are outside the graph, pick a new room + * to look from + */ + if (j == 0) + { + do + r1 = &rdes[rnd(MAXROOMS)]; + until (r1->ingraph); + } + /* + * otherwise, connect new room to the graph, and draw a tunnel + * to it + */ + else + { + r2->ingraph = TRUE; + i = (int)(r1 - rdes); + j = (int)(r2 - rdes); + conn(rs,i, j); + r1->isconn[j] = TRUE; + r2->isconn[i] = TRUE; + roomcount++; + } } while (roomcount < MAXROOMS); - + /* * attempt to add passages to the graph a random number of times so * that there isn't always just one unique passage through it. */ for (roomcount = rnd(5); roomcount > 0; roomcount--) { - r1 = &rdes[rnd(MAXROOMS)]; /* a random room to look from */ - /* - * find an adjacent room not already connected - */ - j = 0; - for (i = 0; i < MAXROOMS; i++) - if (r1->conn[i] && !r1->isconn[i] && rnd(++j) == 0) - r2 = &rdes[i]; - /* - * if there is one, connect it and look for the next added - * passage - */ - if (j != 0) - { - i = (int)(r1 - rdes); - j = (int)(r2 - rdes); - conn(rs,i, j); - r1->isconn[j] = TRUE; - r2->isconn[i] = TRUE; - } + r1 = &rdes[rnd(MAXROOMS)]; /* a random room to look from */ + /* + * find an adjacent room not already connected + */ + j = 0; + for (i = 0; i < MAXROOMS; i++) + if (r1->conn[i] && !r1->isconn[i] && rnd(++j) == 0) + r2 = &rdes[i]; + /* + * if there is one, connect it and look for the next added + * passage + */ + if (j != 0) + { + i = (int)(r1 - rdes); + j = (int)(r2 - rdes); + conn(rs,i, j); + r1->isconn[j] = TRUE; + r2->isconn[i] = TRUE; + } } passnum(); } @@ -138,22 +138,22 @@ conn(struct rogue_state *rs,int r1, int r2) int rm; char direc; static coord del, curr, turn_delta, spos, epos; - + if (r1 < r2) { - rm = r1; - if (r1 + 1 == r2) - direc = 'r'; - else - direc = 'd'; + rm = r1; + if (r1 + 1 == r2) + direc = 'r'; + else + direc = 'd'; } else { - rm = r2; - if (r2 + 1 == r1) - direc = 'r'; - else - direc = 'd'; + rm = r2; + if (r2 + 1 == r1) + direc = 'r'; + else + direc = 'd'; } rpf = &rooms[rm]; /* @@ -162,75 +162,75 @@ conn(struct rogue_state *rs,int r1, int r2) */ if (direc == 'd') { - rmt = rm + 3; /* room # of dest */ - rpt = &rooms[rmt]; /* room pointer of dest */ - del.x = 0; /* direction of move */ - del.y = 1; - spos.x = rpf->r_pos.x; /* start of move */ - spos.y = rpf->r_pos.y; - epos.x = rpt->r_pos.x; /* end of move */ - epos.y = rpt->r_pos.y; - if (!(rpf->r_flags & ISGONE)) /* if not gone pick door pos */ - do - { - spos.x = rpf->r_pos.x + rnd(rpf->r_max.x - 2) + 1; - spos.y = rpf->r_pos.y + rpf->r_max.y - 1; - } while ((rpf->r_flags&ISMAZE) && !(flat(spos.y, spos.x)&F_PASS)); - if (!(rpt->r_flags & ISGONE)) - do - { - epos.x = rpt->r_pos.x + rnd(rpt->r_max.x - 2) + 1; - } while ((rpt->r_flags&ISMAZE) && !(flat(epos.y, epos.x)&F_PASS)); - distance = abs(spos.y - epos.y) - 1; /* distance to move */ - turn_delta.y = 0; /* direction to turn */ - turn_delta.x = (spos.x < epos.x ? 1 : -1); - turn_distance = abs(spos.x - epos.x); /* how far to turn */ + rmt = rm + 3; /* room # of dest */ + rpt = &rooms[rmt]; /* room pointer of dest */ + del.x = 0; /* direction of move */ + del.y = 1; + spos.x = rpf->r_pos.x; /* start of move */ + spos.y = rpf->r_pos.y; + epos.x = rpt->r_pos.x; /* end of move */ + epos.y = rpt->r_pos.y; + if (!(rpf->r_flags & ISGONE)) /* if not gone pick door pos */ + do + { + spos.x = rpf->r_pos.x + rnd(rpf->r_max.x - 2) + 1; + spos.y = rpf->r_pos.y + rpf->r_max.y - 1; + } while ((rpf->r_flags&ISMAZE) && !(flat(spos.y, spos.x)&F_PASS)); + if (!(rpt->r_flags & ISGONE)) + do + { + epos.x = rpt->r_pos.x + rnd(rpt->r_max.x - 2) + 1; + } while ((rpt->r_flags&ISMAZE) && !(flat(epos.y, epos.x)&F_PASS)); + distance = abs(spos.y - epos.y) - 1; /* distance to move */ + turn_delta.y = 0; /* direction to turn */ + turn_delta.x = (spos.x < epos.x ? 1 : -1); + turn_distance = abs(spos.x - epos.x); /* how far to turn */ } else if (direc == 'r') /* setup for moving right */ { - rmt = rm + 1; - rpt = &rooms[rmt]; - del.x = 1; - del.y = 0; - spos.x = rpf->r_pos.x; - spos.y = rpf->r_pos.y; - epos.x = rpt->r_pos.x; - epos.y = rpt->r_pos.y; - if (!(rpf->r_flags & ISGONE)) - do - { - spos.x = rpf->r_pos.x + rpf->r_max.x - 1; - spos.y = rpf->r_pos.y + rnd(rpf->r_max.y - 2) + 1; - } while ((rpf->r_flags&ISMAZE) && !(flat(spos.y, spos.x)&F_PASS)); - if (!(rpt->r_flags & ISGONE)) - do - { - epos.y = rpt->r_pos.y + rnd(rpt->r_max.y - 2) + 1; - } while ((rpt->r_flags&ISMAZE) && !(flat(epos.y, epos.x)&F_PASS)); - distance = abs(spos.x - epos.x) - 1; - turn_delta.y = (spos.y < epos.y ? 1 : -1); - turn_delta.x = 0; - turn_distance = abs(spos.y - epos.y); + rmt = rm + 1; + rpt = &rooms[rmt]; + del.x = 1; + del.y = 0; + spos.x = rpf->r_pos.x; + spos.y = rpf->r_pos.y; + epos.x = rpt->r_pos.x; + epos.y = rpt->r_pos.y; + if (!(rpf->r_flags & ISGONE)) + do + { + spos.x = rpf->r_pos.x + rpf->r_max.x - 1; + spos.y = rpf->r_pos.y + rnd(rpf->r_max.y - 2) + 1; + } while ((rpf->r_flags&ISMAZE) && !(flat(spos.y, spos.x)&F_PASS)); + if (!(rpt->r_flags & ISGONE)) + do + { + epos.y = rpt->r_pos.y + rnd(rpt->r_max.y - 2) + 1; + } while ((rpt->r_flags&ISMAZE) && !(flat(epos.y, epos.x)&F_PASS)); + distance = abs(spos.x - epos.x) - 1; + turn_delta.y = (spos.y < epos.y ? 1 : -1); + turn_delta.x = 0; + turn_distance = abs(spos.y - epos.y); } #ifdef MASTER else - debug("error in connection tables"); + debug("error in connection tables"); #endif - + turn_spot = rnd(distance - 1) + 1; /* where turn starts */ - + /* * Draw in the doors on either side of the passage or just put #'s * if the rooms are gone. */ if (!(rpf->r_flags & ISGONE)) - door(rpf, &spos); + door(rpf, &spos); else - putpass(&spos); + putpass(&spos); if (!(rpt->r_flags & ISGONE)) - door(rpt, &epos); + door(rpt, &epos); else - putpass(&epos); + putpass(&epos); /* * Get ready to move... */ @@ -238,31 +238,31 @@ conn(struct rogue_state *rs,int r1, int r2) curr.y = spos.y; while (distance > 0) { - /* - * Move to new position - */ - curr.x += del.x; - curr.y += del.y; - /* - * Check if we are at the turn place, if so do the turn - */ - if (distance == turn_spot) - while (turn_distance--) - { - putpass(&curr); - curr.x += turn_delta.x; - curr.y += turn_delta.y; - } - /* - * Continue digging along - */ - putpass(&curr); - distance--; + /* + * Move to new position + */ + curr.x += del.x; + curr.y += del.y; + /* + * Check if we are at the turn place, if so do the turn + */ + if (distance == turn_spot) + while (turn_distance--) + { + putpass(&curr); + curr.x += turn_delta.x; + curr.y += turn_delta.y; + } + /* + * Continue digging along + */ + putpass(&curr); + distance--; } curr.x += del.x; curr.y += del.y; if (!ce(curr, epos)) - msg(rs,"warning, connectivity problem on this level"); + msg(rs,"warning, connectivity problem on this level"); } /* @@ -274,13 +274,13 @@ void putpass(coord *cp) { PLACE *pp; - + pp = INDEX(cp->y, cp->x); pp->p_flags |= F_PASS; if (rnd(10) + 1 < level && rnd(40) == 0) - pp->p_flags &= ~F_REAL; + pp->p_flags &= ~F_REAL; else - pp->p_ch = PASSAGE; + pp->p_ch = PASSAGE; } /* @@ -293,23 +293,23 @@ void door(struct room *rm, coord *cp) { PLACE *pp; - + rm->r_exit[rm->r_nexits++] = *cp; - + if (rm->r_flags & ISMAZE) - return; - + return; + pp = INDEX(cp->y, cp->x); if (rnd(10) + 1 < level && rnd(5) == 0) { - if (cp->y == rm->r_pos.y || cp->y == rm->r_pos.y + rm->r_max.y - 1) - pp->p_ch = '-'; - else - pp->p_ch = '|'; - pp->p_flags &= ~F_REAL; + if (cp->y == rm->r_pos.y || cp->y == rm->r_pos.y + rm->r_max.y - 1) + pp->p_ch = '-'; + else + pp->p_ch = '|'; + pp->p_flags &= ~F_REAL; } else - pp->p_ch = DOOR; + pp->p_ch = DOOR; } #ifdef MASTER @@ -324,31 +324,31 @@ add_pass() PLACE *pp; int y, x; char ch; - + for (y = 1; y < NUMLINES - 1; y++) - for (x = 0; x < NUMCOLS; x++) - { - pp = INDEX(y, x); - if ((pp->p_flags & F_PASS) || pp->p_ch == DOOR || - (!(pp->p_flags&F_REAL) && (pp->p_ch == '|' || pp->p_ch == '-'))) - { - ch = pp->p_ch; - if (pp->p_flags & F_PASS) - ch = PASSAGE; - pp->p_flags |= F_SEEN; - move(y, x); - if (pp->p_monst != NULL) - pp->p_monst->t_oldch = pp->p_ch; - else if (pp->p_flags & F_REAL) - addch(ch); - else - { - standout(); - addch((pp->p_flags & F_PASS) ? PASSAGE : DOOR); - standend(); - } - } - } + for (x = 0; x < NUMCOLS; x++) + { + pp = INDEX(y, x); + if ((pp->p_flags & F_PASS) || pp->p_ch == DOOR || + (!(pp->p_flags&F_REAL) && (pp->p_ch == '|' || pp->p_ch == '-'))) + { + ch = pp->p_ch; + if (pp->p_flags & F_PASS) + ch = PASSAGE; + pp->p_flags |= F_SEEN; + move(y, x); + if (pp->p_monst != NULL) + pp->p_monst->t_oldch = pp->p_ch; + else if (pp->p_flags & F_REAL) + addch(ch); + else + { + standout(); + addch((pp->p_flags & F_PASS) ? PASSAGE : DOOR); + standend(); + } + } + } } #endif @@ -365,17 +365,17 @@ passnum() { struct room *rp; int i; - + pnum = 0; newpnum = FALSE; for (rp = passages; rp < &passages[MAXPASS]; rp++) - rp->r_nexits = 0; + rp->r_nexits = 0; for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) - for (i = 0; i < rp->r_nexits; i++) - { - newpnum ^= 1;//newpnum++; - numpass(rp->r_exit[i].y, rp->r_exit[i].x); - } + for (i = 0; i < rp->r_nexits; i++) + { + newpnum ^= 1;//newpnum++; + numpass(rp->r_exit[i].y, rp->r_exit[i].x); + } } /* @@ -389,30 +389,30 @@ numpass(int y, int x) char *fp; struct room *rp; char ch; - + if (x >= NUMCOLS || x < 0 || y >= NUMLINES || y <= 0) - return; + return; fp = &flat(y, x); if (*fp & F_PNUM) - return; + return; if (newpnum) { - pnum++; - newpnum = FALSE; + pnum++; + newpnum = FALSE; } /* * check to see if it is a door or secret door, i.e., a new exit, * or a numerable type of place */ if ((ch = chat(y, x)) == DOOR || - (!(*fp & F_REAL) && (ch == '|' || ch == '-'))) + (!(*fp & F_REAL) && (ch == '|' || ch == '-'))) { - rp = &passages[pnum]; - rp->r_exit[rp->r_nexits].y = y; - rp->r_exit[rp->r_nexits++].x = x; + rp = &passages[pnum]; + rp->r_exit[rp->r_nexits].y = y; + rp->r_exit[rp->r_nexits++].x = x; } else if (!(*fp & F_PASS)) - return; + return; *fp |= pnum; /* * recurse on the surrounding places diff --git a/src/cc/rogue/rings.c b/src/cc/rogue/rings.c index af6cc881b..f9ce50795 100644 --- a/src/cc/rogue/rings.c +++ b/src/cc/rogue/rings.c @@ -23,65 +23,65 @@ ring_on(struct rogue_state *rs) { THING *obj; int ring; - + obj = get_item(rs,"put on", RING); /* * Make certain that it is somethings that we want to wear */ if (obj == NULL) - return; + return; if (obj->o_type != RING) { - if (!terse) - msg(rs,"it would be difficult to wrap that around a finger"); - else - msg(rs,"not a ring"); - return; + if (!terse) + msg(rs,"it would be difficult to wrap that around a finger"); + else + msg(rs,"not a ring"); + return; } - + /* * find out which hand to put it on */ if (is_current(rs,obj)) - return; - + return; + if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) { - if ((ring = gethand(rs)) < 0) - return; + if ((ring = gethand(rs)) < 0) + return; } else if (cur_ring[LEFT] == NULL) - ring = LEFT; + ring = LEFT; else if (cur_ring[RIGHT] == NULL) - ring = RIGHT; + ring = RIGHT; else { - if (!terse) - msg(rs,"you already have a ring on each hand"); - else - msg(rs,"wearing two"); - return; + if (!terse) + msg(rs,"you already have a ring on each hand"); + else + msg(rs,"wearing two"); + return; } cur_ring[ring] = obj; - + /* * Calculate the effect it has on the poor guy. */ switch (obj->o_which) { - case R_ADDSTR: - chg_str(obj->o_arm); - break; - case R_SEEINVIS: - invis_on(); - break; - case R_AGGR: - aggravate(rs); - break; + case R_ADDSTR: + chg_str(obj->o_arm); + break; + case R_SEEINVIS: + invis_on(); + break; + case R_AGGR: + aggravate(rs); + break; } - + if (!terse) - addmsg(rs,"you are now wearing "); + addmsg(rs,"you are now wearing "); msg(rs,"%s (%c)", inv_name(obj, TRUE), obj->o_packch); } @@ -95,31 +95,31 @@ ring_off(struct rogue_state *rs) { int ring; THING *obj; - + if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) { - if (terse) - msg(rs,"no rings"); - else - msg(rs,"you aren't wearing any rings"); - return; + if (terse) + msg(rs,"no rings"); + else + msg(rs,"you aren't wearing any rings"); + return; } else if (cur_ring[LEFT] == NULL) - ring = RIGHT; + ring = RIGHT; else if (cur_ring[RIGHT] == NULL) - ring = LEFT; + ring = LEFT; else - if ((ring = gethand(rs)) < 0) - return; + if ((ring = gethand(rs)) < 0) + return; mpos = 0; obj = cur_ring[ring]; if (obj == NULL) { - msg(rs,"not wearing such a ring"); - return; + msg(rs,"not wearing such a ring"); + return; } if (dropcheck(rs,obj)) - msg(rs,"was wearing %s(%c)", inv_name(obj, TRUE), obj->o_packch); + msg(rs,"was wearing %s(%c)", inv_name(obj, TRUE), obj->o_packch); } /* @@ -163,21 +163,21 @@ ring_eat(int hand) THING *ring; int eat; static int uses[] = { - 1, /* R_PROTECT */ 1, /* R_ADDSTR */ - 1, /* R_SUSTSTR */ -3, /* R_SEARCH */ - -5, /* R_SEEINVIS */ 0, /* R_NOP */ - 0, /* R_AGGR */ -3, /* R_ADDHIT */ - -3, /* R_ADDDAM */ 2, /* R_REGEN */ - -2, /* R_DIGEST */ 0, /* R_TELEPORT */ - 1, /* R_STEALTH */ 1 /* R_SUSTARM */ + 1, /* R_PROTECT */ 1, /* R_ADDSTR */ + 1, /* R_SUSTSTR */ -3, /* R_SEARCH */ + -5, /* R_SEEINVIS */ 0, /* R_NOP */ + 0, /* R_AGGR */ -3, /* R_ADDHIT */ + -3, /* R_ADDDAM */ 2, /* R_REGEN */ + -2, /* R_DIGEST */ 0, /* R_TELEPORT */ + 1, /* R_STEALTH */ 1 /* R_SUSTARM */ }; - + if ((ring = cur_ring[hand]) == NULL) - return 0; + return 0; if ((eat = uses[ring->o_which]) < 0) - eat = (rnd(-eat) == 0); + eat = (rnd(-eat) == 0); if (ring->o_which == R_DIGEST) - eat = -eat; + eat = -eat; return eat; } @@ -189,18 +189,18 @@ char * ring_num(THING *obj) { static char buf[10]; - + if (!(obj->o_flags & ISKNOW)) - return ""; + return ""; switch (obj->o_which) { - case R_PROTECT: - case R_ADDSTR: - case R_ADDDAM: - case R_ADDHIT: - sprintf(buf, " [%s]", num(obj->o_arm, 0, RING)); - otherwise: - return ""; + case R_PROTECT: + case R_ADDSTR: + case R_ADDDAM: + case R_ADDHIT: + sprintf(buf, " [%s]", num(obj->o_arm, 0, RING)); + otherwise: + return ""; } return buf; } diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 90045f083..478e3d2ed 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -131,21 +131,21 @@ int32_t flushkeystrokes_local(struct rogue_state *rs,int32_t waitflag) rs->num = 0; retflag = 0; fclose(fp); - if ( (fp= fopen("savefile","wb")) != 0 ) + /*if ( (fp= fopen("savefile","wb")) != 0 ) { - //save_file(rs,fp,0); + save_file(rs,fp,0); if ( 0 && (fp= fopen("savefile","rb")) != 0 ) { for (i=0; i<0x150; i++) fprintf(stderr,"%02x",fgetc(fp)); fprintf(stderr," first part rnd.%d\n",rnd(1000)); fclose(fp); - } - roguefname(fname,rs->seed,rs->counter); + }*/ + roguefname(fname,rs->seed,rs->counter+1); if ( (fp= fopen(fname,"wb")) != 0 ) // truncate next file fclose(fp); //fprintf(stderr,"savefile <- %s retflag.%d\n",fname,retflag); - } + //} } else fprintf(stderr,"error writing (%s)\n",fname); } else fprintf(stderr,"error creating (%s)\n",fname); return(retflag); @@ -254,11 +254,10 @@ long get_filesize(FILE *fp) return(fsize); } -int32_t rogue_replay(uint64_t seed,int32_t sleeptime) +char *rogue_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter) { - FILE *fp; char fname[1024]; char *keystrokes = 0; long num=0,fsize; int32_t i,counter = 0; struct rogue_state *rs; struct rogue_player P,*player = 0; - if ( seed == 0 ) - seed = 777; + char fname[1024],*keystrokes = 0; FILE *fp; long fsize; int32_t num = 0; + *numkeysp = 0; while ( 1 ) { roguefname(fname,seed,counter); @@ -275,19 +274,30 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) { fprintf(stderr,"error reallocating keystrokes\n"); fclose(fp); - return(-1); + return(0); } if ( fread(&keystrokes[num],1,fsize,fp) != fsize ) { fprintf(stderr,"error reading keystrokes from (%s)\n",fname); fclose(fp); - return(-1); + free(keystrokes); + return(0); } fclose(fp); num += fsize; counter++; - fprintf(stderr,"loaded %ld from (%s) total %ld\n",fsize,fname,num); + fprintf(stderr,"loaded %ld from (%s) total %d\n",fsize,fname,num); } + *numkeysp = num; + return(keystrokes); +} + +int32_t rogue_replay(uint64_t seed,int32_t sleeptime) +{ + FILE *fp; char fname[1024]; char *keystrokes = 0; long fsize; int32_t i,num=0,counter = 0; struct rogue_state *rs; struct rogue_player P,*player = 0; + if ( seed == 0 ) + seed = 777; + keystrokes = rogue_keystrokesload(&num,seed,counter); if ( num > 0 ) { sprintf(fname,"rogue.%llu.player",(long long)seed); @@ -301,7 +311,6 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) fclose(fp); } rogue_replay2(0,seed,keystrokes,num,player,sleeptime); - mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); my_exit(0); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index eee5bc9e9..b690a583e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -978,16 +978,18 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto } if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 ) { - fprintf(stderr,"zero value character was killed -> no playerdata\n"); + sprintf(str,"zero value character was killed -> no playerdata\n"); newdata.resize(0); - //P.gold = (P.gold * 8) / 10; + *numkeysp = numkeys; + return(keystrokes); + /* P.gold = (P.gold * 8) / 10; if ( keystrokes != 0 ) { free(keystrokes); keystrokes = 0; *numkeysp = 0; return(keystrokes); - } + }*/ } else { @@ -1084,8 +1086,8 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C if ( P.amulet != 0 ) mult *= 5; dungeonlevel = P.dungeonlevel; - if ( P.amulet != 0 && dungeonlevel < 21 ) - dungeonlevel = 21; + if ( P.amulet != 0 && dungeonlevel < 26 ) + dungeonlevel = 26; *cashoutp = (uint64_t)P.gold * P.gold * mult * dungeonlevel; if ( newdata == playerdata ) { @@ -1315,7 +1317,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) rogue_gameplayerinfo(cp,obj,txid,tx,i+1,maxplayers,myrogueaddr); a.push_back(obj); } - else + else if ( 0 ) { sprintf(str,"vout %d+1 is unspent",i); result.push_back(Pair("unspent",str)); @@ -1466,7 +1468,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C funcid = script[1]; if ( (e= script[0]) == EVAL_TOKENS ) { - tokentx = 1; + tokentx = funcid; if ( (funcid= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) == 0 ) { if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 ) @@ -1539,22 +1541,29 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C // verify pk belongs to this tx if ( playerdata.size() > 0 ) { + static char laststr[512]; char cashstr[512]; if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) { - fprintf(stderr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); - } - if ( funcid == 'H' ) - cashout *= 2; - if ( tx.vout.size() > 3 ) // orig of 't' has 0 cashout - { - static char laststr[512]; char cashstr[512]; - sprintf(cashstr,"ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); + sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); if ( strcmp(laststr,cashstr) != 0 ) { strcpy(laststr,cashstr); fprintf(stderr,"%s\n",cashstr); } - if ( enabled != 0 && tx.vout[2].nValue != cashout ) + if ( enabled != 0 ) + return eval->Invalid("mismatched playerdata"); + } + if ( funcid == 'H' ) + cashout *= 2; + //if ( tokentx == 0 ) + { + sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); + if ( strcmp(laststr,cashstr) != 0 ) + { + strcpy(laststr,cashstr); + fprintf(stderr,"%s\n",cashstr); + } + if ( tokentx == 0 && enabled != 0 && tx.vout[2].nValue != cashout ) return eval->Invalid("mismatched cashout amount"); } } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b846ba9d1..70a1a7c02 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2126,7 +2126,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) else { bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); - if ( bhash > bnTarget ) + if ( bhash > bnTarget && height > 100 ) { for (i=31; i>=16; i--) fprintf(stderr,"%02x",((uint8_t *)&bhash)[i]); @@ -2135,7 +2135,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]); fprintf(stderr," ht.%d PoW diff violation PoSperc.%d vs goalperc.%d\n",height,PoSperc,(int32_t)ASSETCHAINS_STAKED); return(-1); - } else + } + else { failed = 0; CBlockIndex *pindex; diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 2c3647b30..e1b941197 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -34,6 +34,10 @@ #define GETBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] & (1 << ((bitoffset) & 7))) #define CLEARBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] &= ~(1 << ((bitoffset) & 7))) +#define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1) +#define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63)) +#define KOMODO_VALUETOOBIG(x) ((x) > (uint64_t)10000000000*COIN) + extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC; int32_t MAX_BLOCK_SIZE(int32_t height); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 13de7c310..69ad6b840 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -134,15 +134,15 @@ uint64_t komodo_current_supply(uint32_t nHeight) uint64_t cur_money; int32_t baseid; - if ( (baseid = komodo_baseid(ASSETCHAINS_SYMBOL)) >= 0 && baseid < 32 ) - cur_money = ASSETCHAINS_GENESISTXVAL + ASSETCHAINS_SUPPLY + nHeight * ASSETCHAINS_REWARD[0] / SATOSHIDEN; - else + //if ( (baseid = komodo_baseid(ASSETCHAINS_SYMBOL)) >= 0 && baseid < 32 ) + // cur_money = ASSETCHAINS_GENESISTXVAL + ASSETCHAINS_SUPPLY + nHeight * ASSETCHAINS_REWARD[0] / SATOSHIDEN; + //else { // figure out max_money by adding up supply to a maximum of 10,000,000 blocks cur_money = (ASSETCHAINS_SUPPLY+1) * SATOSHIDEN + (ASSETCHAINS_MAGIC & 0xffffff) + ASSETCHAINS_GENESISTXVAL; if ( ASSETCHAINS_LASTERA == 0 && ASSETCHAINS_REWARD[0] == 0 ) { - cur_money += (nHeight * 10000) / SATOSHIDEN; + cur_money += (nHeight * 10000);// / SATOSHIDEN; } else { @@ -155,6 +155,8 @@ uint64_t komodo_current_supply(uint32_t nHeight) // add rewards from this era, up to nHeight int64_t reward = ASSETCHAINS_REWARD[j]; + + //fprintf(stderr,"last.%d reward %llu period %llu\n",(int32_t)ASSETCHAINS_LASTERA,(long long)reward,(long long)ASSETCHAINS_HALVING[j]); if ( reward > 0 ) { uint64_t lastEnd = j == 0 ? 0 : ASSETCHAINS_ENDSUBSIDY[j - 1]; @@ -166,10 +168,12 @@ uint64_t komodo_current_supply(uint32_t nHeight) uint32_t modulo = (curEnd - lastEnd) % period; uint64_t decay = ASSETCHAINS_DECAY[j]; - if (!period) + //fprintf(stderr,"period.%llu cur_money %.8f += %.8f * %d\n",(long long)period,(double)cur_money/COIN,(double)reward/COIN,nHeight); + if ( ASSETCHAINS_HALVING[j] == 0 ) { // no halving, straight multiply cur_money += reward * (nHeight - 1); + //fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); } // if exactly SATOSHIDEN, linear decay to zero or to next era, same as: // (next_era_reward + (starting reward - next_era_reward) / 2) * num_blocks @@ -263,20 +267,18 @@ uint64_t komodo_current_supply(uint32_t nHeight) } } } - } -#define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1) -#define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63)) - + } if ( KOMODO_BIT63SET(cur_money) != 0 ) return(KOMODO_MAXNVALUE); if ( ASSETCHAINS_COMMISSION != 0 ) { - uint64_t newval = (cur_money + (cur_money * ASSETCHAINS_COMMISSION)); + uint64_t newval = (cur_money + (cur_money/COIN * ASSETCHAINS_COMMISSION)); if ( KOMODO_BIT63SET(newval) != 0 ) return(KOMODO_MAXNVALUE); else if ( newval < cur_money ) // check for underflow return(KOMODO_MAXNVALUE); return(newval); } + //fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); return(cur_money); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 65114c16b..2c4a2d040 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1639,9 +1639,18 @@ uint64_t komodo_ac_block_subsidy(int nHeight) } } } - if ( nHeight == 1 ) + uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff); + if ( ASSETCHAINS_SUPPLY > 10000000000 ) // over 10 billion? + { + if ( nHeight <= ASSETCHAINS_SUPPLY/1000000000 ) + { + subsidy += (uint64_t)1000000000 * COIN; + if ( nHeight == 1 ) + subsidy += (ASSETCHAINS_SUPPLY % 1000000000)*COIN + magicExtra; + } + } + else if ( nHeight == 1 ) { - uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff); if ( ASSETCHAINS_LASTERA == 0 ) subsidy = ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; else @@ -1792,6 +1801,8 @@ void komodo_args(char *argv0) fprintf(stderr,"-ac_supply must be less than 90 billion\n"); exit(0); } + fprintf(stderr,"ASSETCHAINS_SUPPLY %llu\n",(long long)ASSETCHAINS_SUPPLY); + ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); @@ -1885,6 +1896,11 @@ void komodo_args(char *argv0) } if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 ) { + if ( ASSETCHAINS_SUPPLY > 10000000000 ) + { + printf("ac_pubkey or ac_script wont work with ac_supply over 10 billion\n"); + exit(0); + } if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) { printf("Assetchains NOTARY PAY cannot be used with ac_pubkey or ac_script.\n"); @@ -2049,9 +2065,9 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN ) MAX_MONEY = 1000000LL*SATOSHIDEN; - if ( MAX_MONEY <= 0 || MAX_MONEY > 10000100000LL*SATOSHIDEN ) - MAX_MONEY = 10000100000LL*SATOSHIDEN; - //fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); + if ( KOMODO_BIT63SET(MAX_MONEY) != 0 ) + MAX_MONEY = KOMODO_MAXNVALUE; + fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); uint16_t tmpport = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); if ( GetArg("-port",0) != 0 ) diff --git a/src/main.cpp b/src/main.cpp index c88f1520a..8e836ffa0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1808,7 +1808,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa CAmount nValueOut = tx.GetValueOut(); CAmount nFees = nValueIn-nValueOut; double dPriority = view.GetPriority(tx, chainActive.Height()); - if ( KOMODO_BIT63SET(nValueOut) != 0 ) + if ( nValueOut > 777777*COIN && KOMODO_VALUETOOBIG(nValueOut - 777777*COIN) != 0 ) // some room for blockreward and txfees return state.DoS(100, error("AcceptToMemoryPool: GetValueOut too big"),REJECT_INVALID,"tx valueout is too big"); // Keep track of transactions that spend a coinbase, which we re-scan @@ -2845,7 +2845,7 @@ namespace { hasher << hashBlock; hasher << blockundo; fileout << hasher.GetHash(); - +//fprintf(stderr,"hashBlock.%s hasher.%s\n",hashBlock.GetHex().c_str(),hasher.GetHash().GetHex().c_str()); return true; } @@ -2870,7 +2870,7 @@ namespace { hasher << hashBlock; hasher << blockundo; if (hashChecksum != hasher.GetHash()) - return error("%s: Checksum mismatch", __func__); + return error("%s: %s Checksum mismatch %s vs %s", __func__,hashBlock.GetHex().c_str(),hashChecksum.GetHex().c_str(),hasher.GetHash().GetHex().c_str()); return true; } @@ -3494,12 +3494,18 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin txdata.emplace_back(tx); valueout = tx.GetValueOut(); - if ( KOMODO_BIT63SET(valueout) != 0 ) + if ( KOMODO_VALUETOOBIG(valueout) != 0 ) + { + fprintf(stderr,"valueout %.8f too big\n",(double)valueout/COIN); return state.DoS(100, error("ConnectBlock(): GetValueOut too big"),REJECT_INVALID,"tx valueout is too big"); + } prevsum = voutsum; voutsum += valueout; - if ( KOMODO_BIT63SET(voutsum) != 0 ) + if ( KOMODO_VALUETOOBIG(voutsum) != 0 ) + { + fprintf(stderr,"voutsum %.8f too big\n",(double)voutsum/COIN); return state.DoS(100, error("ConnectBlock(): voutsum too big"),REJECT_INVALID,"tx valueout is too big"); + } else if ( voutsum < prevsum ) return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big"); if (!tx.IsCoinBase()) @@ -3634,9 +3640,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return true; // Write undo information to disk + //fprintf(stderr,"nFile.%d isNull %d vs isvalid %d nStatus %x\n",(int32_t)pindex->nFile,pindex->GetUndoPos().IsNull(),pindex->IsValid(BLOCK_VALID_SCRIPTS),(uint32_t)pindex->nStatus); if (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS)) { - if (pindex->GetUndoPos().IsNull()) { + if (pindex->GetUndoPos().IsNull()) + { CDiskBlockPos pos; if (!FindUndoPos(state, pindex->nFile, pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40)) return error("ConnectBlock(): FindUndoPos failed"); @@ -3644,12 +3652,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin fprintf(stderr,"ConnectBlock: unexpected null pprev\n"); if (!UndoWriteToDisk(blockundo, pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart())) return AbortNode(state, "Failed to write undo data"); - // update nUndoPos in block index pindex->nUndoPos = pos.nPos; pindex->nStatus |= BLOCK_HAVE_UNDO; } - + // Now that all consensus rules have been validated, set nCachedBranchId. // Move this if BLOCK_VALID_CONSENSUS is ever altered. static_assert(BLOCK_VALID_CONSENSUS == BLOCK_VALID_SCRIPTS, @@ -3660,7 +3667,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } else if (pindex->pprev) { pindex->nCachedBranchId = pindex->pprev->nCachedBranchId; } - + pindex->RaiseValidity(BLOCK_VALID_SCRIPTS); setDirtyBlockIndex.insert(pindex); } @@ -4269,6 +4276,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->GetHeight()) + "\n\n" + _("Please help, human!"); LogPrintf("*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10); + fprintf(stderr,"*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg.c_str(),reorgLength+10); uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR); StartShutdown(); return false; diff --git a/src/miner.cpp b/src/miner.cpp index a567e2e20..2069e5a8c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -173,7 +173,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } } else pk = _pk; - uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); + uint64_t deposits,voutsum=0; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params(); bool fNotarisationBlock = false; std::vector NotarisationNotaries; //fprintf(stderr,"create new block\n"); @@ -233,7 +233,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); uint32_t proposedTime = GetAdjustedTime(); - + voutsum = GetBlockSubsidy(nHeight,consensusParams) + 10000*COIN; // approx fees + if (proposedTime == nMedianTimePast) { // too fast or stuck, this addresses the too fast issue, while moving @@ -270,7 +271,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 vecPriority.reserve(mempool.mapTx.size() + 1); // now add transactions from the mem pool - int32_t Notarisations = 0; + int32_t Notarisations = 0; uint64_t txvalue; for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); mi != mempool.mapTx.end(); ++mi) { @@ -285,7 +286,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); continue; } - + txvalue = tx.GetValueOut(); + if ( KOMODO_VALUETOOBIG(txvalue) != 0 ) + continue; + if ( KOMODO_VALUETOOBIG(txvalue + voutsum) != 0 ) + continue; + voutsum += txvalue; if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) { //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); @@ -621,7 +627,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout.resize(1); txNew.vout[0].scriptPubKey = scriptPubKeyIn; txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees; - + //fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN); txNew.nExpiryHeight = 0; txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp index ece2ec73e..d4bba72ee 100644 --- a/src/utilstrencodings.cpp +++ b/src/utilstrencodings.cpp @@ -419,10 +419,26 @@ bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out) int mantissa_tzeros = 0; bool mantissa_sign = false; bool exponent_sign = false; - int ptr = 0; + int i,n,ptr = 0; char *str = (char *)val.c_str(); int end = val.size(); int point_ofs = 0; - + n = val.size(); + if ( n == 11 && (val[0] < '9' || val[1] < '3') ) + { + uint64_t val64 = 0; + for (i=0; i '9' ) + break; + val64 = (val64 * 10) + (val[i] - '0'); + } + if ( i == n ) // 90000000000 + { + *amount_out = val64 * 100000000; + //fprintf(stderr,"special case: %s -> %.8f\n",val.c_str(),(double)*amount_out/100000000); + return(true); + } + } if (ptr < end && val[ptr] == '-') { mantissa_sign = true; ++ptr; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 510dff7be..6cf8eeed8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -421,7 +421,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr // Check amount if (nValue <= 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount"); - +//fprintf(stderr,"nValue %.8f vs curBalance %.8f\n",(double)nValue/COIN,(double)curBalance/COIN); if (nValue > curBalance) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds"); @@ -1030,7 +1030,6 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef return GetAccountBalance(walletdb, strAccount, nMinDepth, filter); } - UniValue cleanwallettransactions(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp))