From ab91876752f093be6c1345bdde46d7d72b141a1c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 11:48:56 -0300 Subject: [PATCH 001/549] test --- src/bitcoind.cpp | 9 +--- src/komodo.h | 60 +++++++--------------- src/komodo_events.h | 105 ++++++++++++++++----------------------- src/komodo_gateway.h | 86 ++++++++++++++++++++------------ src/komodo_globals.h | 9 +--- src/komodo_notary.h | 2 +- src/komodo_structs.h | 36 +++++++++++++- src/komodo_utils.h | 85 ++++++++++++++++++++++++++----- src/miner.cpp | 13 ++--- src/util.cpp | 8 +-- src/wallet/rpcwallet.cpp | 4 +- 11 files changed, 235 insertions(+), 182 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 1f7267701..5cb5a92fc 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -33,9 +33,7 @@ static bool fDaemon; extern char ASSETCHAINS_SYMBOL[16]; -void komodo_gateway_iteration(char *symbol); -void komodo_iteration(char *symbol); -int32_t komodo_is_issuer(); +void komodo_passport_iteration(); void WaitForShutdown(boost::thread_group* threadGroup) { @@ -44,10 +42,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) while (!fShutdown) { MilliSleep(10000); - if ( komodo_is_issuer() != 0 ) - komodo_gateway_iteration(ASSETCHAINS_SYMBOL); - else komodo_iteration((char *)"EUR"); - + komodo_passport_iteration(); fShutdown = ShutdownRequested(); } if (threadGroup) diff --git a/src/komodo.h b/src/komodo.h index ed05c1a46..18d8a5a0d 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -41,21 +41,16 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block); #include "komodo_globals.h" #include "komodo_utils.h" -void komodo_setkmdheight(int32_t kmdheight) -{ - if ( kmdheight > KMDHEIGHT ) - KMDHEIGHT = kmdheight; -} - #include "cJSON.c" #include "komodo_bitcoind.h" #include "komodo_interest.h" #include "komodo_pax.h" #include "komodo_notary.h" + +int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char *dest); #include "komodo_gateway.h" #include "komodo_events.h" - void komodo_currentheight_set(int32_t height) { char symbol[16],dest[16]; struct komodo_state *sp; @@ -177,25 +172,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar return; if ( fp == 0 ) { -#ifdef WIN32 - sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"komodostate"); - //sprintf(fname2,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"minerids"); -#else - sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),(char *)"komodostate"); - //sprintf(fname2,"%s/%s",GetDataDir(false).string().c_str(),(char *)"minerids"); -#endif - /*memset(Minerids,0xfe,sizeof(Minerids)); - if ( (Minerfp= fopen(fname2,"rb+")) == 0 ) - { - if ( (Minerfp= fopen(fname2,"wb")) != 0 ) - { - fwrite(Minerids,1,sizeof(Minerids),Minerfp); - fclose(Minerfp); - } - Minerfp = fopen(fname2,"rb+"); - } - if ( Minerfp != 0 && fread(Minerids,1,sizeof(Minerids),Minerfp) != sizeof(Minerids) ) - printf("read error Minerids\n");*/ + komodo_statefname(fname,ASSETCHAINS_SYMBOL); if ( (fp= fopen(fname,"rb+")) != 0 ) { while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) @@ -212,7 +189,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar if ( fp != 0 ) // write out funcid, height, other fields, call side effect function { //printf("fpos.%ld ",ftell(fp)); - if ( KMDheight > 0 ) + if ( KMDheight != 0 ) { fputc('K',fp); if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) ) @@ -368,6 +345,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_HASH = kmdtxid; sp->NOTARIZED_DESTTXID = desttxid; komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0); + // extract X opreturns here } else printf("reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]); } else if ( i == 0 && j == 1 && opretlen == 149 ) @@ -407,7 +385,7 @@ int32_t komodo_isratify(int32_t isspecial,int32_t numvalid) // if all outputs to notary -> notary utxo // if txi == 0 && 2 outputs and 2nd OP_RETURN, len == 32*2+4 -> notarized, 1st byte 'P' -> pricefeed // OP_RETURN: 'D' -> deposit, 'W' -> withdraw -void komodo_currentheight_set(int32_t height); + int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid,int32_t n); int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys[64][33],int32_t numnotaries,uint8_t rmd160[20]) @@ -428,9 +406,12 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { static int32_t hwmheight; uint64_t signedmask,voutmask; char symbol[16],dest[16]; struct komodo_state *sp; - uint8_t scriptbuf[4096],pubkeys[64][33],rmd160[20],scriptPubKey[35]; uint256 kmdtxid,btctxid,txhash; + uint8_t scriptbuf[4096],pubkeys[64][33],rmd160[20],scriptPubKey[35]; uint256 kmdtxid,zero,btctxid,txhash; int32_t i,j,k,numnotaries,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; + memset(zero.bytes,0,sizeof(zero)); komodo_init(pindex->nHeight); + if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) + return; numnotaries = komodo_notaries(pubkeys,pindex->nHeight); calc_rmd160_sha256(rmd160,pubkeys[0],33); if ( pindex->nHeight > hwmheight ) @@ -438,20 +419,19 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) else { printf("hwmheight.%d vs pindex->nHeight.%d reorg.%d\n",hwmheight,pindex->nHeight,hwmheight-pindex->nHeight); - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - komodo_event_rewind(sp,symbol,pindex->nHeight); - // komodo_stateupdate(); + komodo_event_rewind(sp,symbol,pindex->nHeight); + komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,0,0,0,0); } komodo_currentheight_set(chainActive.Tip()->nHeight); - if ( komodo_is_issuer() != 0 ) + /*if ( komodo_is_issuer() != 0 ) { while ( KOMODO_REALTIME == 0 || time(NULL) <= KOMODO_REALTIME ) { fprintf(stderr,"komodo_connect.(%s) waiting for realtime RT.%u now.%u\n",ASSETCHAINS_SYMBOL,KOMODO_REALTIME,(uint32_t)time(NULL)); sleep(30); } - } - KOMODO_REALTIME = KOMODO_INITDONE = (uint32_t)time(NULL); + }*/ + sp->KOMODO_REALTIME = KOMODO_INITDONE = (uint32_t)time(NULL); if ( pindex != 0 ) { height = pindex->nHeight; @@ -481,10 +461,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } } - if ( i != 0 && notaryid >= 0 && notaryid < 64 && voutmask != 0 ) - { - //komodo_stateupdate(height,0,0,notaryid,txhash,voutmask,numvouts,0,0,0,0,0,0,0); - } signedmask = 0; numvins = block.vtx[i].vin.size(); for (j=0; j= 0 ) signedmask |= (1LL << k); } - /*if ( (k= komodo_nutxofind(height,block.vtx[i].vin[j].prevout.hash,block.vtx[i].vin[j].prevout.n)) >= 0 ) - signedmask |= (1LL << k); - else if ( signedmask != 0 ) - printf("signedmask.%llx but ht.%d i.%d j.%d not found (%s %d)\n",(long long)signedmask,height,i,j,block.vtx[i].vin[j].prevout.hash.ToString().c_str(),block.vtx[i].vin[j].prevout.n);*/ } if ( signedmask != 0 ) printf("ht.%d signedmask.%llx numvins.%d numvouts.%d\n",height,(long long)signedmask,numvins,numvouts); @@ -537,6 +509,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } } + if ( pindex->nHeight == hwmheight && (hwmheight % 100) == 0 ) + komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,0,0,0,0); } else printf("komodo_connectblock: unexpected null pindex\n"); KOMODO_INITDONE = (uint32_t)time(NULL); } diff --git a/src/komodo_events.h b/src/komodo_events.h index 017fcb145..e006803c1 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -16,45 +16,7 @@ #ifndef H_KOMODOEVENTS_H #define H_KOMODOEVENTS_H - -#ifdef WIN32 -#define PACKED -#else -#define PACKED __attribute__((packed)) -#endif - -#define KOMODO_EVENT_RATIFY 'P' -#define KOMODO_EVENT_NOTARIZED 'N' -#define KOMODO_EVENT_UTXO 'U' -#define KOMODO_EVENT_KMDHEIGHT 'K' -#define KOMODO_EVENT_REWIND 'B' -//#define KOMODO_EVENT_DELETE 'D' -#define KOMODO_EVENT_PRICEFEED 'V' -#define KOMODO_EVENT_OPRETURN 'R' -#define KOMODO_OPRETURN_DEPOSIT 'D' -#define KOMODO_OPRETURN_ISSUED 'I' // assetchain -#define KOMODO_OPRETURN_WITHDRAW 'W' // assetchain -#define KOMODO_OPRETURN_REDEEMED 'X' - -struct komodo_event_notarized { uint256 blockhash,desttxid; int32_t notarizedheight; char dest[16]; }; -struct komodo_event_pubkeys { uint8_t num; uint8_t pubkeys[64][33]; }; -struct komodo_event_utxo { uint256 txid; uint64_t voutmask; uint8_t numvouts; }; -struct komodo_event_opreturn { uint256 txid; uint64_t value; uint16_t vout,oplen; uint8_t opret[]; }; -struct komodo_event_pricefeed { uint8_t num; uint32_t prices[35]; }; - -struct komodo_event -{ - struct komodo_event *related; - uint16_t len; - int32_t height; - uint8_t type,reorged; - char symbol[16]; - uint8_t space[]; -} PACKED; - -struct komodo_event **Komodo_events; int32_t Komodo_numevents; - -struct komodo_event *komodo_eventadd(int32_t height,char *symbol,uint8_t type,uint8_t *data,uint16_t datalen) +struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char *symbol,uint8_t type,uint8_t *data,uint16_t datalen) { struct komodo_event *ep; uint16_t len = (uint16_t)(sizeof(*ep) + datalen); ep = (struct komodo_event *)calloc(1,len); @@ -64,8 +26,8 @@ struct komodo_event *komodo_eventadd(int32_t height,char *symbol,uint8_t type,ui strcpy(ep->symbol,symbol); if ( datalen != 0 ) memcpy(ep->space,data,datalen); - Komodo_events = (struct komodo_event **)realloc(Komodo_events,(1 + Komodo_numevents) * sizeof(*Komodo_events)); - Komodo_events[Komodo_numevents++] = ep; + sp->Komodo_events = (struct komodo_event **)realloc(sp->Komodo_events,(1 + sp->Komodo_numevents) * sizeof(*Komodo_events)); + sp->Komodo_events[sp->Komodo_numevents++] = ep; return(ep); } @@ -77,7 +39,7 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig N.desttxid = notarized_desttxid; N.notarizedheight = notarizedheight; strcpy(N.dest,dest); - komodo_eventadd(height,symbol,KOMODO_EVENT_NOTARIZED,(uint8_t *)&N,sizeof(N)); + komodo_eventadd(sp,height,symbol,KOMODO_EVENT_NOTARIZED,(uint8_t *)&N,sizeof(N)); if ( sp != 0 ) komodo_notarized_update(sp,height,notarizedheight,notarized_hash,notarized_desttxid); } @@ -89,7 +51,7 @@ void komodo_eventadd_pubkeys(struct komodo_state *sp,char *symbol,int32_t height memset(&P,0,sizeof(P)); P.num = num; memcpy(P.pubkeys,pubkeys,33 * num); - komodo_eventadd(height,symbol,KOMODO_EVENT_RATIFY,(uint8_t *)&P,(int32_t)(sizeof(P.num) + 33 * num)); + komodo_eventadd(sp,height,symbol,KOMODO_EVENT_RATIFY,(uint8_t *)&P,(int32_t)(sizeof(P.num) + 33 * num)); if ( sp != 0 ) komodo_notarysinit(height,pubkeys,num); } @@ -112,18 +74,11 @@ void komodo_eventadd_pricefeed(struct komodo_state *sp,char *symbol,int32_t heig memset(&F,0,sizeof(F)); F.num = num; memcpy(F.prices,prices,sizeof(*F.prices) * num); - komodo_eventadd(height,symbol,KOMODO_EVENT_PRICEFEED,(uint8_t *)&F,(int32_t)(sizeof(F.num) + sizeof(*F.prices) * num)); + komodo_eventadd(sp,height,symbol,KOMODO_EVENT_PRICEFEED,(uint8_t *)&F,(int32_t)(sizeof(F.num) + sizeof(*F.prices) * num)); if ( sp != 0 ) komodo_pvals(height,prices,num); } -void komodo_eventadd_kmdheight(struct komodo_state *sp,char *symbol,int32_t height,int32_t kmdheight) -{ - komodo_eventadd(height,symbol,KOMODO_EVENT_KMDHEIGHT,(uint8_t *)&kmdheight,sizeof(kmdheight)); - if ( sp != 0 ) - komodo_setkmdheight(kmdheight); -} - void komodo_eventadd_opreturn(struct komodo_state *sp,char *symbol,int32_t height,uint256 txid,uint64_t value,uint16_t vout,uint8_t *buf,uint16_t opretlen) { struct komodo_event_opreturn O; uint8_t opret[10000]; @@ -134,21 +89,26 @@ void komodo_eventadd_opreturn(struct komodo_state *sp,char *symbol,int32_t heigh memcpy(opret,&O,sizeof(O)); memcpy(&opret[sizeof(O)],buf,opretlen); O.oplen = (int32_t)(opretlen + sizeof(O)); - komodo_eventadd(height,symbol,KOMODO_EVENT_OPRETURN,opret,O.oplen); + komodo_eventadd(sp,height,symbol,KOMODO_EVENT_OPRETURN,opret,O.oplen); if ( sp != 0 ) komodo_opreturn(height,value,buf,opretlen,txid,vout); } -void komodo_event_undo(struct komodo_event *ep) +void komodo_event_undo(struct komodo_state *sp,struct komodo_event *ep) { switch ( ep->type ) { - case KOMODO_EVENT_RATIFY: - case KOMODO_EVENT_NOTARIZED: - case KOMODO_EVENT_UTXO: + case KOMODO_EVENT_RATIFY: printf("rewind of ratify, needs to be coded.%d\n",ep->height); break; + case KOMODO_EVENT_NOTARIZED: printf("unexpected rewind of notarization.%d\n",ep->height); break; case KOMODO_EVENT_KMDHEIGHT: + if ( ep->height <= sp->SAVEDHEIGHT ) + sp->SAVEDHEIGHT = ep->height; + break; case KOMODO_EVENT_PRICEFEED: + // backtrack prices; + break; case KOMODO_EVENT_OPRETURN: + // backtrack opreturns break; } } @@ -156,23 +116,46 @@ void komodo_event_undo(struct komodo_event *ep) void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height) { struct komodo_event *ep; - komodo_eventadd(height,symbol,KOMODO_EVENT_REWIND,(uint8_t *)&height,sizeof(height)); if ( sp != 0 ) { - while ( Komodo_numevents > 0 ) + while ( sp->Komodo_events != 0 && sp->Komodo_numevents > 0 ) { - if ( (ep= Komodo_events[Komodo_numevents-1]) != 0 ) + if ( (ep= sp->Komodo_events[sp->Komodo_numevents-1]) != 0 ) { if ( ep->height < height ) break; printf("undo event.%c ht.%d for rewind.%d\n",ep->type,ep->height,height); - komodo_event_undo(ep); - Komodo_numevents--; + komodo_event_undo(sp,ep); + sp->Komodo_numevents--; } } } } +void komodo_setkmdheight(struct komodo_state *sp,int32_t kmdheight) +{ + if ( kmdheight > sp->SAVEDHEIGHT ) + sp->SAVEDHEIGHT = kmdheight; +} + +void komodo_eventadd_kmdheight(struct komodo_state *sp,char *symbol,int32_t height,int32_t kmdheight) +{ + if ( kmdheight > 0 ) + { + komodo_eventadd(sp,height,symbol,KOMODO_EVENT_KMDHEIGHT,(uint8_t *)&kmdheight,sizeof(kmdheight)); + if ( sp != 0 ) + komodo_setkmdheight(sp,kmdheight); + } + else + { + kmdheight = -kmdheight; + komodo_eventadd(so,height,symbol,KOMODO_EVENT_REWIND,(uint8_t *)&height,sizeof(height)); + if ( sp != 0 ) + komodo_event_rewind(sp,symbol,height); + } +} + + /*void komodo_eventadd_deposit(int32_t actionflag,char *symbol,int32_t height,uint64_t komodoshis,char *fiat,uint64_t fiatoshis,uint8_t rmd160[20],bits256 kmdtxid,uint16_t kmdvout,uint64_t price) { uint8_t opret[512]; uint16_t opretlen; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d72c4b1c0..01702f303 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -110,12 +110,9 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char } } -int32_t komodo_issued_opreturn(uint8_t *shortflagp,char *base,uint256 *txids,uint16_t *vouts,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) +int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) { int32_t i,n=0,j,len; - if ( opretbuf[opretlen-5] == '-' ) - *shortflagp = 1; - else *shortflagp = 0; for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) // shortflag @@ -143,7 +140,7 @@ int32_t komodo_issued_opreturn(uint8_t *shortflagp,char *base,uint256 *txids,uin for (i=0; opretbuf[len+i]!=0&&i<3; i++) symbol[i] = opretbuf[len+i]; symbol[i] = 0; - printf(">>>>>>> iskomodo X: (%s) fiat %.8f kmdheight.%d other.%d short.%d\n",symbol,dstr(fiatoshis),height,otherheight,shortflag); + printf(">>>>>>> iskomodo X: (%s) fiat %.8f kmdheight.%d other.%d\n",symbol,dstr(fiatoshis),height,otherheight); } } } @@ -223,7 +220,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,cha int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { - int32_t i,j,n,num,opretlen,offset=1,errs=0,matched=0; uint256 hash,txids[64]; uint8_t shortflag; char symbol[16],base[16]; uint16_t vouts[64]; uint8_t *script,opcode; struct pax_transaction *pax,space; + int32_t i,j,n,num,opretlen,offset=1,errs=0,matched=0; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; uint8_t *script,opcode; struct pax_transaction *pax,space; n = block.vtx[0].vout.size(); script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data(); if ( n <= 2 || script[0] != 0x6a ) @@ -244,7 +241,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } if ( script[offset] == opcode && opretlen < block.vtx[0].vout[n-1].scriptPubKey.size() ) { - if ( (num= komodo_issued_opreturn(&shortflag,base,txids,vouts,&script[offset],opretlen,opcode == 'X')) > 0 ) + if ( (num= komodo_issued_opreturn(base,txids,vouts,&script[offset],opretlen,opcode == 'X')) > 0 ) { for (i=1; i= checktoshis || (seed == 0 && diff < .01) ) { - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&txid)[i]); - printf(" <- txid.v%u ",vout); - for (i=0; i<33; i++) - printf("%02x",pubkey33[i]); - printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); - if ( value >= checktoshis || (seed == 0 && diff < .01) ) + if ( komodo_paxfind(&space,txid,vout) == 0 ) { - if ( komodo_paxfind(&space,txid,vout) == 0 ) - { - komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,kmdheight,height); - } else printf("duplicate deposit\n"); - } - } - else // short - { - for (i=0; i 0 && shortflag == ASSETCHAINS_SHORTFLAG ) + if ( (n= komodo_issued_opreturn(&shortflag,base,txids,vouts,opretbuf,opretlen,0)) > 0 ) { for (i=0; i= kmdheight ) - KOMODO_REALTIME = (uint32_t)time(NULL); + sp->KOMODO_REALTIME = (uint32_t)time(NULL); } free_json(infoobj); } @@ -570,3 +555,38 @@ void komodo_iteration(char *symbol) } } } +#else + +void komodo_gateway_iteration() +{ + static long lastpos[33]; + FILE *fp; int32_t baseid,refid; struct komodo_state *sp; char fname[512],*base,dest[16]; + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + refid = 32; + else refid = komodo_baseid(ASSETCHAINS_SYMBOL); + if ( refid >= 0 ) + { + for (baseid=0; baseid<=32; baseid++) + { + if ( baseid != refid ) // use direct data for yourself + { + komodo_statefname(fname,""); + komodo_nameset(symbol,dest,source); + if ( (fp= fopen(fname,"rb")) != 0 ) + { + fseek(fp,lastpos,SEEK_SET); + if ( ftell(fp) > lastpos[baseid] ) + { + while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) + ; + lastpos[baseid] = ftell(fp); + printf("%s lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); + } + fclose(fp); + } + } + } + } +} +#endif + diff --git a/src/komodo_globals.h b/src/komodo_globals.h index f5eba4929..db4b55be4 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -20,19 +20,15 @@ char *komodo_issuemethod(char *method,char *params,uint16_t port); void komodo_init(int32_t height); void komodo_assetchain_pubkeys(char *jsonstr); int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33); +int32_t komodo_isrealtime(int32_t *kmdheightp,char *target); pthread_mutex_t komodo_mutex; -//FILE *Minerfp; -//int8_t Minerids[KOMODO_MAXBLOCKS]; // 5 million blocks #define KOMODO_ELECTION_GAP ((ASSETCHAINS_SYMBOL[0] == 0) ? 2000 : 100) -int32_t KMDHEIGHT = 43000; - struct pax_transaction *PAX; int32_t NUM_PRICES; uint32_t *PVALS; struct knotaries_entry *Pubkeys; -//struct nutxo_entry *NUTXOS; int32_t Num_nutxos; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS; struct komodo_state KOMODO_STATES[33]; @@ -43,13 +39,12 @@ int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED, std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES; uint8_t NOTARY_PUBKEY33[33]; -int32_t ASSETCHAINS_SHORTFLAG; char ASSETCHAINS_SYMBOL[16]; uint16_t ASSETCHAINS_PORT; uint32_t ASSETCHAIN_INIT; uint32_t ASSETCHAINS_MAGIC = 2387029918; uint64_t ASSETCHAINS_SUPPLY = 10; -uint32_t KOMODO_INITDONE,KOMODO_REALTIME; +uint32_t KOMODO_INITDONE; char KMDUSERPASS[1024]; uint16_t BITCOIND_PORT = 7771; uint64_t PENDING_KOMODO_TX; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 954c029a5..64ffb21fd 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -208,7 +208,7 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; } -struct komodo_state *komodo_stateptr(char *symbol,char *dest); +//struct komodo_state *komodo_stateptr(char *symbol,char *dest); int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp) { char symbol[16],dest[16]; struct komodo_state *sp; diff --git a/src/komodo_structs.h b/src/komodo_structs.h index dd653fc37..a5e17e8ae 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -16,10 +16,42 @@ #include "uthash.h" #include "utlist.h" +#ifdef WIN32 +#define PACKED +#else +#define PACKED __attribute__((packed)) +#endif + #define GENESIS_NBITS 0x1f00ffff #define KOMODO_MINRATIFY 7 #define KOMODO_MAXBLOCKS 5000000 +#define KOMODO_EVENT_RATIFY 'P' +#define KOMODO_EVENT_NOTARIZED 'N' +#define KOMODO_EVENT_KMDHEIGHT 'K' +#define KOMODO_EVENT_REWIND 'B' +#define KOMODO_EVENT_PRICEFEED 'V' +#define KOMODO_EVENT_OPRETURN 'R' +#define KOMODO_OPRETURN_DEPOSIT 'D' +#define KOMODO_OPRETURN_ISSUED 'I' // assetchain +#define KOMODO_OPRETURN_WITHDRAW 'W' // assetchain +#define KOMODO_OPRETURN_REDEEMED 'X' + +struct komodo_event_notarized { uint256 blockhash,desttxid; int32_t notarizedheight; char dest[16]; }; +struct komodo_event_pubkeys { uint8_t num; uint8_t pubkeys[64][33]; }; +struct komodo_event_opreturn { uint256 txid; uint64_t value; uint16_t vout,oplen; uint8_t opret[]; }; +struct komodo_event_pricefeed { uint8_t num; uint32_t prices[35]; }; + +struct komodo_event +{ + struct komodo_event *related; + uint16_t len; + int32_t height; + uint8_t type,reorged; + char symbol[16]; + uint8_t space[]; +} PACKED; + struct pax_transaction { UT_hash_handle hh; @@ -38,6 +70,6 @@ struct notarized_checkpoint { uint256 notarized_hash,notarized_desttxid; int32_t struct komodo_state { uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID; - int32_t CURRENT_HEIGHT,NOTARIZED_HEIGHT,rewinding; - // gateway state + int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,rewinding; + struct komodo_event **Komodo_events; int32_t Komodo_numevents; }; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 78d38141d..dc753a3e6 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1261,6 +1261,36 @@ void komodo_userpass(char *username,char *password,FILE *fp) free(rpcpassword); } +void komodo_statefname(char *fname,char *symbol) +{ + int32_t n,len; + sprintf(fname,"%s",GetDataDir(false).string().c_str()); + if ( (n= (int32_t)strlen(ASSETCHAINS_SYMBOL)) != 0 ) + { + len = (int32_t)strlen(fname); + if ( strcmp(ASSETCHAINS_SYMBOL,&fname[len - n]) == 0 ) + { + fname[len - n] = 0; + if ( symbol[0] != 0 ) + { + strcpy(&fname[len - n],symbol); +#ifdef WIN32 + strcat(fname,"\\"); +#else + strcat(fname,"//"); +#endif + } + } + else + { + printf("unexpected fname.(%s) vs %s\n",fname,ASSETCHAINS_SYMBOL); + return; + } + } + strcat(fname,(char *)"komodostate"); + printf("statename.(%s) %s\n",symbol,fname); +} + void komodo_configfile(char *symbol,uint16_t port) { static char myusername[512],mypassword[8192]; @@ -1327,7 +1357,7 @@ uint32_t komodo_assetmagic(char *symbol,uint64_t supply) return(calc_crc32(0,buf,len)); } -int32_t komodo_shortflag(char *symbol) +/*int32_t komodo_shortflag(char *symbol) { int32_t i,shortflag = 0; if ( symbol[0] == '-' ) @@ -1338,17 +1368,16 @@ int32_t komodo_shortflag(char *symbol) symbol[i] = 0; } return(shortflag); -} +}*/ uint16_t komodo_assetport(uint32_t magic,int32_t shortflag) { return(8000 + shortflag*7777 + (magic % 7777)); } -uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,int32_t *shortflagp) +uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp) { *magicp = komodo_assetmagic(symbol,supply); - *shortflagp = komodo_shortflag(symbol); return(komodo_assetport(*magicp,*shortflagp)); } @@ -1381,8 +1410,7 @@ void komodo_args() if ( strlen(addn.c_str()) > 0 ) ASSETCHAINS_SEED = 1; strncpy(ASSETCHAINS_SYMBOL,name.c_str(),sizeof(ASSETCHAINS_SYMBOL)-1); - ASSETCHAINS_PORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,&ASSETCHAINS_SHORTFLAG); - //fprintf(stderr,"after args: %c%s port.%u magic.%08x supply.%u\n",ASSETCHAINS_SHORTFLAG!=0?'-':'+',ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT,ASSETCHAINS_MAGIC,(int32_t)ASSETCHAINS_SUPPLY); + ASSETCHAINS_PORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC); while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) { fprintf(stderr,"waiting for datadir\n"); @@ -1395,7 +1423,7 @@ void komodo_args() extern int COINBASE_MATURITY; komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1); //if ( komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 ) - COINBASE_MATURITY = 1; + COINBASE_MATURITY = 1; } ASSETCHAINS_NOTARIES = GetArg("-ac_notaries",""); komodo_assetchain_pubkeys((char *)ASSETCHAINS_NOTARIES.c_str()); @@ -1419,21 +1447,30 @@ void komodo_args() //fprintf(stderr,"%s chain params initialized\n",ASSETCHAINS_SYMBOL); } -struct komodo_state *komodo_stateptr(char *symbol,char *dest) +void komodo_nameset(char *symbol,char *dest,char *source) { - int32_t baseid; struct komodo_state *sp; - if ( ASSETCHAINS_SYMBOL[0] == 0 ) + if ( source[0] == 0 ) { strcpy(symbol,"KMD"); strcpy(dest,"BTC"); - sp = &KOMODO_STATES[0]; } else { - strcpy(symbol,ASSETCHAINS_SYMBOL); + strcpy(symbol,source); strcpy(dest,"KMD"); + } +} + +struct komodo_state *komodo_stateptr(char *symbol,char *dest) +{ + int32_t baseid; struct komodo_state *sp; + komodo_nameset(symbol,dest,ASSETCHAINS_SYMBOL); + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + sp = &KOMODO_STATES[0]; + else + { if ( (baseid= komodo_baseid(ASSETCHAINS_SYMBOL)) >= 0 ) - sp = &KOMODO_STATES[baseid]; + sp = &KOMODO_STATES[baseid+1]; else { fprintf(stderr,"komodo_stateupdate.(%s) not supported\n",ASSETCHAINS_SYMBOL); @@ -1442,3 +1479,25 @@ struct komodo_state *komodo_stateptr(char *symbol,char *dest) } return(sp); } + +struct komodo_state *komodo_stateptrget(char *base) +{ + int32_t baseid; + if ( base == 0 || base[0] == 0 || strcmp(base,"KMD") == 0 ) + return(KOMODO_STATES[0]); + else if ( (baseid= komodo_baseid(base)) >= 0 ) + return(&KOMODO_STATES[baseid+1]); + else return(0); +} + +int32_t komodo_isrealtime(int32_t *kmdheightp,char *target) +{ + char symbol[16],dest[16]; struct komodo_state *sp; + *kmdheightp = 0; + if ( (sp= komodo_stateptrget(target)) != 0 ) + { + *kmdheightp = sp->CURRENT_HEIGHT; + return(sp->KOMODO_REALTIME); + } + return(0); +} diff --git a/src/miner.cpp b/src/miner.cpp index 90fd460f6..42b2b87c9 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -100,7 +100,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #define ASSETCHAINS_MINHEIGHT 100 #define ROUNDROBIN_DELAY 45 -extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,ASSETCHAINS_SHORTFLAG,KOMODO_REALTIME; +extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33]; @@ -114,7 +114,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,cha CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { - uint64_t deposits; const CChainParams& chainparams = Params(); + uint64_t deposits; int32_t isrealtime,kmdheight; const CChainParams& chainparams = Params(); // Create new block unique_ptr pblocktemplate(new CBlockTemplate()); if(!pblocktemplate.get()) @@ -122,13 +122,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) CBlock *pblock = &pblocktemplate->block; // pointer for convenience if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= 100 ) { - fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),KOMODO_REALTIME,KOMODO_ON_DEMAND); - while ( KOMODO_ON_DEMAND == 0 )//mempool.GetTotalTxSize() <= 0 ) + isrealtime = komodo_isrealtime(&kmdheight,ASSETCHAINS_SYMBOL); + fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),isrealtime,KOMODO_ON_DEMAND); + while ( KOMODO_ON_DEMAND == 0 ) { deposits = komodo_paxtotal(); - if ( KOMODO_INITDONE == 0 || KOMODO_REALTIME == 0 ) + if ( KOMODO_INITDONE == 0 || komodo_isrealtime(&kmdheight,ASSETCHAINS_SYMBOL) == 0 ) { - //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f\n",KOMODO_INITDONE,KOMODO_REALTIME,(double)deposits/COIN); + //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN); } else if ( deposits != 0 ) break; diff --git a/src/util.cpp b/src/util.cpp index a586a7516..4dfe13919 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -401,18 +401,14 @@ void PrintExceptionContinue(const std::exception* pex, const char* pszThread) } extern char ASSETCHAINS_SYMBOL[16]; -extern int32_t ASSETCHAINS_SHORTFLAG; boost::filesystem::path GetDefaultDataDir() { namespace fs = boost::filesystem; char symbol[16]; if ( ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( ASSETCHAINS_SHORTFLAG != 0 ) - sprintf(symbol,"-%s",ASSETCHAINS_SYMBOL); - else strcpy(symbol,ASSETCHAINS_SYMBOL); - } else symbol[0] = 0; + strcpy(symbol,ASSETCHAINS_SYMBOL); + else symbol[0] = 0; // Windows < Vista: C:\Documents and Settings\Username\Application Data\Zcash // Windows >= Vista: C:\Users\Username\AppData\Roaming\Zcash // Mac: ~/Library/Application Support/Zcash diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1f2cb706b..8b1eab8a3 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -521,7 +521,6 @@ Value paxdeposit(const Array& params, bool fHelp) Value paxwithdraw(const Array& params, bool fHelp) { - extern int32_t KMDHEIGHT,KOMODO_REALTIME; CWalletTx wtx; std::string dest; int32_t kmdheight; uint64_t seed,komodoshis = 0; char destaddr[64]; uint8_t i,pubkey37[37]; bool fSubtractFeeFromAmount = false; if ( ASSETCHAINS_SYMBOL[0] == 0 ) return(0); @@ -529,14 +528,13 @@ Value paxwithdraw(const Array& params, bool fHelp) return 0; if (fHelp || params.size() != 2) throw runtime_error("paxwithdraw \"address\" fiatamount"); - if ( KOMODO_REALTIME == 0 ) + if ( komodo_isrealtime(&kmdheight,"KMD") == 0 ) return(0); LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN; - kmdheight = KMDHEIGHT; komodoshis = PAX_fiatdest(&seed,1,destaddr,pubkey37,(char *)params[0].get_str().c_str(),kmdheight,ASSETCHAINS_SYMBOL,fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO777_KMDADDR); From 35fc5e6674a94602bb0d5f14fb45f7ffca75d3ff Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 11:51:19 -0300 Subject: [PATCH 002/549] test --- src/bitcoind.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 5cb5a92fc..8f0037c0d 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -59,6 +59,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,ASSETCHAIN_INIT; extern std::string NOTARY_PUBKEY; int32_t komodo_is_issuer(); +void komodo_passport_iteration(); bool AppInit(int argc, char* argv[]) { @@ -101,8 +102,8 @@ bool AppInit(int argc, char* argv[]) fprintf(stderr,"call komodo_args NOTARY_PUBKEY.(%s)\n",NOTARY_PUBKEY.c_str()); while ( ASSETCHAIN_INIT == 0 ) { - if ( komodo_is_issuer() != 0 ) - komodo_gateway_iteration(ASSETCHAINS_SYMBOL); + //if ( komodo_is_issuer() != 0 ) + komodo_passport_iteration(); sleep(1); } if (!boost::filesystem::is_directory(GetDataDir(false))) From e7a90cf93c645ca01b4806cb00cddc10c8d4e724 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 11:53:53 -0300 Subject: [PATCH 003/549] test --- src/komodo_structs.h | 3 ++- src/komodo_utils.h | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/komodo_structs.h b/src/komodo_structs.h index a5e17e8ae..eefcf09c2 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -70,6 +70,7 @@ struct notarized_checkpoint { uint256 notarized_hash,notarized_desttxid; int32_t struct komodo_state { uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID; - int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT,rewinding; + int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT; + uint32_t KOMODO_REALTIME; struct komodo_event **Komodo_events; int32_t Komodo_numevents; }; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index dc753a3e6..d4ee31f3b 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1370,9 +1370,9 @@ uint32_t komodo_assetmagic(char *symbol,uint64_t supply) return(shortflag); }*/ -uint16_t komodo_assetport(uint32_t magic,int32_t shortflag) +uint16_t komodo_assetport(uint32_t magic) { - return(8000 + shortflag*7777 + (magic % 7777)); + return(8000 + (magic % 7777)); } uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp) @@ -1383,10 +1383,10 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp) void komodo_ports(uint16_t ports[MAX_CURRENCIES]) { - int32_t i,shortflag; uint32_t magic; + int32_t i; uint32_t magic; for (i=0; i= 0 ) return(&KOMODO_STATES[baseid+1]); else return(0); From 76984d2ec5c4d071000cfc206c7ae2b689ad2fd1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 11:56:33 -0300 Subject: [PATCH 004/549] test --- src/komodo_gateway.h | 6 +++--- src/komodo_utils.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 01702f303..cc1a5e3e6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -295,7 +295,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout) { - uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight; char base[4],coinaddr[64],destaddr[64]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; double diff; uint64_t seed; int64_t fiatoshis,checktoshis; const char *typestr = "unknown"; + uint8_t rmd160[20],addrtype,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight; char base[4],coinaddr[64],destaddr[64]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; double diff; uint64_t seed; int64_t fiatoshis,checktoshis; const char *typestr = "unknown"; tokomodo = (komodo_is_issuer() == 0); if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) { @@ -344,7 +344,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( tokomodo == 0 && opretbuf[0] == 'I' ) // assetchain coinbase { - if ( (n= komodo_issued_opreturn(&shortflag,base,txids,vouts,opretbuf,opretlen,0)) > 0 ) + if ( (n= komodo_issued_opreturn(base,txids,vouts,opretbuf,opretlen,0)) > 0 ) { for (i=0; i Date: Sat, 19 Nov 2016 11:58:24 -0300 Subject: [PATCH 005/549] test --- src/komodo_gateway.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index cc1a5e3e6..0dcfb7dd5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -295,7 +295,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout) { - uint8_t rmd160[20],addrtype,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight; char base[4],coinaddr[64],destaddr[64]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; double diff; uint64_t seed; int64_t fiatoshis,checktoshis; const char *typestr = "unknown"; + uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight; char base[4],coinaddr[64],destaddr[64]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; double diff; uint64_t seed; int64_t fiatoshis,checktoshis; const char *typestr = "unknown"; tokomodo = (komodo_is_issuer() == 0); if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) { @@ -568,10 +568,11 @@ void komodo_gateway_iteration() { for (baseid=0; baseid<=32; baseid++) { + base = (char *)CURRENCIES[baseid]; if ( baseid != refid ) // use direct data for yourself { - komodo_statefname(fname,""); - komodo_nameset(symbol,dest,source); + komodo_statefname(fname,(char *)""); + komodo_nameset(symbol,dest,base); if ( (fp= fopen(fname,"rb")) != 0 ) { fseek(fp,lastpos,SEEK_SET); From 2b983c8068eed67ddcb1c456cdb24e9bdece1cf1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 12:00:09 -0300 Subject: [PATCH 006/549] test --- src/komodo_events.h | 4 ++-- src/komodo_gateway.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index e006803c1..774083f71 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -26,7 +26,7 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char strcpy(ep->symbol,symbol); if ( datalen != 0 ) memcpy(ep->space,data,datalen); - sp->Komodo_events = (struct komodo_event **)realloc(sp->Komodo_events,(1 + sp->Komodo_numevents) * sizeof(*Komodo_events)); + sp->Komodo_events = (struct komodo_event **)realloc(sp->Komodo_events,(1 + sp->Komodo_numevents) * sizeof(*sp->Komodo_events)); sp->Komodo_events[sp->Komodo_numevents++] = ep; return(ep); } @@ -149,7 +149,7 @@ void komodo_eventadd_kmdheight(struct komodo_state *sp,char *symbol,int32_t heig else { kmdheight = -kmdheight; - komodo_eventadd(so,height,symbol,KOMODO_EVENT_REWIND,(uint8_t *)&height,sizeof(height)); + komodo_eventadd(sp,height,symbol,KOMODO_EVENT_REWIND,(uint8_t *)&height,sizeof(height)); if ( sp != 0 ) komodo_event_rewind(sp,symbol,height); } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0dcfb7dd5..c83f87a3a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -575,7 +575,7 @@ void komodo_gateway_iteration() komodo_nameset(symbol,dest,base); if ( (fp= fopen(fname,"rb")) != 0 ) { - fseek(fp,lastpos,SEEK_SET); + fseek(fp,lastpos[baseid],SEEK_SET); if ( ftell(fp) > lastpos[baseid] ) { while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) From 878d396188329dc1bb5fe81a3e0ec79fada2a190 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 12:01:11 -0300 Subject: [PATCH 007/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 18d8a5a0d..ad253e032 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -408,7 +408,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) uint64_t signedmask,voutmask; char symbol[16],dest[16]; struct komodo_state *sp; uint8_t scriptbuf[4096],pubkeys[64][33],rmd160[20],scriptPubKey[35]; uint256 kmdtxid,zero,btctxid,txhash; int32_t i,j,k,numnotaries,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; - memset(zero.bytes,0,sizeof(zero)); + memset(&zero,0,sizeof(zero)); komodo_init(pindex->nHeight); if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) return; From ae204823639599370e3ad7de787672f9c6c1557a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 12:03:01 -0300 Subject: [PATCH 008/549] test --- src/miner.cpp | 1 + src/wallet/rpcwallet.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index 42b2b87c9..04c31633d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -111,6 +111,7 @@ int32_t komodo_pax_opreturn(uint8_t *opret,int32_t maxsize); uint64_t komodo_paxtotal(); int32_t komodo_is_issuer(); int32_t komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *symbol,int32_t tokomodo); +int32_t komodo_isrealtime(int32_t *kmdheightp,char *target); CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8b1eab8a3..6b203af30 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -481,6 +481,7 @@ int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_ extern char ASSETCHAINS_SYMBOL[16]; int32_t komodo_is_issuer(); int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); +int32_t komodo_isrealtime(int32_t *kmdheightp,char *target); Value paxdeposit(const Array& params, bool fHelp) { From 6c4ad6931754d7a8514ebd4e1bf507e1caf31fb1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 12:04:34 -0300 Subject: [PATCH 009/549] test --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6b203af30..c0ae4f319 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -529,7 +529,7 @@ Value paxwithdraw(const Array& params, bool fHelp) return 0; if (fHelp || params.size() != 2) throw runtime_error("paxwithdraw \"address\" fiatamount"); - if ( komodo_isrealtime(&kmdheight,"KMD") == 0 ) + if ( komodo_isrealtime(&kmdheight,(char *)"KMD") == 0 ) return(0); LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(params[0].get_str()); From 30d79208cc45d97844620b289487c134717ab655 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 12:06:03 -0300 Subject: [PATCH 010/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c83f87a3a..6fbf479b9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -557,7 +557,7 @@ void komodo_iteration(char *symbol) } #else -void komodo_gateway_iteration() +void komodo_passport_iteration() { static long lastpos[33]; FILE *fp; int32_t baseid,refid; struct komodo_state *sp; char fname[512],*base,symbol[16],dest[16]; From 68503edfd9f51c222ac82574f1d5197581e43135 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 12:12:43 -0300 Subject: [PATCH 011/549] test --- src/komodo_utils.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 325fdc9d8..3327d3999 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1272,14 +1272,7 @@ void komodo_statefname(char *fname,char *symbol) { fname[len - n] = 0; if ( symbol[0] != 0 ) - { strcpy(&fname[len - n],symbol); -#ifdef WIN32 - strcat(fname,"\\"); -#else - strcat(fname,"//"); -#endif - } } else { From 214fa084f035b89e37a2e8a04aa9aa5066258e5a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 12:17:06 -0300 Subject: [PATCH 012/549] test --- src/bitcoind.cpp | 2 +- src/komodo_utils.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 8f0037c0d..2e753c812 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -103,7 +103,7 @@ bool AppInit(int argc, char* argv[]) while ( ASSETCHAIN_INIT == 0 ) { //if ( komodo_is_issuer() != 0 ) - komodo_passport_iteration(); + // komodo_passport_iteration(); sleep(1); } if (!boost::filesystem::is_directory(GetDataDir(false))) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 3327d3999..325fdc9d8 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1272,7 +1272,14 @@ void komodo_statefname(char *fname,char *symbol) { fname[len - n] = 0; if ( symbol[0] != 0 ) + { strcpy(&fname[len - n],symbol); +#ifdef WIN32 + strcat(fname,"\\"); +#else + strcat(fname,"//"); +#endif + } } else { From de2a9ca648473778cec74a8cef906927a458e855 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 12:21:33 -0300 Subject: [PATCH 013/549] test --- src/komodo_utils.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 325fdc9d8..2ae912776 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1274,6 +1274,7 @@ void komodo_statefname(char *fname,char *symbol) if ( symbol[0] != 0 ) { strcpy(&fname[len - n],symbol); + printf("statefname.(%s)\n",fname); #ifdef WIN32 strcat(fname,"\\"); #else From faa6ce59ba99b99b6b01607eab3a79d9d8f1abdc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 12:25:25 -0300 Subject: [PATCH 014/549] test --- src/komodo_utils.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2ae912776..cc22feb84 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1274,11 +1274,11 @@ void komodo_statefname(char *fname,char *symbol) if ( symbol[0] != 0 ) { strcpy(&fname[len - n],symbol); - printf("statefname.(%s)\n",fname); + //printf("statefname.(%s)\n",fname); #ifdef WIN32 strcat(fname,"\\"); #else - strcat(fname,"//"); + strcat(fname,"/"); #endif } } @@ -1289,7 +1289,7 @@ void komodo_statefname(char *fname,char *symbol) } } strcat(fname,(char *)"komodostate"); - printf("statename.(%s) %s\n",symbol,fname); + //printf("statename.(%s) %s\n",symbol,fname); } void komodo_configfile(char *symbol,uint16_t port) From 1ebb14e7407874dfaa15ad1a071879c6050e3baa Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 12:45:28 -0300 Subject: [PATCH 015/549] test --- src/komodo.h | 18 +++++++++--------- src/komodo_events.h | 12 ------------ src/komodo_notary.h | 35 ++--------------------------------- 3 files changed, 11 insertions(+), 54 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index ad253e032..990438a9b 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -87,7 +87,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char else { printf("updated %d pubkeys at ht.%d\n",num,ht); - if ( matched != 0 ) + if ( matched != 0 ) // private state -> global Pubkeys komodo_eventadd_pubkeys(sp,symbol,ht,num,pubkeys); } } else printf("illegal num.%d\n",num); @@ -100,11 +100,11 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char errs++; if ( fread(¬arized_desttxid,1,sizeof(notarized_desttxid),fp) != sizeof(notarized_desttxid) ) errs++; - printf("load NOTARIZED %d %s\n",notarized_height,notarized_hash.ToString().c_str()); - if ( matched != 0 ) - komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); + printf("load %s NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,notarized_height,notarized_hash.ToString().c_str()); + //if ( matched != 0 ) global independent states -> inside *sp + komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); } - else if ( func == 'U' ) + else if ( func == 'U' ) // deprecated { uint8_t n,nid; uint256 hash; uint64_t mask; n = fgetc(fp); @@ -122,7 +122,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char int32_t kheight; if ( fread(&kheight,1,sizeof(kheight),fp) != sizeof(kheight) ) errs++; - if ( matched != 0 ) + //if ( matched != 0 ) global independent states -> inside *sp komodo_eventadd_kmdheight(sp,symbol,ht,kheight); } else if ( func == 'R' ) @@ -140,7 +140,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char { if ( fread(opret,1,olen,fp) != olen ) errs++; - if ( matched != 0 ) + //if ( matched != 0 ) global shared state -> global PAX komodo_eventadd_opreturn(sp,symbol,ht,txid,ovalue,v,opret,olen); } else printf("illegal olen.%u\n",olen); } @@ -154,7 +154,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char numpvals = fgetc(fp); if ( numpvals*sizeof(uint32_t) <= sizeof(pvals) && fread(pvals,sizeof(uint32_t),numpvals,fp) == numpvals ) { - if ( matched != 0 ) + //if ( matched != 0 ) global shared state -> global PVALS komodo_eventadd_pricefeed(sp,symbol,ht,pvals,numpvals); //printf("load pvals ht.%d numpvals.%d\n",ht,numpvals); } else printf("error loading pvals[%d]\n",numpvals); @@ -340,7 +340,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); if ( *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { - printf("ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s)\n",height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len]); + printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len]); sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = kmdtxid; sp->NOTARIZED_DESTTXID = desttxid; diff --git a/src/komodo_events.h b/src/komodo_events.h index 774083f71..296824b6e 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -56,18 +56,6 @@ void komodo_eventadd_pubkeys(struct komodo_state *sp,char *symbol,int32_t height komodo_notarysinit(height,pubkeys,num); } -/*void komodo_eventadd_utxo(struct komodo_state *sp,char *symbol,int32_t height,uint8_t notaryid,uint256 txid,uint64_t voutmask,uint8_t numvouts) -{ - struct komodo_event_utxo U; - memset(&U,0,sizeof(U)); - U.txid = txid; - U.voutmask = voutmask; - U.numvouts = numvouts; - komodo_eventadd(height,symbol,KOMODO_EVENT_UTXO,(uint8_t *)&U,sizeof(U)); - if ( sp != 0 ) - komodo_nutxoadd(height,notaryid,txid,voutmask,numvouts); -}*/ - void komodo_eventadd_pricefeed(struct komodo_state *sp,char *symbol,int32_t height,uint32_t *prices,uint8_t num) { struct komodo_event_pricefeed F; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 64ffb21fd..b58819f30 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -52,46 +52,15 @@ const char *Notaries_genesis[][2] = { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, }; -/*void komodo_nutxoadd(int32_t height,int32_t notaryid,uint256 txhash,uint64_t voutmask,int32_t numvouts) -{ - struct nutxo_entry *np; - if ( numvouts > 1 && notaryid < 64 ) - { - pthread_mutex_lock(&komodo_mutex); - np = (struct nutxo_entry *)calloc(1,sizeof(*np)); - np->height = height; - np->txhash = txhash; - np->voutmask = voutmask; - np->notaryid = notaryid; - HASH_ADD_KEYPTR(hh,NUTXOS,&np->txhash,sizeof(np->txhash),np); - //printf("Add NUTXO[%d] <- %s notaryid.%d t%u %s %llx\n",Num_nutxos,Notaries[notaryid][0],notaryid,komodo_txtime(txhash),txhash.ToString().c_str(),(long long)voutmask); - Num_nutxos++; - pthread_mutex_unlock(&komodo_mutex); - } -} - -int32_t komodo_nutxofind(int32_t height,uint256 txhash,int32_t vout) -{ - struct nutxo_entry *np; - pthread_mutex_lock(&komodo_mutex); - HASH_FIND(hh,NUTXOS,&txhash,sizeof(txhash),np); - pthread_mutex_unlock(&komodo_mutex); - if ( np != 0 && ((1LL << vout) & np->voutmask) != 0 ) - return(np->notaryid); - return(-1); -}*/ - int32_t komodo_ratify_threshold(int32_t height,uint64_t signedmask) { int32_t htind,numnotaries,i,wt = 0; - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - return(2); htind = height / KOMODO_ELECTION_GAP; - numnotaries = Pubkeys[htind].numnotaries; + numnotaries = sp->Pubkeys[htind].numnotaries; for (i=0; i (numnotaries >> 1) || (wt > 7 && (signedmask & 3) != 0) ) + if ( wt > (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) ) return(1); else return(0); } From 0b4c2bd1d372de253011f18cea8aabef440f9603 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 12:47:11 -0300 Subject: [PATCH 016/549] test --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index b58819f30..b362aa017 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -56,7 +56,7 @@ int32_t komodo_ratify_threshold(int32_t height,uint64_t signedmask) { int32_t htind,numnotaries,i,wt = 0; htind = height / KOMODO_ELECTION_GAP; - numnotaries = sp->Pubkeys[htind].numnotaries; + numnotaries = Pubkeys[htind].numnotaries; for (i=0; i Date: Sat, 19 Nov 2016 12:56:34 -0300 Subject: [PATCH 017/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6fbf479b9..cdf398631 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -584,7 +584,7 @@ void komodo_passport_iteration() printf("%s lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); } fclose(fp); - } + } else printf("fname.(%s) cant open\n",fname); } } } From aa6b61528d5647cfb6d15c48fa0983cff71df991 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 12:59:46 -0300 Subject: [PATCH 018/549] test --- src/bitcoind.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 2e753c812..590d91463 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -106,6 +106,7 @@ bool AppInit(int argc, char* argv[]) // komodo_passport_iteration(); sleep(1); } + printf("initialized %s\n",ASSETCHAINS_SYMBOL); if (!boost::filesystem::is_directory(GetDataDir(false))) { fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str()); @@ -140,7 +141,6 @@ bool AppInit(int argc, char* argv[]) fDaemon = GetBoolArg("-daemon", false); if (fDaemon) { - extern char ASSETCHAINS_SYMBOL[16]; fprintf(stdout, "Komodo %s server starting\n",ASSETCHAINS_SYMBOL); // Daemonize From 61b59007d757925a966ce1042ccb33970459722b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 13:07:32 -0300 Subject: [PATCH 019/549] test --- src/komodo_gateway.h | 3 ++- src/komodo_globals.h | 2 +- src/komodo_notary.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index cdf398631..b5b0e3dbd 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -561,6 +561,7 @@ void komodo_passport_iteration() { static long lastpos[33]; FILE *fp; int32_t baseid,refid; struct komodo_state *sp; char fname[512],*base,symbol[16],dest[16]; + printf("PASSPORT\n"); if ( ASSETCHAINS_SYMBOL[0] == 0 ) refid = 32; else refid = komodo_baseid(ASSETCHAINS_SYMBOL); @@ -587,7 +588,7 @@ void komodo_passport_iteration() } else printf("fname.(%s) cant open\n",fname); } } - } + } else printf("passport disabled for refid.%d (%s)\n",refid,ASSETCHAINS_SYMBOL); } #endif diff --git a/src/komodo_globals.h b/src/komodo_globals.h index db4b55be4..b63b59c07 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -35,7 +35,7 @@ struct komodo_state KOMODO_STATES[33]; int COINBASE_MATURITY = 100; -int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND; +int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES; uint8_t NOTARY_PUBKEY33[33]; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index b362aa017..f8ae0fe39 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -268,6 +268,7 @@ void komodo_assetchain_pubkeys(char *jsonstr) { komodo_init(-1); komodo_notarysinit(0,pubkeys,n); + KOMODO_EXTERNAL_NOTARIES = 1; //printf("initialize pubkeys[%d]\n",n); } else fprintf(stderr,"komodo_assetchain_pubkeys i.%d vs n.%d\n",i,n); } else fprintf(stderr,"assetchain pubkeys n.%d\n",n); From e3e2dcdb823206d81dd8303c7044a5a07754604c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 13:11:05 -0300 Subject: [PATCH 020/549] test --- src/komodo_gateway.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b5b0e3dbd..3282220ee 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -561,17 +561,18 @@ void komodo_passport_iteration() { static long lastpos[33]; FILE *fp; int32_t baseid,refid; struct komodo_state *sp; char fname[512],*base,symbol[16],dest[16]; - printf("PASSPORT\n"); if ( ASSETCHAINS_SYMBOL[0] == 0 ) refid = 32; else refid = komodo_baseid(ASSETCHAINS_SYMBOL); + printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); if ( refid >= 0 ) { for (baseid=0; baseid<=32; baseid++) { - base = (char *)CURRENCIES[baseid]; if ( baseid != refid ) // use direct data for yourself { + base = (char *)CURRENCIES[baseid]; + fprintf(stderr,"%s ",base); komodo_statefname(fname,(char *)""); komodo_nameset(symbol,dest,base); if ( (fp= fopen(fname,"rb")) != 0 ) From f25dc96a15747d83cba2f7206f223773c55c381a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 13:13:14 -0300 Subject: [PATCH 021/549] test --- src/komodo_gateway.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3282220ee..1a5675345 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -572,14 +572,13 @@ void komodo_passport_iteration() if ( baseid != refid ) // use direct data for yourself { base = (char *)CURRENCIES[baseid]; - fprintf(stderr,"%s ",base); komodo_statefname(fname,(char *)""); komodo_nameset(symbol,dest,base); if ( (fp= fopen(fname,"rb")) != 0 ) { - fseek(fp,lastpos[baseid],SEEK_SET); if ( ftell(fp) > lastpos[baseid] ) { + fseek(fp,lastpos[baseid],SEEK_SET); while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) ; lastpos[baseid] = ftell(fp); From 5fd9310d6ae5f7315c41bad7114b9795d8d00fe9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 13:15:25 -0300 Subject: [PATCH 022/549] test --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1a5675345..571c15e62 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -576,6 +576,7 @@ void komodo_passport_iteration() komodo_nameset(symbol,dest,base); if ( (fp= fopen(fname,"rb")) != 0 ) { + fseek(fp,0,SEEK_END); if ( ftell(fp) > lastpos[baseid] ) { fseek(fp,lastpos[baseid],SEEK_SET); @@ -583,7 +584,7 @@ void komodo_passport_iteration() ; lastpos[baseid] = ftell(fp); printf("%s lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); - } + } else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); } else printf("fname.(%s) cant open\n",fname); } From a5e3ab13bee622c97559face903e808bfdb46f14 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 13:25:36 -0300 Subject: [PATCH 023/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 571c15e62..573e708d2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -572,9 +572,9 @@ void komodo_passport_iteration() if ( baseid != refid ) // use direct data for yourself { base = (char *)CURRENCIES[baseid]; - komodo_statefname(fname,(char *)""); + komodo_statefname(fname,baseid<32?base:""); komodo_nameset(symbol,dest,base); - if ( (fp= fopen(fname,"rb")) != 0 ) + if ( (fp= fopen(fname,"rb")) != 0 && (sp= komodo_stateptrget(symbol)) != 0 ) { fseek(fp,0,SEEK_END); if ( ftell(fp) > lastpos[baseid] ) From 1bcfe35d6925081adc1d8400ac86a35aebb0dbe1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 13:26:22 -0300 Subject: [PATCH 024/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 573e708d2..f8bd0aa55 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -572,7 +572,7 @@ void komodo_passport_iteration() if ( baseid != refid ) // use direct data for yourself { base = (char *)CURRENCIES[baseid]; - komodo_statefname(fname,baseid<32?base:""); + komodo_statefname(fname,baseid<32?base:(char *)""); komodo_nameset(symbol,dest,base); if ( (fp= fopen(fname,"rb")) != 0 && (sp= komodo_stateptrget(symbol)) != 0 ) { From 15724d022157ad65736e1dc1e72b7ae66736eafe Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 13:34:10 -0300 Subject: [PATCH 025/549] test --- src/komodo.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 990438a9b..7dd14d1ed 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -86,8 +86,8 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char errs++; else { - printf("updated %d pubkeys at ht.%d\n",num,ht); - if ( matched != 0 ) // private state -> global Pubkeys + printf("updated %d pubkeys at %s ht.%d\n",num,symbol,ht); + if ( (KOMODO_EXTERNAL_NOTARIES != 0 && matched != 0) || (strcmp(symbol,"KMD") == 0 && KOMODO_EXTERNAL_NOTARIES == 0) ) komodo_eventadd_pubkeys(sp,symbol,ht,num,pubkeys); } } else printf("illegal num.%d\n",num); @@ -100,7 +100,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char errs++; if ( fread(¬arized_desttxid,1,sizeof(notarized_desttxid),fp) != sizeof(notarized_desttxid) ) errs++; - printf("load %s NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,notarized_height,notarized_hash.ToString().c_str()); + printf("%s load[%s] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,symbol,notarized_height,notarized_hash.ToString().c_str()); //if ( matched != 0 ) global independent states -> inside *sp komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); } @@ -123,7 +123,8 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( fread(&kheight,1,sizeof(kheight),fp) != sizeof(kheight) ) errs++; //if ( matched != 0 ) global independent states -> inside *sp - komodo_eventadd_kmdheight(sp,symbol,ht,kheight); + printf("%s load[%s] ht.%d\n",ASSETCHAINS_SYMBOL,symbol,kheight); + komodo_eventadd_kmdheight(sp,symbol,ht,kheight); } else if ( func == 'R' ) { @@ -141,7 +142,8 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( fread(opret,1,olen,fp) != olen ) errs++; //if ( matched != 0 ) global shared state -> global PAX - komodo_eventadd_opreturn(sp,symbol,ht,txid,ovalue,v,opret,olen); + printf("%s load[%s] opret[%c] %.8f\n",ASSETCHAINS_SYMBOL,symbol,opret[0],(double)ovalue/COIN); + komodo_eventadd_opreturn(sp,symbol,ht,txid,ovalue,v,opret,olen); } else printf("illegal olen.%u\n",olen); } else if ( func == 'D' ) @@ -155,7 +157,8 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( numpvals*sizeof(uint32_t) <= sizeof(pvals) && fread(pvals,sizeof(uint32_t),numpvals,fp) == numpvals ) { //if ( matched != 0 ) global shared state -> global PVALS - komodo_eventadd_pricefeed(sp,symbol,ht,pvals,numpvals); + printf("%s load[%s] prices %d\n",ASSETCHAINS_SYMBOL,symbol,ht); + komodo_eventadd_pricefeed(sp,symbol,ht,pvals,numpvals); //printf("load pvals ht.%d numpvals.%d\n",ht,numpvals); } else printf("error loading pvals[%d]\n",numpvals); } From e155dbe9c3c67c67fe260d4a27f9878b0ce75824 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 13:47:18 -0300 Subject: [PATCH 026/549] test --- src/bitcoin-cli.cpp | 2 +- src/komodo.h | 52 ++++++++++++++++++++++++++++++++------------ src/komodo_events.h | 14 ++++++++---- src/komodo_gateway.h | 4 ++-- src/komodo_globals.h | 2 +- src/komodo_notary.h | 2 +- src/komodo_pax.h | 2 +- src/komodo_structs.h | 2 +- 8 files changed, 55 insertions(+), 25 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 53204a8c4..a03dca4ad 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -66,7 +66,7 @@ public: #include "cJSON.c" #include "komodo_notary.h" -void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout) +void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout) { } diff --git a/src/komodo.h b/src/komodo.h index 7dd14d1ed..ffae64609 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -124,7 +124,18 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char errs++; //if ( matched != 0 ) global independent states -> inside *sp printf("%s load[%s] ht.%d\n",ASSETCHAINS_SYMBOL,symbol,kheight); - komodo_eventadd_kmdheight(sp,symbol,ht,kheight); + komodo_eventadd_kmdheight(sp,symbol,ht,kheight,0); + } + else if ( func == 'T' ) + { + int32_t kheight,ktimestamp; + if ( fread(&kheight,1,sizeof(kheight),fp) != sizeof(kheight) ) + errs++; + if ( fread(&ktimestamp,1,sizeof(ktimestamp),fp) != sizeof(ktimestamp) ) + errs++; + //if ( matched != 0 ) global independent states -> inside *sp + printf("%s load[%s] ht.%d t.%u\n",ASSETCHAINS_SYMBOL,symbol,kheight,ktimestamp); + komodo_eventadd_kmdheight(sp,symbol,ht,kheight,ktimestamp); } else if ( func == 'R' ) { @@ -167,7 +178,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char } else return(-1); } -void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout) +void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout) { static FILE *fp; static int32_t errs; struct komodo_state *sp; char fname[512],symbol[16],dest[16]; int32_t ht,func; uint8_t num,pubkeys[64][33]; @@ -194,12 +205,25 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar //printf("fpos.%ld ",ftell(fp)); if ( KMDheight != 0 ) { - fputc('K',fp); - if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) ) - errs++; - if ( fwrite(&KMDheight,1,sizeof(KMDheight),fp) != sizeof(KMDheight) ) - errs++; - komodo_eventadd_kmdheight(sp,symbol,height,KMDheight); + if ( KMDtimestamp != 0 ) + { + fputc('T',fp); + if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) ) + errs++; + if ( fwrite(&KMDheight,1,sizeof(KMDheight),fp) != sizeof(KMDheight) ) + errs++; + if ( fwrite(&KMDtimestamp,1,sizeof(KMDtimestamp),fp) != sizeof(KMDtimestamp) ) + errs++; + } + else + { + fputc('K',fp); + if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) ) + errs++; + if ( fwrite(&KMDheight,1,sizeof(KMDheight),fp) != sizeof(KMDheight) ) + errs++; + } + komodo_eventadd_kmdheight(sp,symbol,height,KMDheight,KMDtimestamp); } else if ( opretbuf != 0 && opretlen > 0 ) { @@ -347,7 +371,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = kmdtxid; sp->NOTARIZED_DESTTXID = desttxid; - komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0); + komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0); // extract X opreturns here } else printf("reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]); } @@ -370,7 +394,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } } if ( *isratificationp == 0 ) - komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,value,&scriptbuf[len],opretlen,j); + komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j); } } return(notaryid); @@ -423,7 +447,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { printf("hwmheight.%d vs pindex->nHeight.%d reorg.%d\n",hwmheight,pindex->nHeight,hwmheight-pindex->nHeight); komodo_event_rewind(sp,symbol,pindex->nHeight); - komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,0,0,0,0); + komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0); } komodo_currentheight_set(chainActive.Tip()->nHeight); /*if ( komodo_is_issuer() != 0 ) @@ -506,14 +530,14 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( ((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1) ) { memset(&txhash,0,sizeof(txhash)); - komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0); + komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0); printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height); } else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries); } } } - if ( pindex->nHeight == hwmheight && (hwmheight % 100) == 0 ) - komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,0,0,0,0); + if ( pindex->nHeight == hwmheight ) + komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,pindex->nHeight,0,0,0,0); } else printf("komodo_connectblock: unexpected null pindex\n"); KOMODO_INITDONE = (uint32_t)time(NULL); } diff --git a/src/komodo_events.h b/src/komodo_events.h index 296824b6e..0e5439210 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -120,19 +120,25 @@ void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height) } } -void komodo_setkmdheight(struct komodo_state *sp,int32_t kmdheight) +void komodo_setkmdheight(struct komodo_state *sp,int32_t kmdheight,uint32_t timestamp) { if ( kmdheight > sp->SAVEDHEIGHT ) + { sp->SAVEDHEIGHT = kmdheight; + sp->SAVEDTIMESTAMP = timestamp; + } } -void komodo_eventadd_kmdheight(struct komodo_state *sp,char *symbol,int32_t height,int32_t kmdheight) +void komodo_eventadd_kmdheight(struct komodo_state *sp,char *symbol,int32_t height,int32_t kmdheight,uint32_t timestamp) { + uint32_t buf[2]; if ( kmdheight > 0 ) { - komodo_eventadd(sp,height,symbol,KOMODO_EVENT_KMDHEIGHT,(uint8_t *)&kmdheight,sizeof(kmdheight)); + buf[0] = (uint32_t)kmdheight; + buf[1] = timestamp; + komodo_eventadd(sp,height,symbol,KOMODO_EVENT_KMDHEIGHT,(uint8_t *)buf,sizeof(buf)); if ( sp != 0 ) - komodo_setkmdheight(sp,kmdheight); + komodo_setkmdheight(sp,kmdheight,timestamp); } else { diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f8bd0aa55..ca5b80362 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -386,7 +386,7 @@ void komodo_gateway_voutupdate(char *symbol,int32_t isspecial,int32_t height,int komodo_paxpricefeed(height,&script[offset],opretlen); //printf("height.%d pricefeed len.%d\n",height,opretlen); } - else komodo_stateupdate(height,0,0,0,utxid,0,0,0,0,0,value,&script[offset],opretlen,vout); + else komodo_stateupdate(height,0,0,0,utxid,0,0,0,0,0,0,value,&script[offset],opretlen,vout); } else if ( numvouts >= KOMODO_MINRATIFY ) typestr = "ratify"; @@ -494,7 +494,7 @@ void komodo_gateway_iteration(char *symbol) if ( (KMDHEIGHT % 100) == 0 ) fprintf(stderr,"%s.%d ",symbol,KMDHEIGHT); memset(&zero,0,sizeof(zero)); - komodo_stateupdate(KMDHEIGHT,0,0,0,zero,0,0,0,0,KMDHEIGHT,0,0,0,0); + komodo_stateupdate(KMDHEIGHT,0,0,0,zero,0,0,0,0,KMDHEIGHT,0,0,0,0,0); } if ( komodo_gateway_block(symbol,KMDHEIGHT,port) < 0 ) { diff --git a/src/komodo_globals.h b/src/komodo_globals.h index b63b59c07..b69802edc 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -13,7 +13,7 @@ * * ******************************************************************************/ -void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout); +void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint32_t ktime,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout); void komodo_init(int32_t height); int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp); char *komodo_issuemethod(char *method,char *params,uint16_t port); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index f8ae0fe39..055ecac9b 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -240,7 +240,7 @@ void komodo_init(int32_t height) // Minerids[i] = -2; didinit = 1; } - komodo_stateupdate(0,0,0,0,zero,0,0,0,0,0,0,0,0,0); + komodo_stateupdate(0,0,0,0,zero,0,0,0,0,0,0,0,0,0,0); } void komodo_assetchain_pubkeys(char *jsonstr) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index d63ffa0f6..f582a9721 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -454,7 +454,7 @@ void komodo_paxpricefeed(int32_t height,uint8_t *pricefeed,int32_t opretlen) double KMDBTC,BTCUSD,CNYUSD; uint32_t numpvals,timestamp,pvals[128]; uint256 zero; numpvals = dpow_readprices(pricefeed,×tamp,&KMDBTC,&BTCUSD,&CNYUSD,pvals); memset(&zero,0,sizeof(zero)); - komodo_stateupdate(height,0,0,0,zero,0,0,pvals,numpvals,0,0,0,0,0); + komodo_stateupdate(height,0,0,0,zero,0,0,pvals,numpvals,0,0,0,0,0,0); //printf("komodo_paxpricefeed vout OP_RETURN.%d prices numpvals.%d opretlen.%d\n",height,numpvals,opretlen); } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index eefcf09c2..eed4103bd 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -71,6 +71,6 @@ struct komodo_state { uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID; int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT; - uint32_t KOMODO_REALTIME; + uint32_t KOMODO_REALTIME,SAVEDTIMESTAMP; struct komodo_event **Komodo_events; int32_t Komodo_numevents; }; From 3085016b489ae623d2c867adba785a77e2a607a9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 13:47:53 -0300 Subject: [PATCH 027/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ca5b80362..a447f444f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -564,7 +564,7 @@ void komodo_passport_iteration() if ( ASSETCHAINS_SYMBOL[0] == 0 ) refid = 32; else refid = komodo_baseid(ASSETCHAINS_SYMBOL); - printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); + //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); if ( refid >= 0 ) { for (baseid=0; baseid<=32; baseid++) @@ -584,7 +584,7 @@ void komodo_passport_iteration() ; lastpos[baseid] = ftell(fp); printf("%s lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); - } else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); + } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); } else printf("fname.(%s) cant open\n",fname); } From 335f2ea7407556d50ffdcb9675b412b73941d9f2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 13:53:21 -0300 Subject: [PATCH 028/549] test --- src/komodo.h | 2 +- src/komodo_globals.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index ffae64609..34bf91c7a 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -168,7 +168,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( numpvals*sizeof(uint32_t) <= sizeof(pvals) && fread(pvals,sizeof(uint32_t),numpvals,fp) == numpvals ) { //if ( matched != 0 ) global shared state -> global PVALS - printf("%s load[%s] prices %d\n",ASSETCHAINS_SYMBOL,symbol,ht); + //printf("%s load[%s] prices %d\n",ASSETCHAINS_SYMBOL,symbol,ht); komodo_eventadd_pricefeed(sp,symbol,ht,pvals,numpvals); //printf("load pvals ht.%d numpvals.%d\n",ht,numpvals); } else printf("error loading pvals[%d]\n",numpvals); diff --git a/src/komodo_globals.h b/src/komodo_globals.h index b69802edc..a4b718ec9 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -24,7 +24,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp,char *target); pthread_mutex_t komodo_mutex; -#define KOMODO_ELECTION_GAP ((ASSETCHAINS_SYMBOL[0] == 0) ? 2000 : 100) +#define KOMODO_ELECTION_GAP 2000 //((ASSETCHAINS_SYMBOL[0] == 0) ? 2000 : 100) struct pax_transaction *PAX; int32_t NUM_PRICES; uint32_t *PVALS; From ce169ae346f179a1f8a1cd8be311b3d21b9daf4e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 14:03:02 -0300 Subject: [PATCH 029/549] test --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 34bf91c7a..cfb6c5c0d 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -499,10 +499,10 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } if ( signedmask != 0 ) - printf("ht.%d signedmask.%llx numvins.%d numvouts.%d\n",height,(long long)signedmask,numvins,numvouts); + printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); if ( signedmask != 0 && (notarizedheight != 0 || specialtx != 0) ) { - printf("NOTARY SIGNED.%llx numvins.%d ht.%d txi.%d notaryht.%d specialtx.%d\n",(long long)signedmask,numvins,height,i,notarizedheight,specialtx); + printf("%s NOTARY SIGNED.%llx numvins.%d ht.%d txi.%d notaryht.%d specialtx.%d\n",ASSETCHAINS_SYMBOL,(long long)signedmask,numvins,height,i,notarizedheight,specialtx); printf("ht.%d specialtx.%d isratification.%d numvouts.%d signed.%llx numnotaries.%d\n",height,specialtx,isratification,numvouts,(long long)signedmask,numnotaries); if ( specialtx != 0 && isratification != 0 && numvouts > 2 ) { From 9a3fc044a86ee880d3007a23add61339c4c1cb7f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 14:03:56 -0300 Subject: [PATCH 030/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index cfb6c5c0d..4f82082fd 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -381,7 +381,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr { int32_t k; for (k=0; k= 32*2+4 && strcmp(ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,(char *)&scriptbuf[len+32*2+4]) == 0 ) { for (k=0; k<32; k++) From 8afdc8e7b10d9264c2c08f94308dd5dcc7698f67 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 14:08:12 -0300 Subject: [PATCH 031/549] test --- src/komodo.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 4f82082fd..de05c938c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -153,7 +153,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( fread(opret,1,olen,fp) != olen ) errs++; //if ( matched != 0 ) global shared state -> global PAX - printf("%s load[%s] opret[%c] %.8f\n",ASSETCHAINS_SYMBOL,symbol,opret[0],(double)ovalue/COIN); + printf("%s load[%s] opret[%c] len.%d %.8f\n",ASSETCHAINS_SYMBOL,symbol,opret[0],olen,(double)ovalue/COIN); komodo_eventadd_opreturn(sp,symbol,ht,txid,ovalue,v,opret,olen); } else printf("illegal olen.%u\n",olen); } @@ -445,7 +445,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) hwmheight = pindex->nHeight; else { - printf("hwmheight.%d vs pindex->nHeight.%d reorg.%d\n",hwmheight,pindex->nHeight,hwmheight-pindex->nHeight); + printf("hwmheight.%d vs pindex->nHeight.%d t.%u reorg.%d\n",hwmheight,pindex->nHeight,(uint32_t)pindex->nTime,hwmheight-pindex->nHeight); komodo_event_rewind(sp,symbol,pindex->nHeight); komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0); } @@ -537,7 +537,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } if ( pindex->nHeight == hwmheight ) - komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,pindex->nHeight,0,0,0,0); + komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0); } else printf("komodo_connectblock: unexpected null pindex\n"); KOMODO_INITDONE = (uint32_t)time(NULL); } From 9f33e1766b4abb2b0762e65ca67ffeeb7fd01ab3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 14:19:56 -0300 Subject: [PATCH 032/549] test --- src/komodo.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index de05c938c..fa6794a39 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -153,7 +153,9 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( fread(opret,1,olen,fp) != olen ) errs++; //if ( matched != 0 ) global shared state -> global PAX - printf("%s load[%s] opret[%c] len.%d %.8f\n",ASSETCHAINS_SYMBOL,symbol,opret[0],olen,(double)ovalue/COIN); + for (i=0; i Date: Sat, 19 Nov 2016 14:20:51 -0300 Subject: [PATCH 033/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index fa6794a39..4e0b0a4b6 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -153,7 +153,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( fread(opret,1,olen,fp) != olen ) errs++; //if ( matched != 0 ) global shared state -> global PAX - for (i=0; i Date: Sat, 19 Nov 2016 14:22:31 -0300 Subject: [PATCH 034/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 4e0b0a4b6..2086a868b 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -153,7 +153,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( fread(opret,1,olen,fp) != olen ) errs++; //if ( matched != 0 ) global shared state -> global PAX - int32_t i; for (i=0; i Date: Sat, 19 Nov 2016 14:36:47 -0300 Subject: [PATCH 035/549] test --- src/komodo_globals.h | 2 +- src/komodo_utils.h | 30 +++++++++--------------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index a4b718ec9..cdd4cb5f3 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -31,7 +31,7 @@ int32_t NUM_PRICES; uint32_t *PVALS; struct knotaries_entry *Pubkeys; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS; -struct komodo_state KOMODO_STATES[33]; +struct komodo_state KOMODO_STATES[34]; int COINBASE_MATURITY = 100; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index cc22feb84..48f38e0f9 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1462,33 +1462,21 @@ void komodo_nameset(char *symbol,char *dest,char *source) } } -struct komodo_state *komodo_stateptr(char *symbol,char *dest) -{ - int32_t baseid; struct komodo_state *sp; - komodo_nameset(symbol,dest,ASSETCHAINS_SYMBOL); - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - sp = &KOMODO_STATES[0]; - else - { - if ( (baseid= komodo_baseid(ASSETCHAINS_SYMBOL)) >= 0 ) - sp = &KOMODO_STATES[baseid+1]; - else - { - fprintf(stderr,"komodo_stateupdate.(%s) not supported\n",ASSETCHAINS_SYMBOL); - return(0); - } - } - return(sp); -} - struct komodo_state *komodo_stateptrget(char *base) { int32_t baseid; if ( base == 0 || base[0] == 0 || strcmp(base,"KMD") == 0 ) - return(&KOMODO_STATES[0]); + return(&KOMODO_STATES[33]); else if ( (baseid= komodo_baseid(base)) >= 0 ) return(&KOMODO_STATES[baseid+1]); - else return(0); + else return(&KOMODO_STATES[0]); +} + +struct komodo_state *komodo_stateptr(char *symbol,char *dest) +{ + int32_t baseid; + komodo_nameset(symbol,dest,ASSETCHAINS_SYMBOL); + return(komodo_stateptrget(symbol)); } int32_t komodo_isrealtime(int32_t *kmdheightp,char *target) From 52f1d7888b8c8d9866ae007ce28ea2f54b9a4cec Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 14:40:06 -0300 Subject: [PATCH 036/549] test --- src/komodo_gateway.h | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a447f444f..4f76fc70d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -565,31 +565,28 @@ void komodo_passport_iteration() refid = 32; else refid = komodo_baseid(ASSETCHAINS_SYMBOL); //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); - if ( refid >= 0 ) + for (baseid=0; baseid<=32; baseid++) { - for (baseid=0; baseid<=32; baseid++) + if ( baseid != refid ) { - if ( baseid != refid ) // use direct data for yourself + base = (char *)CURRENCIES[baseid]; + komodo_statefname(fname,baseid<32?base:(char *)""); + komodo_nameset(symbol,dest,base); + if ( (fp= fopen(fname,"rb")) != 0 && (sp= komodo_stateptrget(symbol)) != 0 ) { - base = (char *)CURRENCIES[baseid]; - komodo_statefname(fname,baseid<32?base:(char *)""); - komodo_nameset(symbol,dest,base); - if ( (fp= fopen(fname,"rb")) != 0 && (sp= komodo_stateptrget(symbol)) != 0 ) + fseek(fp,0,SEEK_END); + if ( ftell(fp) > lastpos[baseid] ) { - fseek(fp,0,SEEK_END); - if ( ftell(fp) > lastpos[baseid] ) - { - fseek(fp,lastpos[baseid],SEEK_SET); - while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) - ; - lastpos[baseid] = ftell(fp); - printf("%s lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); - } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); - fclose(fp); - } else printf("fname.(%s) cant open\n",fname); - } - } - } else printf("passport disabled for refid.%d (%s)\n",refid,ASSETCHAINS_SYMBOL); + fseek(fp,lastpos[baseid],SEEK_SET); + while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) + ; + lastpos[baseid] = ftell(fp); + printf("%s lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); + } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); + fclose(fp); + } else printf("fname.(%s) cant open\n",fname); + } // else use direct data for self via connect + } } #endif From ea3aa592244dbc3fe2ecebbaf1c1af0bff3c668d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 14:45:37 -0300 Subject: [PATCH 037/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 2086a868b..9245fda78 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -100,7 +100,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char errs++; if ( fread(¬arized_desttxid,1,sizeof(notarized_desttxid),fp) != sizeof(notarized_desttxid) ) errs++; - printf("%s load[%s] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,symbol,notarized_height,notarized_hash.ToString().c_str()); + //printf("%s load[%s] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,symbol,notarized_height,notarized_hash.ToString().c_str()); //if ( matched != 0 ) global independent states -> inside *sp komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); } From 4031bde05cd6df8364fb54f79cfa81588a1be51f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 14:46:55 -0300 Subject: [PATCH 038/549] test --- src/assetchains | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/assetchains b/src/assetchains index 6341963fe..f3697bc2f 100755 --- a/src/assetchains +++ b/src/assetchains @@ -1,6 +1,8 @@ source pubkey.txt echo $pubkey +./komodod -pubkey=$pubkey -ac_name=REVS -ac_supply=1300000 -addnode=78.47.196.146 $1 & + ./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=EUR -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=JPY -addnode=78.47.196.146 $1 & From fade6934fdb0ecd7e809d49ee6c4d4b73d632100 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 14:51:17 -0300 Subject: [PATCH 039/549] test --- src/komodo_utils.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 48f38e0f9..76df0d07e 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1272,15 +1272,12 @@ void komodo_statefname(char *fname,char *symbol) { fname[len - n] = 0; if ( symbol[0] != 0 ) - { strcpy(&fname[len - n],symbol); - //printf("statefname.(%s)\n",fname); #ifdef WIN32 - strcat(fname,"\\"); + strcat(fname,"\\"); #else - strcat(fname,"/"); + strcat(fname,"/"); #endif - } } else { From be7e899906ff6cfbfd411dac9bfc124b9955528c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 14:52:41 -0300 Subject: [PATCH 040/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 9245fda78..e2ce40cbf 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -500,7 +500,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) signedmask |= (1LL << k); } } - if ( signedmask != 0 ) + if ( 0 && signedmask != 0 ) printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); if ( signedmask != 0 && (notarizedheight != 0 || specialtx != 0) ) { From 1740e3aaa73b87dc3cd92e9106bd2cf596f6af26 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 14:53:55 -0300 Subject: [PATCH 041/549] test --- src/komodo_utils.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 76df0d07e..03fe4bad4 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1273,11 +1273,6 @@ void komodo_statefname(char *fname,char *symbol) fname[len - n] = 0; if ( symbol[0] != 0 ) strcpy(&fname[len - n],symbol); -#ifdef WIN32 - strcat(fname,"\\"); -#else - strcat(fname,"/"); -#endif } else { @@ -1285,6 +1280,11 @@ void komodo_statefname(char *fname,char *symbol) return; } } +#ifdef WIN32 + strcat(fname,"\\"); +#else + strcat(fname,"/"); +#endif strcat(fname,(char *)"komodostate"); //printf("statename.(%s) %s\n",symbol,fname); } From 803176150009423cf1ebcf1a121abb903dde3328 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 14:54:37 -0300 Subject: [PATCH 042/549] test --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e2ce40cbf..5a26cba76 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -123,7 +123,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( fread(&kheight,1,sizeof(kheight),fp) != sizeof(kheight) ) errs++; //if ( matched != 0 ) global independent states -> inside *sp - printf("%s load[%s] ht.%d\n",ASSETCHAINS_SYMBOL,symbol,kheight); + //printf("%s load[%s] ht.%d\n",ASSETCHAINS_SYMBOL,symbol,kheight); komodo_eventadd_kmdheight(sp,symbol,ht,kheight,0); } else if ( func == 'T' ) @@ -134,7 +134,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( fread(&ktimestamp,1,sizeof(ktimestamp),fp) != sizeof(ktimestamp) ) errs++; //if ( matched != 0 ) global independent states -> inside *sp - printf("%s load[%s] ht.%d t.%u\n",ASSETCHAINS_SYMBOL,symbol,kheight,ktimestamp); + //printf("%s load[%s] ht.%d t.%u\n",ASSETCHAINS_SYMBOL,symbol,kheight,ktimestamp); komodo_eventadd_kmdheight(sp,symbol,ht,kheight,ktimestamp); } else if ( func == 'R' ) From 5633157a446415df5662e5b91c765d6fe1466922 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 14:58:48 -0300 Subject: [PATCH 043/549] test --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 5a26cba76..bfa8f55d8 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -123,7 +123,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( fread(&kheight,1,sizeof(kheight),fp) != sizeof(kheight) ) errs++; //if ( matched != 0 ) global independent states -> inside *sp - //printf("%s load[%s] ht.%d\n",ASSETCHAINS_SYMBOL,symbol,kheight); + printf("%s.%d load[%s] ht.%d\n",ASSETCHAINS_SYMBOL,ht,symbol,kheight); komodo_eventadd_kmdheight(sp,symbol,ht,kheight,0); } else if ( func == 'T' ) @@ -134,7 +134,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( fread(&ktimestamp,1,sizeof(ktimestamp),fp) != sizeof(ktimestamp) ) errs++; //if ( matched != 0 ) global independent states -> inside *sp - //printf("%s load[%s] ht.%d t.%u\n",ASSETCHAINS_SYMBOL,symbol,kheight,ktimestamp); + printf("%s.%d load[%s] ht.%d t.%u\n",ASSETCHAINS_SYMBOL,ht,symbol,kheight,ktimestamp); komodo_eventadd_kmdheight(sp,symbol,ht,kheight,ktimestamp); } else if ( func == 'R' ) From 6d562a0e0e7d367b07cf131a5a00eff72173b549 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 15:01:07 -0300 Subject: [PATCH 044/549] test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4f76fc70d..de0ebb7ab 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -574,6 +574,7 @@ void komodo_passport_iteration() komodo_nameset(symbol,dest,base); if ( (fp= fopen(fname,"rb")) != 0 && (sp= komodo_stateptrget(symbol)) != 0 ) { + printf("%s fname.(%s)\n",symbol,fname); fseek(fp,0,SEEK_END); if ( ftell(fp) > lastpos[baseid] ) { From 67cd296f20627f6f52c3337a08c4ad1086d0f8dc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 15:02:15 -0300 Subject: [PATCH 045/549] test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index de0ebb7ab..1df1af8c0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -559,11 +559,11 @@ void komodo_iteration(char *symbol) void komodo_passport_iteration() { - static long lastpos[33]; + static long lastpos[34]; FILE *fp; int32_t baseid,refid; struct komodo_state *sp; char fname[512],*base,symbol[16],dest[16]; if ( ASSETCHAINS_SYMBOL[0] == 0 ) - refid = 32; - else refid = komodo_baseid(ASSETCHAINS_SYMBOL); + refid = 33; + else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=0; baseid<=32; baseid++) { @@ -574,7 +574,7 @@ void komodo_passport_iteration() komodo_nameset(symbol,dest,base); if ( (fp= fopen(fname,"rb")) != 0 && (sp= komodo_stateptrget(symbol)) != 0 ) { - printf("%s fname.(%s)\n",symbol,fname); + printf("refid.%d %s fname.(%s)\n",refid,symbol,fname); fseek(fp,0,SEEK_END); if ( ftell(fp) > lastpos[baseid] ) { From 0e0a794b43306cde58dd1bd00b90cebb38e4ce82 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 15:05:27 -0300 Subject: [PATCH 046/549] test --- src/komodo_gateway.h | 2 +- src/komodo_utils.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1df1af8c0..38905b912 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -574,7 +574,7 @@ void komodo_passport_iteration() komodo_nameset(symbol,dest,base); if ( (fp= fopen(fname,"rb")) != 0 && (sp= komodo_stateptrget(symbol)) != 0 ) { - printf("refid.%d %s fname.(%s)\n",refid,symbol,fname); + printf("refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); fseek(fp,0,SEEK_END); if ( ftell(fp) > lastpos[baseid] ) { diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 03fe4bad4..e0e7ede32 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1265,10 +1265,10 @@ void komodo_statefname(char *fname,char *symbol) { int32_t n,len; sprintf(fname,"%s",GetDataDir(false).string().c_str()); - if ( (n= (int32_t)strlen(ASSETCHAINS_SYMBOL)) != 0 ) + if ( (n= (int32_t)strlen(symbol)) != 0 ) { len = (int32_t)strlen(fname); - if ( strcmp(ASSETCHAINS_SYMBOL,&fname[len - n]) == 0 ) + if ( strcmp(symbol,&fname[len - n]) == 0 ) { fname[len - n] = 0; if ( symbol[0] != 0 ) @@ -1276,7 +1276,7 @@ void komodo_statefname(char *fname,char *symbol) } else { - printf("unexpected fname.(%s) vs %s\n",fname,ASSETCHAINS_SYMBOL); + printf("unexpected fname.(%s) vs %s\n",fname,symbol); return; } } From 4eb91c7afeca67d56caa365352fb362ec7bfa9d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 15:11:44 -0300 Subject: [PATCH 047/549] test --- src/komodo_utils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index e0e7ede32..3a9cc0d23 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1265,7 +1265,7 @@ void komodo_statefname(char *fname,char *symbol) { int32_t n,len; sprintf(fname,"%s",GetDataDir(false).string().c_str()); - if ( (n= (int32_t)strlen(symbol)) != 0 ) + if ( (n= (int32_t)strlen(ASSETCHAINS_SYMBOL)) != 0 ) { len = (int32_t)strlen(fname); if ( strcmp(symbol,&fname[len - n]) == 0 ) @@ -1280,6 +1280,7 @@ void komodo_statefname(char *fname,char *symbol) return; } } + printf("statefname.(%s) -> (%s)\n",symbol,fname); #ifdef WIN32 strcat(fname,"\\"); #else From 413d04bf228cd5d9b53d4f6c563de86961ab7442 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 15:16:36 -0300 Subject: [PATCH 048/549] test --- src/komodo_utils.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 3a9cc0d23..86c51206f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1269,17 +1269,15 @@ void komodo_statefname(char *fname,char *symbol) { len = (int32_t)strlen(fname); if ( strcmp(symbol,&fname[len - n]) == 0 ) - { fname[len - n] = 0; - if ( symbol[0] != 0 ) - strcpy(&fname[len - n],symbol); - } else { printf("unexpected fname.(%s) vs %s\n",fname,symbol); return; } } + if ( symbol != 0 && symbol[0] != 0 ) + strcat(fname,symbol); printf("statefname.(%s) -> (%s)\n",symbol,fname); #ifdef WIN32 strcat(fname,"\\"); From 20533bd89a7a59442f95d765c07e123b87dd53d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 15:19:30 -0300 Subject: [PATCH 049/549] test --- src/komodo_utils.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 86c51206f..2942fc193 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1277,8 +1277,15 @@ void komodo_statefname(char *fname,char *symbol) } } if ( symbol != 0 && symbol[0] != 0 ) + { +#ifdef WIN32 + strcat(fname,"\\"); +#else + strcat(fname,"/"); +#endif strcat(fname,symbol); - printf("statefname.(%s) -> (%s)\n",symbol,fname); + } + //printf("statefname.(%s) -> (%s)\n",symbol,fname); #ifdef WIN32 strcat(fname,"\\"); #else From 95a6016df8dc7eeed3a386bcaaf723cf84240ff7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 15:23:25 -0300 Subject: [PATCH 050/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 38905b912..dda185d52 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -567,7 +567,7 @@ void komodo_passport_iteration() //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=0; baseid<=32; baseid++) { - if ( baseid != refid ) + if ( baseid+1 != refid ) { base = (char *)CURRENCIES[baseid]; komodo_statefname(fname,baseid<32?base:(char *)""); From 29255d5ffb1881e0450646e50e7af690be0f953c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 15:30:20 -0300 Subject: [PATCH 051/549] test --- src/komodo_utils.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2942fc193..41738c012 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1268,7 +1268,7 @@ void komodo_statefname(char *fname,char *symbol) if ( (n= (int32_t)strlen(ASSETCHAINS_SYMBOL)) != 0 ) { len = (int32_t)strlen(fname); - if ( strcmp(symbol,&fname[len - n]) == 0 ) + if ( strcmp(ASSETCHAINS_SYMBOL,&fname[len - n]) == 0 ) fname[len - n] = 0; else { @@ -1276,15 +1276,13 @@ void komodo_statefname(char *fname,char *symbol) return; } } - if ( symbol != 0 && symbol[0] != 0 ) - { #ifdef WIN32 - strcat(fname,"\\"); + strcat(fname,"\\"); #else - strcat(fname,"/"); + strcat(fname,"/"); #endif + if ( symbol == 0 || symbol[0] == 0 || strcmp("KMD",symbol) == 0 ) strcat(fname,symbol); - } //printf("statefname.(%s) -> (%s)\n",symbol,fname); #ifdef WIN32 strcat(fname,"\\"); From 643d946e025a60f8096f1849141180bcbe4ef7bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 15:45:33 -0300 Subject: [PATCH 052/549] test --- src/komodo_utils.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 41738c012..cefdad2d6 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1261,7 +1261,7 @@ void komodo_userpass(char *username,char *password,FILE *fp) free(rpcpassword); } -void komodo_statefname(char *fname,char *symbol) +void komodo_statefname(char *fname,char *symbol,char *test) { int32_t n,len; sprintf(fname,"%s",GetDataDir(false).string().c_str()); @@ -1276,21 +1276,26 @@ void komodo_statefname(char *fname,char *symbol) return; } } + else + { #ifdef WIN32 - strcat(fname,"\\"); + strcat(fname,"\\"); #else - strcat(fname,"/"); + strcat(fname,"/"); #endif - if ( symbol == 0 || symbol[0] == 0 || strcmp("KMD",symbol) == 0 ) + } + if ( symbol != 0 && symbol[0] != 0 && strcmp("KMD",symbol) != 0 ) + { strcat(fname,symbol); - //printf("statefname.(%s) -> (%s)\n",symbol,fname); + //printf("statefname.(%s) -> (%s)\n",symbol,fname); #ifdef WIN32 - strcat(fname,"\\"); + strcat(fname,"\\"); #else - strcat(fname,"/"); + strcat(fname,"/"); #endif + } strcat(fname,(char *)"komodostate"); - //printf("statename.(%s) %s\n",symbol,fname); + //printf("test.(%s) -> [%s] statename.(%s) %s\n",test,ASSETCHAINS_SYMBOL,symbol,fname); } void komodo_configfile(char *symbol,uint16_t port) From 4f28bbed31e074fd2bc4466eeb2492367df5bb24 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 15:46:36 -0300 Subject: [PATCH 053/549] test --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index cefdad2d6..2a5cf4fec 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1261,7 +1261,7 @@ void komodo_userpass(char *username,char *password,FILE *fp) free(rpcpassword); } -void komodo_statefname(char *fname,char *symbol,char *test) +void komodo_statefname(char *fname,char *symbol) { int32_t n,len; sprintf(fname,"%s",GetDataDir(false).string().c_str()); From a4ddd7899c0766535245c8cae48da52f8e9e50aa Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 15:50:21 -0300 Subject: [PATCH 054/549] test --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2a5cf4fec..eca8beb63 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1272,7 +1272,7 @@ void komodo_statefname(char *fname,char *symbol) fname[len - n] = 0; else { - printf("unexpected fname.(%s) vs %s\n",fname,symbol); + printf("unexpected fname.(%s) vs %s [%s] n.%d len.%d (%s)\n",fname,symbol,ASSETCHAINS_SYMBOL,n,len,&fname[len - n]); return; } } From a8f4e85e5023f2cc912ff7a52a71b97148fb1d97 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 15:57:18 -0300 Subject: [PATCH 055/549] test --- src/komodo.h | 4 ++-- src/komodo_gateway.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index bfa8f55d8..a36aab0b4 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -123,7 +123,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( fread(&kheight,1,sizeof(kheight),fp) != sizeof(kheight) ) errs++; //if ( matched != 0 ) global independent states -> inside *sp - printf("%s.%d load[%s] ht.%d\n",ASSETCHAINS_SYMBOL,ht,symbol,kheight); + //printf("%s.%d load[%s] ht.%d\n",ASSETCHAINS_SYMBOL,ht,symbol,kheight); komodo_eventadd_kmdheight(sp,symbol,ht,kheight,0); } else if ( func == 'T' ) @@ -134,7 +134,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( fread(&ktimestamp,1,sizeof(ktimestamp),fp) != sizeof(ktimestamp) ) errs++; //if ( matched != 0 ) global independent states -> inside *sp - printf("%s.%d load[%s] ht.%d t.%u\n",ASSETCHAINS_SYMBOL,ht,symbol,kheight,ktimestamp); + //printf("%s.%d load[%s] ht.%d t.%u\n",ASSETCHAINS_SYMBOL,ht,symbol,kheight,ktimestamp); komodo_eventadd_kmdheight(sp,symbol,ht,kheight,ktimestamp); } else if ( func == 'R' ) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index dda185d52..a3ea9dda1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -574,7 +574,7 @@ void komodo_passport_iteration() komodo_nameset(symbol,dest,base); if ( (fp= fopen(fname,"rb")) != 0 && (sp= komodo_stateptrget(symbol)) != 0 ) { - printf("refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); + //printf("refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); fseek(fp,0,SEEK_END); if ( ftell(fp) > lastpos[baseid] ) { From 5f34a2242f4da6fa5a6501efb4b9d8a1f6648c24 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 16:05:53 -0300 Subject: [PATCH 056/549] test --- src/komodo_bitcoind.h | 2 +- src/komodo_gateway.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 8e915a170..08a02f097 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -539,7 +539,7 @@ int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 has } } else fprintf(stderr,"unexpected error notary_hash %s ht.%d at ht.%d\n",notarized_hash.ToString().c_str(),notarized_height,notary->nHeight); } else if ( notarized_height > 0 && notarized_height != 73880 ) - fprintf(stderr,"couldnt find notary_hash %s ht.%d\n",notarized_hash.ToString().c_str(),notarized_height); + fprintf(stderr,"[%s] couldnt find notary_hash %s ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height); return(0); } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a3ea9dda1..0fb7cef87 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -582,7 +582,7 @@ void komodo_passport_iteration() while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) ; lastpos[baseid] = ftell(fp); - printf("%s lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); + printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); } else printf("fname.(%s) cant open\n",fname); From 92866aa17bb73be6064b761819be78194e2a2981 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 16:16:17 -0300 Subject: [PATCH 057/549] test --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 055ecac9b..0df2b8502 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -108,7 +108,7 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) memcpy(kp->pubkey,pubkeys[k],33); kp->notaryid = k; HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); - //if ( height > 0 ) + if ( height > 0 ) { for (i=0; i<33; i++) printf("%02x",pubkeys[k][i]); From a9bb99d2fe07aa0562e5a4c9620490757b622606 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 16:21:34 -0300 Subject: [PATCH 058/549] test --- src/komodo_bitcoind.h | 2 +- src/komodo_events.h | 2 +- src/komodo_gateway.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 08a02f097..ebe2b8079 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -539,7 +539,7 @@ int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 has } } else fprintf(stderr,"unexpected error notary_hash %s ht.%d at ht.%d\n",notarized_hash.ToString().c_str(),notarized_height,notary->nHeight); } else if ( notarized_height > 0 && notarized_height != 73880 ) - fprintf(stderr,"[%s] couldnt find notary_hash %s ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height); + fprintf(stderr,"[%s] couldnt find notarized.(%s %d) ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height,chainActive.Tip()->nHeight); return(0); } diff --git a/src/komodo_events.h b/src/komodo_events.h index 0e5439210..08b2db7fb 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -112,7 +112,7 @@ void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height) { if ( ep->height < height ) break; - printf("undo event.%c ht.%d for rewind.%d\n",ep->type,ep->height,height); + printf("[%s] undo %s event.%c ht.%d for rewind.%d\n",ASSETCHAINS_SYMBOL,symbol,ep->type,ep->height,height); komodo_event_undo(sp,ep); sp->Komodo_numevents--; } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0fb7cef87..5212b8d33 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -582,7 +582,7 @@ void komodo_passport_iteration() while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) ; lastpos[baseid] = ftell(fp); - printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); + //printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); } else printf("fname.(%s) cant open\n",fname); From 03ef7187bc613ce41a5873c53f3406927475b38b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 16:26:49 -0300 Subject: [PATCH 059/549] test --- src/komodo_globals.h | 1 - src/komodo_notary.h | 31 +++++++++++++++++-------------- src/komodo_structs.h | 1 + 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index cdd4cb5f3..72ecc3eba 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -29,7 +29,6 @@ pthread_mutex_t komodo_mutex; struct pax_transaction *PAX; int32_t NUM_PRICES; uint32_t *PVALS; struct knotaries_entry *Pubkeys; -struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS; struct komodo_state KOMODO_STATES[34]; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 0df2b8502..d44eb5177 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -168,8 +168,8 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not printf("komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); return; } - NPOINTS = (struct notarized_checkpoint *)realloc(NPOINTS,(NUM_NPOINTS+1) * sizeof(*NPOINTS)); - np = &NPOINTS[NUM_NPOINTS++]; + sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); + np = &sp->NPOINTS[NUM_NPOINTS++]; memset(np,0,sizeof(*np)); np->nHeight = nHeight; sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; @@ -197,21 +197,24 @@ int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp) int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) { - struct notarized_checkpoint *np = 0; int32_t i; - if ( NUM_NPOINTS > 0 ) + struct notarized_checkpoint *np = 0; int32_t i; char symbol[16],dest[16]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) { - for (i=0; iNUM_NPOINTS > 0 ) { - if ( NPOINTS[i].nHeight >= nHeight ) - break; - np = &NPOINTS[i]; + for (i=0; iNUM_NPOINTS; i++) + { + if ( sp->NPOINTS[i].nHeight >= nHeight ) + break; + np = &sp->NPOINTS[i]; + } + } + if ( np != 0 ) + { + *notarized_hashp = np->notarized_hash; + *notarized_desttxidp = np->notarized_desttxid; + return(np->notarized_height); } - } - if ( np != 0 ) - { - *notarized_hashp = np->notarized_hash; - *notarized_desttxidp = np->notarized_desttxid; - return(np->notarized_height); } memset(notarized_hashp,0,sizeof(*notarized_hashp)); return(0); diff --git a/src/komodo_structs.h b/src/komodo_structs.h index eed4103bd..89ebcab33 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -72,5 +72,6 @@ struct komodo_state uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID; int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT; uint32_t KOMODO_REALTIME,SAVEDTIMESTAMP; + struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS; struct komodo_event **Komodo_events; int32_t Komodo_numevents; }; From 2e98c3a27aadcc2ec9e30629b2e63ff31d245b1a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 16:27:55 -0300 Subject: [PATCH 060/549] test --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d44eb5177..61c9473fa 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -169,7 +169,7 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not return; } sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); - np = &sp->NPOINTS[NUM_NPOINTS++]; + np = &sp->NPOINTS[sp->NUM_NPOINTS++]; memset(np,0,sizeof(*np)); np->nHeight = nHeight; sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; From f595c2e0f88583190c2bbd8153f6e897ed1ac094 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 17:01:44 -0300 Subject: [PATCH 061/549] test --- src/main.cpp | 2 +- src/rpcmisc.cpp | 2 ++ src/rpcnet.cpp | 30 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 41d21c7b8..d070178d5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1179,7 +1179,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa view.GetBestBlock(); nValueIn = view.GetValueIn(chainActive.Tip()->nHeight,&interest,tx,chainActive.Tip()->nTime); - if ( interest != 0 ) + if ( 0 && interest != 0 ) fprintf(stderr,"add interest %.8f\n",(double)interest/COIN); // we have all inputs cached now, so switch back to dummy, so we don't need to keep lock on mempool view.SetBackend(dummy); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 9cc9d4d12..7f289723a 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -40,6 +40,7 @@ using namespace std; * Or alternatively, create a specific query method for the information. **/ uint64_t komodo_interestsum(); +int32_t komodo_longestchain(); int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp); Value getinfo(const Array& params, bool fHelp) @@ -98,6 +99,7 @@ Value getinfo(const Array& params, bool fHelp) } #endif obj.push_back(Pair("blocks", (int)chainActive.Height())); + obj.push_back(Pair("longestchain", komodo_longestchain())); obj.push_back(Pair("timeoffset", GetTimeOffset())); if ( chainActive.Tip() != 0 ) obj.push_back(Pair("tiptime", (int)chainActive.Tip()->nTime)); diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index e3d264a57..76c9fceb2 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -165,6 +165,36 @@ Value getpeerinfo(const Array& params, bool fHelp) return ret; } +int32_t komodo_longestchain() +{ + int32_t ht,n=0,num=0,maxheight=0,height = 0; + LOCK(cs_main); + vector vstats; + CopyNodeStats(vstats); + BOOST_FOREACH(const CNodeStats& stats, vstats) + { + CNodeStateStats statestats; + bool fStateStats = GetNodeStateStats(stats.nodeid,statestats); + ht = 0; + if ( stats.nStartingHeight > ht ) + ht = stats.nStartingHeight; + if ( stats.nSyncHeight > ht ) + ht = stats.nSyncHeight; + if ( stats.nCommonHeight > ht ) + ht = stats.nCommonHeight; + if ( maxheight == 0 || ht > maxheight*1.01 ) + maxheight = ht, num = 1; + else if ( ht > maxheight*0.99 ) + num++; + n++; + if ( ht > height ) + height = ht; + } + if ( num > (n >> 1) ) + return(height); + else return(0); +} + Value addnode(const Array& params, bool fHelp) { string strCommand; From ffaeceaed06a327adc90e0efb382581dfc03d5e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 17:04:59 -0300 Subject: [PATCH 062/549] test --- src/rpcnet.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index 76c9fceb2..7e05c6efd 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -178,10 +178,10 @@ int32_t komodo_longestchain() ht = 0; if ( stats.nStartingHeight > ht ) ht = stats.nStartingHeight; - if ( stats.nSyncHeight > ht ) - ht = stats.nSyncHeight; - if ( stats.nCommonHeight > ht ) - ht = stats.nCommonHeight; + if ( statestats.nSyncHeight > ht ) + ht = statestats.nSyncHeight; + if ( statestats.nCommonHeight > ht ) + ht = statestats.nCommonHeight; if ( maxheight == 0 || ht > maxheight*1.01 ) maxheight = ht, num = 1; else if ( ht > maxheight*0.99 ) From a19b28ce5e132fb66315cdb446390e20efcac38d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 17:10:01 -0300 Subject: [PATCH 063/549] test --- src/komodo_notary.h | 2 +- src/rpcmisc.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 61c9473fa..5cea65f95 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -108,7 +108,7 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) memcpy(kp->pubkey,pubkeys[k],33); kp->notaryid = k; HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); - if ( height > 0 ) + if ( height > 10000 ) { for (i=0; i<33; i++) printf("%02x",pubkeys[k][i]); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 7f289723a..e6bf47e4f 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -46,7 +46,7 @@ int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp); Value getinfo(const Array& params, bool fHelp) { uint256 notarized_hash,notarized_desttxid; - int32_t notarized_height; + int32_t notarized_height,longestchain; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -99,7 +99,9 @@ Value getinfo(const Array& params, bool fHelp) } #endif obj.push_back(Pair("blocks", (int)chainActive.Height())); - obj.push_back(Pair("longestchain", komodo_longestchain())); + if ( (longestchain= komodo_longestchain()) != 0 && chainActive.Height() > longestchain ) + longestchain = chainActive.Height(); + obj.push_back(Pair("longestchain", longestchain)); obj.push_back(Pair("timeoffset", GetTimeOffset())); if ( chainActive.Tip() != 0 ) obj.push_back(Pair("tiptime", (int)chainActive.Tip()->nTime)); From 550824a80928c1f58e5f874458a0d2919d9bd305 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 17:28:13 -0300 Subject: [PATCH 064/549] test --- src/komodo.h | 2 +- src/komodo_events.h | 2 ++ src/komodo_gateway.h | 20 +++++++++++++++++++- src/komodo_utils.h | 11 ++++++++++- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index a36aab0b4..a06b20faf 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -460,7 +460,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) sleep(30); } }*/ - sp->KOMODO_REALTIME = KOMODO_INITDONE = (uint32_t)time(NULL); + KOMODO_INITDONE = (uint32_t)time(NULL); if ( pindex != 0 ) { height = pindex->nHeight; diff --git a/src/komodo_events.h b/src/komodo_events.h index 08b2db7fb..b11b1e101 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -127,6 +127,8 @@ void komodo_setkmdheight(struct komodo_state *sp,int32_t kmdheight,uint32_t time sp->SAVEDHEIGHT = kmdheight; sp->SAVEDTIMESTAMP = timestamp; } + if ( kmdheight > sp->CURRENT_HEIGHT ) + sp->CURRENT_HEIGHT = kmdheight; } void komodo_eventadd_kmdheight(struct komodo_state *sp,char *symbol,int32_t height,int32_t kmdheight,uint32_t timestamp) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5212b8d33..4e840e133 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -560,7 +560,7 @@ void komodo_iteration(char *symbol) void komodo_passport_iteration() { static long lastpos[34]; - FILE *fp; int32_t baseid,refid; struct komodo_state *sp; char fname[512],*base,symbol[16],dest[16]; + FILE *fp; int32_t baseid,isrealtime,refid,block,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj; uint16_t port; uint32_t magic; if ( ASSETCHAINS_SYMBOL[0] == 0 ) refid = 33; else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; @@ -572,6 +572,9 @@ void komodo_passport_iteration() base = (char *)CURRENCIES[baseid]; komodo_statefname(fname,baseid<32?base:(char *)""); komodo_nameset(symbol,dest,base); + port = komodo_port(base,10,&magic); + sp = 0; + isrealtime = 0; if ( (fp= fopen(fname,"rb")) != 0 && (sp= komodo_stateptrget(symbol)) != 0 ) { //printf("refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); @@ -585,7 +588,22 @@ void komodo_passport_iteration() //printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); + if ( (retstr= komodo_issuemethod((char *)"getinfo",0,port)) != 0 ) + { + if ( (infoobj= cJSON_Parse(retstr)) != 0 ) + { + blocks = juint(infoobj,"blocks"); + longest = juint(infoobj,"longestchain"); + printf("(%s %d %d) ",base,blocks,longest); + if ( blocks > 0 && blocks == longest ) + isrealtime = 1; + free_json(infoobj); + } + free(retstr); + } } else printf("fname.(%s) cant open\n",fname); + if ( sp != 0 ) + sp->KOMODO_REALTIME = isrealtime * (uint32_t)time(NULL); } // else use direct data for self via connect } } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index eca8beb63..256e593f4 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1358,6 +1358,8 @@ void komodo_configfile(char *symbol,uint16_t port) uint32_t komodo_assetmagic(char *symbol,uint64_t supply) { uint8_t buf[512]; int32_t len = 0; + if ( strcmp(symbol,"KMD") == 0 ) + return(0x8de4eef9); len = iguana_rwnum(1,&buf[len],sizeof(supply),(void *)&supply); strcpy((char *)&buf[len],symbol); len += strlen(symbol); @@ -1379,11 +1381,18 @@ uint32_t komodo_assetmagic(char *symbol,uint64_t supply) uint16_t komodo_assetport(uint32_t magic) { - return(8000 + (magic % 7777)); + if ( magic == 0x8de4eef9 ) + return(7771); + else return(8000 + (magic % 7777)); } uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp) { + if ( symbol == 0 || symbol[0] == 0 || strcmp("KMD",symbol) == 0 ) + { + *magicp = 0x8de4eef9; + return(7771); + } *magicp = komodo_assetmagic(symbol,supply); return(komodo_assetport(*magicp)); } From af125a4e83128037b17f3478a9645877e2389f52 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 17:29:16 -0300 Subject: [PATCH 065/549] test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4e840e133..27b368a52 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -560,7 +560,7 @@ void komodo_iteration(char *symbol) void komodo_passport_iteration() { static long lastpos[34]; - FILE *fp; int32_t baseid,isrealtime,refid,block,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj; uint16_t port; uint32_t magic; + FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj; uint16_t port; uint32_t magic; if ( ASSETCHAINS_SYMBOL[0] == 0 ) refid = 33; else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; @@ -592,8 +592,8 @@ void komodo_passport_iteration() { if ( (infoobj= cJSON_Parse(retstr)) != 0 ) { - blocks = juint(infoobj,"blocks"); - longest = juint(infoobj,"longestchain"); + blocks = juint(infoobj,(char *)"blocks"); + longest = juint(infoobj,(char *)"longestchain"); printf("(%s %d %d) ",base,blocks,longest); if ( blocks > 0 && blocks == longest ) isrealtime = 1; From 1333a8c47d122d5ad2b016c16ddc709b59734105 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 17:32:53 -0300 Subject: [PATCH 066/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 27b368a52..02c26f127 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -600,7 +600,7 @@ void komodo_passport_iteration() free_json(infoobj); } free(retstr); - } + } else printf("%s port.%u no getinfo\n",base,port); } else printf("fname.(%s) cant open\n",fname); if ( sp != 0 ) sp->KOMODO_REALTIME = isrealtime * (uint32_t)time(NULL); From 950baa0e6b3a37ad276af2df06b7e399f7b17642 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 17:37:44 -0300 Subject: [PATCH 067/549] test --- src/komodo_gateway.h | 2 +- src/komodo_utils.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 02c26f127..a2c1a6704 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -572,7 +572,7 @@ void komodo_passport_iteration() base = (char *)CURRENCIES[baseid]; komodo_statefname(fname,baseid<32?base:(char *)""); komodo_nameset(symbol,dest,base); - port = komodo_port(base,10,&magic); + port = komodo_port(base,10,&magic) + 1; sp = 0; isrealtime = 0; if ( (fp= fopen(fname,"rb")) != 0 && (sp= komodo_stateptrget(symbol)) != 0 ) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 256e593f4..049e0603b 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1382,7 +1382,7 @@ uint32_t komodo_assetmagic(char *symbol,uint64_t supply) uint16_t komodo_assetport(uint32_t magic) { if ( magic == 0x8de4eef9 ) - return(7771); + return(7770); else return(8000 + (magic % 7777)); } @@ -1391,7 +1391,7 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp) if ( symbol == 0 || symbol[0] == 0 || strcmp("KMD",symbol) == 0 ) { *magicp = 0x8de4eef9; - return(7771); + return(7770); } *magicp = komodo_assetmagic(symbol,supply); return(komodo_assetport(*magicp)); From 51311cad6f5d55804879df63ead6fb037fbb8539 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 17:46:09 -0300 Subject: [PATCH 068/549] test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a2c1a6704..88141b12d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -599,6 +599,7 @@ void komodo_passport_iteration() isrealtime = 1; free_json(infoobj); } + printf("(%s)\n",retstr); free(retstr); } else printf("%s port.%u no getinfo\n",base,port); } else printf("fname.(%s) cant open\n",fname); From 0ded57c850c376d63af4f4d5415f059495d52ece Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 17:58:04 -0300 Subject: [PATCH 069/549] test --- src/komodo.h | 2 +- src/komodo_bitcoind.h | 4 ++-- src/komodo_gateway.h | 12 +++++++++--- src/komodo_globals.h | 2 +- src/komodo_utils.h | 20 ++++++++++++++++++-- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index a06b20faf..970e088de 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -188,7 +188,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar return; if ( fp == 0 ) { - komodo_statefname(fname,ASSETCHAINS_SYMBOL); + komodo_statefname(fname,ASSETCHAINS_SYMBOL,"komodostate"); if ( (fp= fopen(fname,"rb+")) != 0 ) { while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ebe2b8079..fdd383c33 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -329,7 +329,7 @@ char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char * return(chunk.memory); } -char *komodo_issuemethod(char *method,char *params,uint16_t port) +char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) { //static void *cHandle; char url[512],*retstr=0,*retstr2=0,postdata[8192]; @@ -340,7 +340,7 @@ char *komodo_issuemethod(char *method,char *params,uint16_t port) sprintf(url,(char *)"http://127.0.0.1:%u",port); sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params); //printf("postdata.(%s) USERPASS.(%s)\n",postdata,KMDUSERPASS); - retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,KMDUSERPASS,method,params); + retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params); //retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0); } return(retstr2); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 88141b12d..9ef29ef33 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -559,8 +559,14 @@ void komodo_iteration(char *symbol) void komodo_passport_iteration() { - static long lastpos[34]; + static long lastpos[34],didinit; static char userpass[33][1024]; FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj; uint16_t port; uint32_t magic; + if ( didinit == 0 ) + { + for (baseid=0; baseid<=32; baseid++) + komodo_userpass(userpass[baseid],CURRENCIES[baseid]) + didinit = 1; + } if ( ASSETCHAINS_SYMBOL[0] == 0 ) refid = 33; else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; @@ -570,7 +576,7 @@ void komodo_passport_iteration() if ( baseid+1 != refid ) { base = (char *)CURRENCIES[baseid]; - komodo_statefname(fname,baseid<32?base:(char *)""); + komodo_statefname(fname,baseid<32?base:(char *)"","komodostate"); komodo_nameset(symbol,dest,base); port = komodo_port(base,10,&magic) + 1; sp = 0; @@ -588,7 +594,7 @@ void komodo_passport_iteration() //printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); - if ( (retstr= komodo_issuemethod((char *)"getinfo",0,port)) != 0 ) + if ( (retstr= komodo_issuemethod(userpass[baseid],(char *)"getinfo",0,port)) != 0 ) { if ( (infoobj= cJSON_Parse(retstr)) != 0 ) { diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 72ecc3eba..f92b72248 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -16,7 +16,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint32_t ktime,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout); void komodo_init(int32_t height); int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp); -char *komodo_issuemethod(char *method,char *params,uint16_t port); +char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port); void komodo_init(int32_t height); void komodo_assetchain_pubkeys(char *jsonstr); int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 049e0603b..82db20e39 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1261,7 +1261,7 @@ void komodo_userpass(char *username,char *password,FILE *fp) free(rpcpassword); } -void komodo_statefname(char *fname,char *symbol) +void komodo_statefname(char *fname,char *symbol,char *str) { int32_t n,len; sprintf(fname,"%s",GetDataDir(false).string().c_str()); @@ -1294,7 +1294,7 @@ void komodo_statefname(char *fname,char *symbol) strcat(fname,"/"); #endif } - strcat(fname,(char *)"komodostate"); + strcat(fname,str); //printf("test.(%s) -> [%s] statename.(%s) %s\n",test,ASSETCHAINS_SYMBOL,symbol,fname); } @@ -1355,6 +1355,22 @@ void komodo_configfile(char *symbol,uint16_t port) } else printf("couldnt open.(%s)\n",fname); } +int32_t komodo_userpass(char *userpass,char *symbol) +{ + FILE *fp; char fname[512],username[512],password[512],confname[16]; + userpass[0] = 0; + sprintf(confname,"%s.conf",symbol); + komodo_statefname(fname,symbol,confname); + if ( (fp= fopen(fname,"rb")) != 0 ) + { + komodo_userpass(username,password,fp); + sprintf(userpass,"%s:%s",username,password); + fclose(fp); + return((int32_t)strlen(userpass)); + } + return(-1); +} + uint32_t komodo_assetmagic(char *symbol,uint64_t supply) { uint8_t buf[512]; int32_t len = 0; From 055db9b60e27f6b2f239c7fe35b30f8e74fdbded Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 17:59:34 -0300 Subject: [PATCH 070/549] test --- src/komodo.h | 2 +- src/komodo_gateway.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 970e088de..58dc8bb58 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -188,7 +188,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar return; if ( fp == 0 ) { - komodo_statefname(fname,ASSETCHAINS_SYMBOL,"komodostate"); + komodo_statefname(fname,ASSETCHAINS_SYMBOL,(char *)"komodostate"); if ( (fp= fopen(fname,"rb+")) != 0 ) { while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9ef29ef33..aec40dab6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -564,7 +564,7 @@ void komodo_passport_iteration() if ( didinit == 0 ) { for (baseid=0; baseid<=32; baseid++) - komodo_userpass(userpass[baseid],CURRENCIES[baseid]) + komodo_userpass(userpass[baseid],CURRENCIES[baseid]); didinit = 1; } if ( ASSETCHAINS_SYMBOL[0] == 0 ) @@ -576,7 +576,7 @@ void komodo_passport_iteration() if ( baseid+1 != refid ) { base = (char *)CURRENCIES[baseid]; - komodo_statefname(fname,baseid<32?base:(char *)"","komodostate"); + komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"komodostate"); komodo_nameset(symbol,dest,base); port = komodo_port(base,10,&magic) + 1; sp = 0; From 43450135b580c27628eaef8ad7e8bdacc36a7971 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 18:07:04 -0300 Subject: [PATCH 071/549] test --- src/komodo_gateway.h | 17 ++++++++++------- src/main.cpp | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index aec40dab6..418774fad 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -560,7 +560,7 @@ void komodo_iteration(char *symbol) void komodo_passport_iteration() { static long lastpos[34],didinit; static char userpass[33][1024]; - FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj; uint16_t port; uint32_t magic; + FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj,*result; uint16_t port; uint32_t magic; if ( didinit == 0 ) { for (baseid=0; baseid<=32; baseid++) @@ -598,14 +598,17 @@ void komodo_passport_iteration() { if ( (infoobj= cJSON_Parse(retstr)) != 0 ) { - blocks = juint(infoobj,(char *)"blocks"); - longest = juint(infoobj,(char *)"longestchain"); - printf("(%s %d %d) ",base,blocks,longest); - if ( blocks > 0 && blocks == longest ) - isrealtime = 1; + if ( (result= jobj(infoobj,"result")) != 0 ) + { + blocks = juint(infoobj,(char *)"blocks"); + longest = juint(infoobj,(char *)"longestchain"); + printf("%s.(%d L%d) ",base,blocks,longest); + if ( blocks > 0 && blocks == longest ) + isrealtime = 1; + } free_json(infoobj); } - printf("(%s)\n",retstr); + //printf("(%s)\n",retstr); free(retstr); } else printf("%s port.%u no getinfo\n",base,port); } else printf("fname.(%s) cant open\n",fname); diff --git a/src/main.cpp b/src/main.cpp index d070178d5..822fc76ce 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -535,10 +535,10 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc // Find the first block the caller has in the main chain BOOST_FOREACH(const uint256& hash, locator.vHave) { BlockMap::iterator mi = mapBlockIndex.find(hash); - if (mi != mapBlockIndex.end()) + if (mi != 0 && mi != mapBlockIndex.end()) { CBlockIndex* pindex = (*mi).second; - if (chain.Contains(pindex)) + if (pindex != 0 && chain.Contains(pindex)) return pindex; } } From e4d89f433c00722a514cc21cc0d15c36167c1da4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 18:09:04 -0300 Subject: [PATCH 072/549] test --- src/komodo_gateway.h | 2 +- src/komodo_utils.h | 2 ++ src/main.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 418774fad..ac0ca7837 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -598,7 +598,7 @@ void komodo_passport_iteration() { if ( (infoobj= cJSON_Parse(retstr)) != 0 ) { - if ( (result= jobj(infoobj,"result")) != 0 ) + if ( (result= jobj(infoobj,(char *)"result")) != 0 ) { blocks = juint(infoobj,(char *)"blocks"); longest = juint(infoobj,(char *)"longestchain"); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 82db20e39..75fdbfa69 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1361,6 +1361,8 @@ int32_t komodo_userpass(char *userpass,char *symbol) userpass[0] = 0; sprintf(confname,"%s.conf",symbol); komodo_statefname(fname,symbol,confname); + if ( strcmp(symbol,"KMD") == 0 ) + printf("conf.(%s)\n",fname); if ( (fp= fopen(fname,"rb")) != 0 ) { komodo_userpass(username,password,fp); diff --git a/src/main.cpp b/src/main.cpp index 822fc76ce..0e1b84341 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -535,7 +535,7 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc // Find the first block the caller has in the main chain BOOST_FOREACH(const uint256& hash, locator.vHave) { BlockMap::iterator mi = mapBlockIndex.find(hash); - if (mi != 0 && mi != mapBlockIndex.end()) + if (mi != mapBlockIndex.end()) { CBlockIndex* pindex = (*mi).second; if (pindex != 0 && chain.Contains(pindex)) From ecf6256cab6e9e6aa064d18de5e6cbee0deceaff Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 18:14:44 -0300 Subject: [PATCH 073/549] test --- src/komodo_gateway.h | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ac0ca7837..ef6a1c451 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -573,14 +573,14 @@ void komodo_passport_iteration() //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=0; baseid<=32; baseid++) { + sp = 0; + isrealtime = 0; if ( baseid+1 != refid ) { base = (char *)CURRENCIES[baseid]; komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"komodostate"); komodo_nameset(symbol,dest,base); port = komodo_port(base,10,&magic) + 1; - sp = 0; - isrealtime = 0; if ( (fp= fopen(fname,"rb")) != 0 && (sp= komodo_stateptrget(symbol)) != 0 ) { //printf("refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); @@ -594,27 +594,27 @@ void komodo_passport_iteration() //printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); - if ( (retstr= komodo_issuemethod(userpass[baseid],(char *)"getinfo",0,port)) != 0 ) + } + } + if ( (retstr= komodo_issuemethod(userpass[baseid],(char *)"getinfo",0,port)) != 0 ) + { + if ( (infoobj= cJSON_Parse(retstr)) != 0 ) + { + if ( (result= jobj(infoobj,(char *)"result")) != 0 ) { - if ( (infoobj= cJSON_Parse(retstr)) != 0 ) - { - if ( (result= jobj(infoobj,(char *)"result")) != 0 ) - { - blocks = juint(infoobj,(char *)"blocks"); - longest = juint(infoobj,(char *)"longestchain"); - printf("%s.(%d L%d) ",base,blocks,longest); - if ( blocks > 0 && blocks == longest ) - isrealtime = 1; - } - free_json(infoobj); - } - //printf("(%s)\n",retstr); - free(retstr); - } else printf("%s port.%u no getinfo\n",base,port); - } else printf("fname.(%s) cant open\n",fname); - if ( sp != 0 ) - sp->KOMODO_REALTIME = isrealtime * (uint32_t)time(NULL); - } // else use direct data for self via connect + blocks = juint(result,(char *)"blocks"); + longest = juint(result,(char *)"longestchain"); + printf("%s.(%d L%d) ",base,blocks,longest); + if ( blocks > 0 && blocks == longest ) + isrealtime = 1; + } + free_json(infoobj); + } + //printf("(%s)\n",retstr); + free(retstr); + } else printf("%s port.%u no getinfo\n",base,port); + if ( sp != 0 ) + sp->KOMODO_REALTIME = isrealtime * (uint32_t)time(NULL); } } #endif From f394a03e91f1dd7cbb43cd2f24164a8cae2f46ab Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 18:19:03 -0300 Subject: [PATCH 074/549] test --- src/komodo_gateway.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ef6a1c451..37025b4f3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -604,13 +604,14 @@ void komodo_passport_iteration() { blocks = juint(result,(char *)"blocks"); longest = juint(result,(char *)"longestchain"); - printf("%s.(%d L%d) ",base,blocks,longest); + //printf("%s.(%d L%d) ",base,blocks,longest); if ( blocks > 0 && blocks == longest ) isrealtime = 1; } free_json(infoobj); } - //printf("(%s)\n",retstr); + if ( baseid == 32 ) + printf("(%s)\n",retstr); free(retstr); } else printf("%s port.%u no getinfo\n",base,port); if ( sp != 0 ) From 8e3649cb3cc51a25d6a4c3fe30cdc927eced8acf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 18:23:34 -0300 Subject: [PATCH 075/549] test --- src/komodo_utils.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 75fdbfa69..c48eec5f9 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1361,8 +1361,7 @@ int32_t komodo_userpass(char *userpass,char *symbol) userpass[0] = 0; sprintf(confname,"%s.conf",symbol); komodo_statefname(fname,symbol,confname); - if ( strcmp(symbol,"KMD") == 0 ) - printf("conf.(%s)\n",fname); + printf("[%s] conf.(%s)\n",symbol,fname); if ( (fp= fopen(fname,"rb")) != 0 ) { komodo_userpass(username,password,fp); From 609fbcc2665febc1a8917fd85453c73c154c9049 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 18:27:28 -0300 Subject: [PATCH 076/549] test --- src/komodo_gateway.h | 2 +- src/komodo_utils.h | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 37025b4f3..56f7b53a3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -613,7 +613,7 @@ void komodo_passport_iteration() if ( baseid == 32 ) printf("(%s)\n",retstr); free(retstr); - } else printf("%s port.%u no getinfo\n",base,port); + } // else printf("%s port.%u no getinfo\n",base,port); if ( sp != 0 ) sp->KOMODO_REALTIME = isrealtime * (uint32_t)time(NULL); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index c48eec5f9..e6d7d5f5e 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1359,9 +1359,11 @@ int32_t komodo_userpass(char *userpass,char *symbol) { FILE *fp; char fname[512],username[512],password[512],confname[16]; userpass[0] = 0; - sprintf(confname,"%s.conf",symbol); + if ( strcmp("KMD",symbol) == 0 ) + sprintf(confname,"komodo.conf"); + else sprintf(confname,"%s.conf",symbol); komodo_statefname(fname,symbol,confname); - printf("[%s] conf.(%s)\n",symbol,fname); + //printf("[%s] conf.(%s)\n",symbol,fname); if ( (fp= fopen(fname,"rb")) != 0 ) { komodo_userpass(username,password,fp); From 4961e57b81aaf43c5beac6601102750f55f8c303 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 18:33:04 -0300 Subject: [PATCH 077/549] test --- src/komodo_utils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index e6d7d5f5e..cdb565722 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1363,12 +1363,13 @@ int32_t komodo_userpass(char *userpass,char *symbol) sprintf(confname,"komodo.conf"); else sprintf(confname,"%s.conf",symbol); komodo_statefname(fname,symbol,confname); - //printf("[%s] conf.(%s)\n",symbol,fname); + printf("[%s] conf.(%s)\n",symbol,fname); if ( (fp= fopen(fname,"rb")) != 0 ) { komodo_userpass(username,password,fp); sprintf(userpass,"%s:%s",username,password); fclose(fp); + printf("[%s] conf.(%s) %s\n",symbol,fname,userpass); return((int32_t)strlen(userpass)); } return(-1); From 7d4c1af6df097f4626dbd0b59f935ce5ceb459e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 18:36:16 -0300 Subject: [PATCH 078/549] test --- src/komodo_gateway.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 56f7b53a3..c2576903b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -610,8 +610,7 @@ void komodo_passport_iteration() } free_json(infoobj); } - if ( baseid == 32 ) - printf("(%s)\n",retstr); + else printf("%s (%s)\n",base,retstr); free(retstr); } // else printf("%s port.%u no getinfo\n",base,port); if ( sp != 0 ) From be0e81d0d8040e5076c79ce16a410a316c0805e3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 18:42:15 -0300 Subject: [PATCH 079/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c2576903b..41cc8d7fd 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -610,7 +610,7 @@ void komodo_passport_iteration() } free_json(infoobj); } - else printf("%s (%s)\n",base,retstr); + else printf("[%s] %s (%s)\n",ASSETCHAINS_SYMBOL,base,retstr); free(retstr); } // else printf("%s port.%u no getinfo\n",base,port); if ( sp != 0 ) From a7ef556c2b807b2edad96f0eba03e3ee7c68ac4f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 18:53:52 -0300 Subject: [PATCH 080/549] test --- src/komodo_gateway.h | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 41cc8d7fd..b1f20bec4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -560,13 +560,13 @@ void komodo_iteration(char *symbol) void komodo_passport_iteration() { static long lastpos[34],didinit; static char userpass[33][1024]; - FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj,*result; uint16_t port; uint32_t magic; - if ( didinit == 0 ) + FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj,*result; uint16_t port; uint32_t magic,buf[3]; + /*if ( didinit == 0 ) { for (baseid=0; baseid<=32; baseid++) komodo_userpass(userpass[baseid],CURRENCIES[baseid]); didinit = 1; - } + }*/ if ( ASSETCHAINS_SYMBOL[0] == 0 ) refid = 33; else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; @@ -595,8 +595,32 @@ void komodo_passport_iteration() } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); } + komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime"); + if ( (fp= fopen(fname,"rb")) != 0 ) + { + if ( fread(buf,1,sizeof(buf),fp) == sizeof(buf) ) + { + if ( buf[0] != 0 && buf[0] == buf[1] ) + isrealtime = 1; + } + fclose(fp); + } } - if ( (retstr= komodo_issuemethod(userpass[baseid],(char *)"getinfo",0,port)) != 0 ) + else + { + komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime"); + if ( (fp= fopen(fname,"wb")) != 0 ) + { + buf[0] = (uint32_t)chainActive.Tip()->nHeight; + buf[1] = (uint32_t)komodo_longestchain(); + if ( buf[0] != 0 && buf[0] == buf[1] ) + buf[2] = (uint32_t)time(NULL); + if ( fwrite(buf,1,sizeof(buf),fp) != sizeof(buf) ) + fprintf(stderr,"[%s] %s error writing realtime\n",ASSETCHAINS_SYMBOL,base); + fclose(fp); + } + } + /*if ( (retstr= komodo_issuemethod(userpass[baseid],(char *)"getinfo",0,port)) != 0 ) { if ( (infoobj= cJSON_Parse(retstr)) != 0 ) { @@ -612,7 +636,7 @@ void komodo_passport_iteration() } else printf("[%s] %s (%s)\n",ASSETCHAINS_SYMBOL,base,retstr); free(retstr); - } // else printf("%s port.%u no getinfo\n",base,port); + } // else printf("%s port.%u no getinfo\n",base,port);*/ if ( sp != 0 ) sp->KOMODO_REALTIME = isrealtime * (uint32_t)time(NULL); } From 44a80e607a90b6e9bc2dddcf64c0bc74fa02e0e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 18:57:48 -0300 Subject: [PATCH 081/549] test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b1f20bec4..ecb55aa07 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -556,6 +556,7 @@ void komodo_iteration(char *symbol) } } #else +int32_t komodo_longestchain(); void komodo_passport_iteration() { From 6eb41a2f0b7b9643e522aba709379235cdf42085 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 19:03:56 -0300 Subject: [PATCH 082/549] test --- src/komodo_gateway.h | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ecb55aa07..89e327063 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -560,14 +560,8 @@ int32_t komodo_longestchain(); void komodo_passport_iteration() { - static long lastpos[34],didinit; static char userpass[33][1024]; - FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj,*result; uint16_t port; uint32_t magic,buf[3]; - /*if ( didinit == 0 ) - { - for (baseid=0; baseid<=32; baseid++) - komodo_userpass(userpass[baseid],CURRENCIES[baseid]); - didinit = 1; - }*/ + static long lastpos[34]; static uint64_t prevRTmask; static char userpass[33][1024]; + FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj,*result; uint64_t RTmask = 0; uint16_t port; uint32_t magic,buf[3]; if ( ASSETCHAINS_SYMBOL[0] == 0 ) refid = 33; else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; @@ -602,7 +596,10 @@ void komodo_passport_iteration() if ( fread(buf,1,sizeof(buf),fp) == sizeof(buf) ) { if ( buf[0] != 0 && buf[0] == buf[1] ) + { isrealtime = 1; + RTmask |= (1LL << baseid); + } } fclose(fp); } @@ -615,32 +612,23 @@ void komodo_passport_iteration() buf[0] = (uint32_t)chainActive.Tip()->nHeight; buf[1] = (uint32_t)komodo_longestchain(); if ( buf[0] != 0 && buf[0] == buf[1] ) + { buf[2] = (uint32_t)time(NULL); + RTmask |= (1LL << baseid); + } if ( fwrite(buf,1,sizeof(buf),fp) != sizeof(buf) ) fprintf(stderr,"[%s] %s error writing realtime\n",ASSETCHAINS_SYMBOL,base); fclose(fp); } } - /*if ( (retstr= komodo_issuemethod(userpass[baseid],(char *)"getinfo",0,port)) != 0 ) - { - if ( (infoobj= cJSON_Parse(retstr)) != 0 ) - { - if ( (result= jobj(infoobj,(char *)"result")) != 0 ) - { - blocks = juint(result,(char *)"blocks"); - longest = juint(result,(char *)"longestchain"); - //printf("%s.(%d L%d) ",base,blocks,longest); - if ( blocks > 0 && blocks == longest ) - isrealtime = 1; - } - free_json(infoobj); - } - else printf("[%s] %s (%s)\n",ASSETCHAINS_SYMBOL,base,retstr); - free(retstr); - } // else printf("%s port.%u no getinfo\n",base,port);*/ if ( sp != 0 ) sp->KOMODO_REALTIME = isrealtime * (uint32_t)time(NULL); } + if ( RTmask != prevRTmask ) + { + printf("[%s] new RTmask %llx\n",ASSETCHAINS_SYMBOL,RTmask); + prevRTmask = RTmask; + } } #endif From 2452d1558c278ca3db0dad8e0caae9c2e97fa1d1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 19:06:46 -0300 Subject: [PATCH 083/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 89e327063..12450e399 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -626,7 +626,7 @@ void komodo_passport_iteration() } if ( RTmask != prevRTmask ) { - printf("[%s] new RTmask %llx\n",ASSETCHAINS_SYMBOL,RTmask); + printf("[%s] new RTmask %llx\n",ASSETCHAINS_SYMBOL,(long long)RTmask); prevRTmask = RTmask; } } From fe0210c0d7e7aff4cd5adb32dd36f8d34a0c2d23 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 19:10:21 -0300 Subject: [PATCH 084/549] test --- src/komodo_gateway.h | 2 +- src/komodo_utils.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 12450e399..08d7a2b6b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -595,7 +595,7 @@ void komodo_passport_iteration() { if ( fread(buf,1,sizeof(buf),fp) == sizeof(buf) ) { - if ( buf[0] != 0 && buf[0] == buf[1] ) + if ( buf[0] != 0 && buf[0] == buf[1] && buf[2] > time(NULL)-60 ) { isrealtime = 1; RTmask |= (1LL << baseid); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index cdb565722..e071d5232 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1363,13 +1363,11 @@ int32_t komodo_userpass(char *userpass,char *symbol) sprintf(confname,"komodo.conf"); else sprintf(confname,"%s.conf",symbol); komodo_statefname(fname,symbol,confname); - printf("[%s] conf.(%s)\n",symbol,fname); if ( (fp= fopen(fname,"rb")) != 0 ) { komodo_userpass(username,password,fp); sprintf(userpass,"%s:%s",username,password); fclose(fp); - printf("[%s] conf.(%s) %s\n",symbol,fname,userpass); return((int32_t)strlen(userpass)); } return(-1); From 209dc96ca6e002943179342f23d0da6822d4e842 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 19:13:26 -0300 Subject: [PATCH 085/549] test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 08d7a2b6b..0206bc318 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -599,10 +599,10 @@ void komodo_passport_iteration() { isrealtime = 1; RTmask |= (1LL << baseid); - } - } + } else fprintf(stderr,"%s not RT\n",base); + } else fprintf(stderr,"%s size error RT\n",base); fclose(fp); - } + } else fprintf(stderr,"%s open error RT\n",base); } else { From f789eddea98d91d9a5089c60b240f2db84b49d70 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 19:19:16 -0300 Subject: [PATCH 086/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0206bc318..1e2afd236 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -570,9 +570,9 @@ void komodo_passport_iteration() { sp = 0; isrealtime = 0; + base = (char *)CURRENCIES[baseid]; if ( baseid+1 != refid ) { - base = (char *)CURRENCIES[baseid]; komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"komodostate"); komodo_nameset(symbol,dest,base); port = komodo_port(base,10,&magic) + 1; @@ -619,7 +619,7 @@ void komodo_passport_iteration() if ( fwrite(buf,1,sizeof(buf),fp) != sizeof(buf) ) fprintf(stderr,"[%s] %s error writing realtime\n",ASSETCHAINS_SYMBOL,base); fclose(fp); - } + } else fprintf(stderr,"%s create error RT\n",base); } if ( sp != 0 ) sp->KOMODO_REALTIME = isrealtime * (uint32_t)time(NULL); From 140fccf8b7c7e778a09bd16b87640a19b43f29e5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 19:22:02 -0300 Subject: [PATCH 087/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1e2afd236..d2ffc4ff9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -599,7 +599,7 @@ void komodo_passport_iteration() { isrealtime = 1; RTmask |= (1LL << baseid); - } else fprintf(stderr,"%s not RT\n",base); + } //else fprintf(stderr,"%s not RT\n",base); } else fprintf(stderr,"%s size error RT\n",base); fclose(fp); } else fprintf(stderr,"%s open error RT\n",base); @@ -626,7 +626,7 @@ void komodo_passport_iteration() } if ( RTmask != prevRTmask ) { - printf("[%s] new RTmask %llx\n",ASSETCHAINS_SYMBOL,(long long)RTmask); + printf("[%s] new RTmask %llx\n",ASSETCHAINS_SYMBOL[0]!=0?ASSETCHAINS_SYMBOL:"KMD",(long long)RTmask); prevRTmask = RTmask; } } From d7529fce685d508fbd5db048dc1a7bdb92ae7ae2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 19:34:49 -0300 Subject: [PATCH 088/549] test --- src/komodo_gateway.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d2ffc4ff9..32ac485d0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -560,7 +560,7 @@ int32_t komodo_longestchain(); void komodo_passport_iteration() { - static long lastpos[34]; static uint64_t prevRTmask; static char userpass[33][1024]; + static long lastpos[34]; static uint64_t prevRTmask,lastRTheight; static char userpass[33][1024]; FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj,*result; uint64_t RTmask = 0; uint16_t port; uint32_t magic,buf[3]; if ( ASSETCHAINS_SYMBOL[0] == 0 ) refid = 33; @@ -604,12 +604,13 @@ void komodo_passport_iteration() fclose(fp); } else fprintf(stderr,"%s open error RT\n",base); } - else + else if ( chainActive.Tip()->nHeight != lastRTheight ) { + lastRTheight = chainActive.Tip()->nHeight; komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime"); if ( (fp= fopen(fname,"wb")) != 0 ) { - buf[0] = (uint32_t)chainActive.Tip()->nHeight; + buf[0] = (uint32_t)lastRTheight; buf[1] = (uint32_t)komodo_longestchain(); if ( buf[0] != 0 && buf[0] == buf[1] ) { From 84ee07e9263f5b5270cc38b95cc5b4c95ab28cea Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 19:38:23 -0300 Subject: [PATCH 089/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 32ac485d0..81d6f89f0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -604,7 +604,7 @@ void komodo_passport_iteration() fclose(fp); } else fprintf(stderr,"%s open error RT\n",base); } - else if ( chainActive.Tip()->nHeight != lastRTheight ) + else //if ( chainActive.Tip()->nHeight != lastRTheight ) { lastRTheight = chainActive.Tip()->nHeight; komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime"); From 4411f74f0fb36bea9ef3f7056e9993d0e757a423 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 08:52:35 -0300 Subject: [PATCH 090/549] test --- src/fiat-cli | 1 + src/fiat/revs | 2 ++ 2 files changed, 3 insertions(+) create mode 100755 src/fiat/revs diff --git a/src/fiat-cli b/src/fiat-cli index 8dd0fc02b..1a4004be7 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -31,3 +31,4 @@ echo thb; fiat/thb $1 $2 $3 $4 echo try; fiat/try $1 $2 $3 $4 echo usd; fiat/usd $1 $2 $3 $4 echo zar; fiat/zar $1 $2 $3 $4 +echo revs; fiat/revs $1 $2 $3 $4 diff --git a/src/fiat/revs b/src/fiat/revs new file mode 100755 index 000000000..5c8782ae5 --- /dev/null +++ b/src/fiat/revs @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=REVS $1 $2 $3 $4 From 635dd34d59d982e728be25f0ee925fbf01dad9f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 10:15:01 -0300 Subject: [PATCH 091/549] test --- src/komodo.h | 1 - src/komodo_gateway.h | 33 +++++++++++++++++---------------- src/komodo_structs.h | 1 + src/miner.cpp | 6 +++--- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 58dc8bb58..7e8202be0 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -17,7 +17,6 @@ #define H_KOMODO_H // Todo: -// 0. optimize assetchains // 1. error check fiat redeem amounts // 2. net balance limiter // 3. verify: reorgs diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 81d6f89f0..3b1aa7e16 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -147,9 +147,10 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint8_t return(n); } -int32_t komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *base,int32_t tokomodo) +int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t tokomodo) { - struct pax_transaction *pax,*tmp; char symbol[16]; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,len=0,opretlen=0,numvouts=1; + struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; + sp = komodo_stateptr(symbol,dest); strcpy(symbol,base); PENDING_KOMODO_TX = 0; if ( tokomodo == 0 ) @@ -157,10 +158,11 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,cha else opcode = 'X'; HASH_ITER(hh,PAX,pax,tmp) { - if ( pax->marked != 0 ) + printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); + if ( pax->marked != 0 || strcmp(pax->symbol,ASSETCHAINS_SYMBOL) != 0 ) continue; if ( ASSETCHAINS_SYMBOL[0] != 0 ) - printf("pax.%p marked.%d %.8f -> %.8f\n",pax,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); + printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); txNew->vout.resize(numvouts+1); txNew->vout[numvouts].nValue = (opcode == 'I') ? pax->fiatoshis : pax->komodoshis; txNew->vout[numvouts].scriptPubKey.resize(25); @@ -186,9 +188,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,cha len += iguana_rwnum(1,&data[len],sizeof(pax->fiatoshis),&pax->fiatoshis); len += iguana_rwnum(1,&data[len],sizeof(pax->height),&pax->height); len += iguana_rwnum(1,&data[len],sizeof(pax->otherheight),&pax->otherheight); - if ( pax->shortflag != 0 ) - data[len++] = '-'; - for (i=0; pax->symbol[i]!=0&&i<3; i++) + for (i=0; pax->symbol[i]!=0&&i<3; i++) // must be 3 letter currency data[len++] = pax->symbol[i]; data[len++] = 0; PENDING_KOMODO_TX += pax->komodoshis; @@ -560,11 +560,12 @@ int32_t komodo_longestchain(); void komodo_passport_iteration() { - static long lastpos[34]; static uint64_t prevRTmask,lastRTheight; static char userpass[33][1024]; - FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj,*result; uint64_t RTmask = 0; uint16_t port; uint32_t magic,buf[3]; + static long lastpos[34]; static char userpass[33][1024]; + FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3]; cJSON *infoobj,*result; uint64_t RTmask = 0; + refsp = komodo_stateptr(symbol,dest); if ( ASSETCHAINS_SYMBOL[0] == 0 ) refid = 33; - else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; + else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=0; baseid<=32; baseid++) { @@ -599,12 +600,13 @@ void komodo_passport_iteration() { isrealtime = 1; RTmask |= (1LL << baseid); + memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1])); } //else fprintf(stderr,"%s not RT\n",base); } else fprintf(stderr,"%s size error RT\n",base); fclose(fp); } else fprintf(stderr,"%s open error RT\n",base); } - else //if ( chainActive.Tip()->nHeight != lastRTheight ) + else { lastRTheight = chainActive.Tip()->nHeight; komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime"); @@ -616,6 +618,9 @@ void komodo_passport_iteration() { buf[2] = (uint32_t)time(NULL); RTmask |= (1LL << baseid); + memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1])); + if ( refid != 0 ) + memcpy(refsp->RTbufs[0],buf,sizeof(refsp->RTbufs[0])); } if ( fwrite(buf,1,sizeof(buf),fp) != sizeof(buf) ) fprintf(stderr,"[%s] %s error writing realtime\n",ASSETCHAINS_SYMBOL,base); @@ -625,11 +630,7 @@ void komodo_passport_iteration() if ( sp != 0 ) sp->KOMODO_REALTIME = isrealtime * (uint32_t)time(NULL); } - if ( RTmask != prevRTmask ) - { - printf("[%s] new RTmask %llx\n",ASSETCHAINS_SYMBOL[0]!=0?ASSETCHAINS_SYMBOL:"KMD",(long long)RTmask); - prevRTmask = RTmask; - } + refsp->RTmask = RTmask; } #endif diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 89ebcab33..8797dfb4d 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -74,4 +74,5 @@ struct komodo_state uint32_t KOMODO_REALTIME,SAVEDTIMESTAMP; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS; struct komodo_event **Komodo_events; int32_t Komodo_numevents; + uint32_t RTbufs[64][3]; uint64_t RTmask; }; diff --git a/src/miner.cpp b/src/miner.cpp index 04c31633d..e74c07702 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -110,7 +110,7 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]); int32_t komodo_pax_opreturn(uint8_t *opret,int32_t maxsize); uint64_t komodo_paxtotal(); int32_t komodo_is_issuer(); -int32_t komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *symbol,int32_t tokomodo); +int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *symbol,int32_t tokomodo); int32_t komodo_isrealtime(int32_t *kmdheightp,char *target); CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) @@ -376,7 +376,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( ASSETCHAINS_SYMBOL[0] == 0 ) { int32_t i,opretlen; uint8_t opret[256],*ptr; - if ( komodo_gateway_deposits(&txNew,0,(char *)"EUR",1) == 0 ) + if ( komodo_gateway_deposits(&txNew,(char *)"KMD",1) == 0 ) { if ( (opretlen= komodo_pax_opreturn(opret,sizeof(opret))) > 0 ) { @@ -392,7 +392,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) } else if ( komodo_is_issuer() != 0 ) { - komodo_gateway_deposits(&txNew,0,ASSETCHAINS_SYMBOL,0); + komodo_gateway_deposits(&txNew,ASSETCHAINS_SYMBOL,0); fprintf(stderr,"txNew numvouts.%d\n",(int32_t)txNew.vout.size()); } pblock->vtx[0] = txNew; From 48e96ba114d1e103665b551e55e113fc69cb2cee Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 10:18:28 -0300 Subject: [PATCH 092/549] test --- src/komodo_gateway.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3b1aa7e16..7303e59e3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -149,12 +149,22 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint8_t int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t tokomodo) { - struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; + struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,baseid,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t mask; sp = komodo_stateptr(symbol,dest); strcpy(symbol,base); PENDING_KOMODO_TX = 0; if ( tokomodo == 0 ) + { opcode = 'I'; + if ( (baseid= komodo_baseid(base)) < 0 ) + return(0); + mask = (1LL << 32) | (1LL << (baseid+1)); + if ( (sp->RTmask & mask) != mask ) + { + printf("%s not RT mask.%llx vs RTmask.%llx\n",ASSETCHAINS_SYMBOL,(long long)mask,(long long)sp->RTmask); + return(0); + } + } else opcode = 'X'; HASH_ITER(hh,PAX,pax,tmp) { From 30376a70dfcd7b3242a1d3b4755416b476a72a69 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 10:20:03 -0300 Subject: [PATCH 093/549] test --- src/komodo_gateway.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7303e59e3..3b1a1845d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -209,8 +209,6 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to } if ( numvouts > 1 ) { - if ( shortflag != 0 ) - data[len++] = '-'; if ( tokomodo != 0 ) strcpy(symbol,(char *)"KMD"); for (i=0; symbol[i]!=0; i++) @@ -586,7 +584,7 @@ void komodo_passport_iteration() { komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"komodostate"); komodo_nameset(symbol,dest,base); - port = komodo_port(base,10,&magic) + 1; + //port = komodo_port(base,10,&magic) + 1; if ( (fp= fopen(fname,"rb")) != 0 && (sp= komodo_stateptrget(symbol)) != 0 ) { //printf("refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); @@ -618,11 +616,10 @@ void komodo_passport_iteration() } else { - lastRTheight = chainActive.Tip()->nHeight; komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime"); if ( (fp= fopen(fname,"wb")) != 0 ) { - buf[0] = (uint32_t)lastRTheight; + buf[0] = (uint32_t)chainActive.Tip()->nHeight; buf[1] = (uint32_t)komodo_longestchain(); if ( buf[0] != 0 && buf[0] == buf[1] ) { From 90b09456312ceb28d321dc040e1c992aa5c558e2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 10:34:14 -0300 Subject: [PATCH 094/549] test --- src/komodo_gateway.h | 188 --------------------------------------- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 1 insertion(+), 189 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3b1a1845d..c99807b8d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -377,193 +377,6 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 return(typestr); } -#ifdef pollmethod -void komodo_gateway_voutupdate(char *symbol,int32_t isspecial,int32_t height,int32_t txi,bits256 txid,int32_t vout,int32_t numvouts,uint64_t value,uint8_t *script,int32_t len) -{ - int32_t i,opretlen,offset = 0; uint256 zero,utxid; const char *typestr; - typestr = "unknown"; - memcpy(&utxid,&txid,sizeof(utxid)); - if ( script[offset++] == 0x6a ) - { - offset += komodo_scriptitemlen(&opretlen,&script[offset]); - if ( isspecial != 0 && len >= offset+32*2+4 && strcmp((char *)&script[offset+32*2+4],ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL) == 0 ) - typestr = "notarized"; - else if ( txi == 0 && vout == 1 && opretlen == 149 ) - { - typestr = "pricefeed"; - komodo_paxpricefeed(height,&script[offset],opretlen); - //printf("height.%d pricefeed len.%d\n",height,opretlen); - } - else komodo_stateupdate(height,0,0,0,utxid,0,0,0,0,0,0,value,&script[offset],opretlen,vout); - } - else if ( numvouts >= KOMODO_MINRATIFY ) - typestr = "ratify"; -} - -int32_t komodo_gateway_tx(char *symbol,int32_t height,int32_t txi,char *txidstr,uint32_t port) -{ - char *retstr,params[256],*hexstr; uint8_t script[10000]; cJSON *oldpub,*newpub,*json,*result,*vouts,*item,*sobj; int32_t vout,n,len,isspecial,retval = -1; uint64_t value; bits256 txid; - sprintf(params,"[\"%s\", 1]",txidstr); - if ( (retstr= komodo_issuemethod((char *)"getrawtransaction",params,port)) != 0 ) - { - if ( (json= cJSON_Parse(retstr)) != 0 ) - { - if ( (result= jobj(json,(char *)"result")) != 0 ) - { - oldpub = jobj(result,(char *)"vpub_old"); - newpub = jobj(result,(char *)"vpub_new"); - retval = 0; - if ( oldpub == 0 && newpub == 0 && (vouts= jarray(&n,result,(char *)"vout")) != 0 ) - { - isspecial = 0; - txid = jbits256(result,(char *)"txid"); - for (vout=0; vout> 1; - if ( vout == 0 && ((memcmp(&hexstr[2],CRYPTO777_PUBSECPSTR,66) == 0 && len == 35) || (memcmp(&hexstr[6],CRYPTO777_RMD160STR,40) == 0 && len == 25)) ) - isspecial = 1; - else if ( len <= sizeof(script) ) - { - decode_hex(script,len,hexstr); - komodo_gateway_voutupdate(symbol,isspecial,height,txi,txid,vout,n,value,script,len); - } - } - } - } - } - } else printf("error getting txids.(%s) %p\n",retstr,result); - free_json(json); - } - free(retstr); - } - return(retval); -} - -int32_t komodo_gateway_block(char *symbol,int32_t height,uint16_t port) -{ - char *retstr,*retstr2,params[128],*txidstr; int32_t i,n,retval = -1; cJSON *json,*tx=0,*result=0,*result2; - sprintf(params,"[%d]",height); - if ( (retstr= komodo_issuemethod((char *)"getblockhash",params,port)) != 0 ) - { - if ( (result= cJSON_Parse(retstr)) != 0 ) - { - if ( (txidstr= jstr(result,(char *)"result")) != 0 && strlen(txidstr) == 64 ) - { - sprintf(params,"[\"%s\"]",txidstr); - if ( (retstr2= komodo_issuemethod((char *)"getblock",params,port)) != 0 ) - { - //printf("getblock.(%s)\n",retstr2); - if ( (json= cJSON_Parse(retstr2)) != 0 ) - { - if ( (result2= jobj(json,(char *)"result")) != 0 && (tx= jarray(&n,result2,(char *)"tx")) != 0 ) - { - for (i=0; i= kmdheight ) - sp->KOMODO_REALTIME = (uint32_t)time(NULL); - } - free_json(infoobj); - } - free(retstr); - } - else - { - printf("error from %s\n",symbol); - sleep(30); - } -} - -void komodo_iteration(char *symbol) -{ - char *retstr,*base,*coinaddr,*txidstr,cmd[512]; uint64_t value,fiatoshis; cJSON *array,*item; int32_t i,n,vout,shortflag,height,fiatheight; uint256 txid; uint8_t rmd160[20],addrtype; - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { - sprintf(cmd,"{\"agent\":\"dpow\",\"method\":\"pending\",\"fiat\":\"%s\"}",symbol); - if ( (retstr= issue_curl(cmd)) != 0 ) - { - if ( (array= cJSON_Parse(retstr)) != 0 ) - { - if ( (n= cJSON_GetArraySize(array)) > 0 ) - { - for (i=0; i 0 && height > 0 ) - { - fiatoshis = jdouble(item,base) * COIN; - decode_hex((uint8_t *)&txid,sizeof(txid),txidstr); - bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr); - komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,height,fiatheight); - } - } - } - } - //printf("retstr.(%s)\n",retstr); - free(retstr); - } - } -} -#else int32_t komodo_longestchain(); void komodo_passport_iteration() @@ -639,5 +452,4 @@ void komodo_passport_iteration() } refsp->RTmask = RTmask; } -#endif diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c0ae4f319..fe3b2a854 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -492,7 +492,7 @@ Value paxdeposit(const Array& params, bool fHelp) if (!EnsureWalletIsAvailable(fHelp)) return Value::null; if (fHelp || params.size() != 3) - throw runtime_error("paxdeposit \"address\" [-]fiatoshis \"base\"\nnegative fiatoshis means a short position, long position capped at 100% gain"); + throw runtime_error("paxdeposit \"address\" fiatoshis base"); LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) From f1db88ea001b9a3c286e9ad020b8c3b413abed54 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 10:54:09 -0300 Subject: [PATCH 095/549] test --- src/komodo_gateway.h | 56 ++++++++++++++++++++++---------------------- src/komodo_structs.h | 2 +- src/komodo_utils.h | 16 +++++++++++-- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c99807b8d..0c065ed67 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -15,21 +15,6 @@ // paxdeposit equivalent in reverse makes opreturn and KMD does the same in reverse -uint64_t komodo_paxtotal() -{ - struct pax_transaction *pax,*tmp; uint64_t total = 0; - HASH_ITER(hh,PAX,pax,tmp) - { - if ( pax->marked == 0 ) - { - if ( komodo_is_issuer() != 0 ) - total += pax->fiatoshis; - else total += pax->komodoshis; - } - } - return(total); -} - struct pax_transaction *komodo_paxfind(struct pax_transaction *space,uint256 txid,uint16_t vout) { struct pax_transaction *pax; @@ -68,7 +53,8 @@ struct pax_transaction *komodo_paxmark(int32_t height,struct pax_transaction *sp void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight) // assetchain context { - struct pax_transaction *pax; int32_t addflag = 0; + struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char symbol[16],dest[16]; + sp = komodo_stateptr(symbol,dest); pthread_mutex_lock(&komodo_mutex); HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); if ( pax == 0 ) @@ -95,7 +81,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char pax->fiatoshis = fiatoshis; memcpy(pax->rmd160,rmd160,20); pax->height = height; - pax->otherheight = otherheight; + pax->otherheight = sp->CURRENT_HEIGHT;//otherheight; if ( pax->marked == 0 ) { if ( addflag != 0 ) @@ -147,23 +133,36 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint8_t return(n); } +uint64_t komodo_paxtotal() +{ + struct pax_transaction *pax,*tmp; uint64_t total = 0; + if ( komodo_isrealtime(&ht,ASSETCHAINS_SYMBOL) == 0 ) + return(0); + HASH_ITER(hh,PAX,pax,tmp) + { + printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); + if ( pax->marked == 0 ) + { + if ( komodo_is_issuer() != 0 ) + total += pax->fiatoshis; + else total += pax->komodoshis; + } + } + printf("paxtotal %.8f\n",dstr(total)); + return(total); +} + int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t tokomodo) { - struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,baseid,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t mask; + struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t mask; sp = komodo_stateptr(symbol,dest); strcpy(symbol,base); PENDING_KOMODO_TX = 0; if ( tokomodo == 0 ) { opcode = 'I'; - if ( (baseid= komodo_baseid(base)) < 0 ) + if ( komodo_isrealtime(&ht,ASSETCHAINS_SYMBOL) == 0 ) return(0); - mask = (1LL << 32) | (1LL << (baseid+1)); - if ( (sp->RTmask & mask) != mask ) - { - printf("%s not RT mask.%llx vs RTmask.%llx\n",ASSETCHAINS_SYMBOL,(long long)mask,(long long)sp->RTmask); - return(0); - } } else opcode = 'X'; HASH_ITER(hh,PAX,pax,tmp) @@ -337,7 +336,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 for (i=0; i<33; i++) printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); - if ( value >= checktoshis || (seed == 0 && diff < .01) ) + if ( value == checktoshis )//value >= checktoshis || (seed == 0 && diff < .01) ) { if ( komodo_paxfind(&space,txid,vout) == 0 ) { @@ -417,6 +416,7 @@ void komodo_passport_iteration() { if ( fread(buf,1,sizeof(buf),fp) == sizeof(buf) ) { + sp->CURRENT_HEIGHT = buf[0]; if ( buf[0] != 0 && buf[0] == buf[1] && buf[2] > time(NULL)-60 ) { isrealtime = 1; @@ -447,8 +447,8 @@ void komodo_passport_iteration() fclose(fp); } else fprintf(stderr,"%s create error RT\n",base); } - if ( sp != 0 ) - sp->KOMODO_REALTIME = isrealtime * (uint32_t)time(NULL); + if ( sp != 0 && isrealtime == 0 ) + refsp->RTbufs[0][2] = 0; } refsp->RTmask = RTmask; } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 8797dfb4d..4d09d5a81 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -71,7 +71,7 @@ struct komodo_state { uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID; int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT; - uint32_t KOMODO_REALTIME,SAVEDTIMESTAMP; + uint32_t SAVEDTIMESTAMP; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS; struct komodo_event **Komodo_events; int32_t Komodo_numevents; uint32_t RTbufs[64][3]; uint64_t RTmask; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index e071d5232..7e187d835 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1514,12 +1514,24 @@ struct komodo_state *komodo_stateptr(char *symbol,char *dest) int32_t komodo_isrealtime(int32_t *kmdheightp,char *target) { - char symbol[16],dest[16]; struct komodo_state *sp; + char symbol[16],dest[16]; int32_t baseid; uint64_t mask; struct komodo_state *sp; *kmdheightp = 0; + if ( target == 0 || target[0] == 0 ) + target = (char *)"KMD"; if ( (sp= komodo_stateptrget(target)) != 0 ) { + if ( (baseid= komodo_baseid(target)) < 0 ) + return(0); + mask = (1LL << 32) | (1LL << (baseid+1)); + if ( (sp->RTmask & mask) != mask ) + { + printf("%s not RT mask.%llx vs RTmask.%llx\n",target,(long long)mask,(long long)sp->RTmask); + return(0); + } *kmdheightp = sp->CURRENT_HEIGHT; - return(sp->KOMODO_REALTIME); + return(sp->RTbufs[0][2]); } return(0); } + + From bffa91b20df0537f5ce2e20d15bd6c6d0141ff52 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 10:56:25 -0300 Subject: [PATCH 096/549] test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0c065ed67..c9a92ac43 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -53,8 +53,8 @@ struct pax_transaction *komodo_paxmark(int32_t height,struct pax_transaction *sp void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight) // assetchain context { - struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char symbol[16],dest[16]; - sp = komodo_stateptr(symbol,dest); + struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16]; + sp = komodo_stateptr(str,dest); pthread_mutex_lock(&komodo_mutex); HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); if ( pax == 0 ) @@ -135,7 +135,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint8_t uint64_t komodo_paxtotal() { - struct pax_transaction *pax,*tmp; uint64_t total = 0; + struct pax_transaction *pax,*tmp; int32_t ht; uint64_t total = 0; if ( komodo_isrealtime(&ht,ASSETCHAINS_SYMBOL) == 0 ) return(0); HASH_ITER(hh,PAX,pax,tmp) @@ -423,7 +423,7 @@ void komodo_passport_iteration() RTmask |= (1LL << baseid); memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1])); } //else fprintf(stderr,"%s not RT\n",base); - } else fprintf(stderr,"%s size error RT\n",base); + } //else fprintf(stderr,"%s size error RT\n",base); fclose(fp); } else fprintf(stderr,"%s open error RT\n",base); } From b4116bb6f6225376b8986f2e62bf8c172dc45ba4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 10:57:44 -0300 Subject: [PATCH 097/549] test --- src/komodo_globals.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index f92b72248..83b8a0ae9 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -21,6 +21,7 @@ void komodo_init(int32_t height); void komodo_assetchain_pubkeys(char *jsonstr); int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33); int32_t komodo_isrealtime(int32_t *kmdheightp,char *target); +uint64_t komodo_paxtotal(); pthread_mutex_t komodo_mutex; From 5461e2431dfe5d48023ee053cb3b4beaa92fe5b8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 11:41:21 -0300 Subject: [PATCH 098/549] test --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 7e187d835..96e6a9905 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1522,7 +1522,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp,char *target) { if ( (baseid= komodo_baseid(target)) < 0 ) return(0); - mask = (1LL << 32) | (1LL << (baseid+1)); + mask = (1LL << 32) | (1LL << baseid); if ( (sp->RTmask & mask) != mask ) { printf("%s not RT mask.%llx vs RTmask.%llx\n",target,(long long)mask,(long long)sp->RTmask); From 48a3cd18c9c829e9f0e0298e2fcd8b3e4f27e1ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 11:50:57 -0300 Subject: [PATCH 099/549] test --- src/komodo_events.h | 2 +- src/komodo_gateway.h | 6 +++--- src/komodo_globals.h | 2 +- src/komodo_utils.h | 12 ++++-------- src/miner.cpp | 6 +++--- src/wallet/rpcwallet.cpp | 4 ++-- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index b11b1e101..d7411737f 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -112,7 +112,7 @@ void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height) { if ( ep->height < height ) break; - printf("[%s] undo %s event.%c ht.%d for rewind.%d\n",ASSETCHAINS_SYMBOL,symbol,ep->type,ep->height,height); + //printf("[%s] undo %s event.%c ht.%d for rewind.%d\n",ASSETCHAINS_SYMBOL,symbol,ep->type,ep->height,height); komodo_event_undo(sp,ep); sp->Komodo_numevents--; } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c9a92ac43..f36c71e98 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -136,7 +136,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint8_t uint64_t komodo_paxtotal() { struct pax_transaction *pax,*tmp; int32_t ht; uint64_t total = 0; - if ( komodo_isrealtime(&ht,ASSETCHAINS_SYMBOL) == 0 ) + if ( komodo_isrealtime(&ht) == 0 ) return(0); HASH_ITER(hh,PAX,pax,tmp) { @@ -161,7 +161,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to if ( tokomodo == 0 ) { opcode = 'I'; - if ( komodo_isrealtime(&ht,ASSETCHAINS_SYMBOL) == 0 ) + if ( komodo_isrealtime(&ht) == 0 ) return(0); } else opcode = 'X'; @@ -437,7 +437,7 @@ void komodo_passport_iteration() if ( buf[0] != 0 && buf[0] == buf[1] ) { buf[2] = (uint32_t)time(NULL); - RTmask |= (1LL << baseid); + RTmask |= (1LL << baseid) | 1; memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1])); if ( refid != 0 ) memcpy(refsp->RTbufs[0],buf,sizeof(refsp->RTbufs[0])); diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 83b8a0ae9..9415a16d6 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -20,7 +20,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) void komodo_init(int32_t height); void komodo_assetchain_pubkeys(char *jsonstr); int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33); -int32_t komodo_isrealtime(int32_t *kmdheightp,char *target); +int32_t komodo_isrealtime(int32_t *kmdheightp); uint64_t komodo_paxtotal(); pthread_mutex_t komodo_mutex; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 96e6a9905..7f23d5af7 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1512,17 +1512,13 @@ struct komodo_state *komodo_stateptr(char *symbol,char *dest) return(komodo_stateptrget(symbol)); } -int32_t komodo_isrealtime(int32_t *kmdheightp,char *target) +int32_t komodo_isrealtime(int32_t *kmdheightp) { - char symbol[16],dest[16]; int32_t baseid; uint64_t mask; struct komodo_state *sp; + char symbol[16],dest[16]; uint64_t mask; struct komodo_state *sp; *kmdheightp = 0; - if ( target == 0 || target[0] == 0 ) - target = (char *)"KMD"; - if ( (sp= komodo_stateptrget(target)) != 0 ) + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) { - if ( (baseid= komodo_baseid(target)) < 0 ) - return(0); - mask = (1LL << 32) | (1LL << baseid); + mask = (1LL << 32) | 1LL; if ( (sp->RTmask & mask) != mask ) { printf("%s not RT mask.%llx vs RTmask.%llx\n",target,(long long)mask,(long long)sp->RTmask); diff --git a/src/miner.cpp b/src/miner.cpp index e74c07702..367584592 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -111,7 +111,7 @@ int32_t komodo_pax_opreturn(uint8_t *opret,int32_t maxsize); uint64_t komodo_paxtotal(); int32_t komodo_is_issuer(); int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *symbol,int32_t tokomodo); -int32_t komodo_isrealtime(int32_t *kmdheightp,char *target); +int32_t komodo_isrealtime(int32_t *kmdheightp); CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { @@ -123,12 +123,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) CBlock *pblock = &pblocktemplate->block; // pointer for convenience if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= 100 ) { - isrealtime = komodo_isrealtime(&kmdheight,ASSETCHAINS_SYMBOL); + isrealtime = komodo_isrealtime(&kmdheight); fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),isrealtime,KOMODO_ON_DEMAND); while ( KOMODO_ON_DEMAND == 0 ) { deposits = komodo_paxtotal(); - if ( KOMODO_INITDONE == 0 || komodo_isrealtime(&kmdheight,ASSETCHAINS_SYMBOL) == 0 ) + if ( KOMODO_INITDONE == 0 || komodo_isrealtime(&kmdheight) == 0 ) { //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fe3b2a854..b96b0a48a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -481,7 +481,7 @@ int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_ extern char ASSETCHAINS_SYMBOL[16]; int32_t komodo_is_issuer(); int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); -int32_t komodo_isrealtime(int32_t *kmdheightp,char *target); +int32_t komodo_isrealtime(int32_t *kmdheightp); Value paxdeposit(const Array& params, bool fHelp) { @@ -529,7 +529,7 @@ Value paxwithdraw(const Array& params, bool fHelp) return 0; if (fHelp || params.size() != 2) throw runtime_error("paxwithdraw \"address\" fiatamount"); - if ( komodo_isrealtime(&kmdheight,(char *)"KMD") == 0 ) + if ( komodo_isrealtime(&kmdheight) == 0 ) return(0); LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(params[0].get_str()); From e557df4c1d74265f09ce469267ebc7fb1043f937 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 11:52:19 -0300 Subject: [PATCH 100/549] test --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 7f23d5af7..e4b80db04 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1521,7 +1521,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp) mask = (1LL << 32) | 1LL; if ( (sp->RTmask & mask) != mask ) { - printf("%s not RT mask.%llx vs RTmask.%llx\n",target,(long long)mask,(long long)sp->RTmask); + printf("%s not RT mask.%llx vs RTmask.%llx\n",ASSETCHAINS_SYMBOL,(long long)mask,(long long)sp->RTmask); return(0); } *kmdheightp = sp->CURRENT_HEIGHT; From 50373c3d53b30857aae0580170a9c4b01daf2fdd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 11:59:36 -0300 Subject: [PATCH 101/549] test --- src/komodo_utils.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index e4b80db04..31cd4e8d8 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1514,11 +1514,13 @@ struct komodo_state *komodo_stateptr(char *symbol,char *dest) int32_t komodo_isrealtime(int32_t *kmdheightp) { - char symbol[16],dest[16]; uint64_t mask; struct komodo_state *sp; + char symbol[16],dest[16]; int32_t baseid; uint64_t mask; struct komodo_state *sp; *kmdheightp = 0; if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) { - mask = (1LL << 32) | 1LL; + if ( (baseid= komodo_baseid(symbol)) < 0 ) + return(0); + mask = (1LL << 32) | (1LL << baseid); if ( (sp->RTmask & mask) != mask ) { printf("%s not RT mask.%llx vs RTmask.%llx\n",ASSETCHAINS_SYMBOL,(long long)mask,(long long)sp->RTmask); From 4fe186b7db1d9f6cd69195b29dccbf0ad9255d18 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 12:03:56 -0300 Subject: [PATCH 102/549] test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 367584592..722042db6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -128,9 +128,9 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) while ( KOMODO_ON_DEMAND == 0 ) { deposits = komodo_paxtotal(); - if ( KOMODO_INITDONE == 0 || komodo_isrealtime(&kmdheight) == 0 ) + if ( KOMODO_INITDONE == 0 || (isrealtime= komodo_isrealtime(&kmdheight)) == 0 ) { - //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN); + fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f ht.%d\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN,kmdheight); } else if ( deposits != 0 ) break; From 2f344fd0cb5432bc34a0845db3a8ce9442d7bf5a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 12:11:14 -0300 Subject: [PATCH 103/549] test --- src/komodo_utils.h | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 31cd4e8d8..8d039fa54 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1514,22 +1514,10 @@ struct komodo_state *komodo_stateptr(char *symbol,char *dest) int32_t komodo_isrealtime(int32_t *kmdheightp) { - char symbol[16],dest[16]; int32_t baseid; uint64_t mask; struct komodo_state *sp; - *kmdheightp = 0; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - if ( (baseid= komodo_baseid(symbol)) < 0 ) - return(0); - mask = (1LL << 32) | (1LL << baseid); - if ( (sp->RTmask & mask) != mask ) - { - printf("%s not RT mask.%llx vs RTmask.%llx\n",ASSETCHAINS_SYMBOL,(long long)mask,(long long)sp->RTmask); - return(0); - } - *kmdheightp = sp->CURRENT_HEIGHT; - return(sp->RTbufs[0][2]); - } - return(0); + *kmdheightp = (int32_t)chainActive.Tip()->nHeight; + if ( *kmdheightp != 0 && *kmdheightp == (int32_t)komodo_longestchain() ) + return(1); + else return(0); } From 439e76aeef1531266b18c9cc0c7deb0510796d98 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 12:13:08 -0300 Subject: [PATCH 104/549] test --- src/komodo_gateway.h | 2 -- src/komodo_globals.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f36c71e98..a042f1898 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -376,8 +376,6 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 return(typestr); } -int32_t komodo_longestchain(); - void komodo_passport_iteration() { static long lastpos[34]; static char userpass[33][1024]; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 9415a16d6..a4ab49acf 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -22,6 +22,7 @@ void komodo_assetchain_pubkeys(char *jsonstr); int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33); int32_t komodo_isrealtime(int32_t *kmdheightp); uint64_t komodo_paxtotal(); +int32_t komodo_longestchain(); pthread_mutex_t komodo_mutex; From 8a7f70639af9f42ea8d11ca148324358369d8370 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 12:16:27 -0300 Subject: [PATCH 105/549] test --- src/komodo_bitcoind.h | 8 ++++++++ src/komodo_utils.h | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index fdd383c33..80bb43f79 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -577,3 +577,11 @@ uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 } return(0); } + +int32_t komodo_isrealtime(int32_t *kmdheightp) +{ + *kmdheightp = (int32_t)chainActive.Tip()->nHeight; + if ( *kmdheightp != 0 && *kmdheightp == (int32_t)komodo_longestchain() ) + return(1); + else return(0); +} diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 8d039fa54..c2b4f4b4f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1512,12 +1512,5 @@ struct komodo_state *komodo_stateptr(char *symbol,char *dest) return(komodo_stateptrget(symbol)); } -int32_t komodo_isrealtime(int32_t *kmdheightp) -{ - *kmdheightp = (int32_t)chainActive.Tip()->nHeight; - if ( *kmdheightp != 0 && *kmdheightp == (int32_t)komodo_longestchain() ) - return(1); - else return(0); -} From 106944866d8ff382c235ecfe3d0bcbece8e57e43 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 12:35:00 -0300 Subject: [PATCH 106/549] test --- src/komodo_gateway.h | 2 +- src/miner.cpp | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a042f1898..2c6b8cf73 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -140,7 +140,7 @@ uint64_t komodo_paxtotal() return(0); HASH_ITER(hh,PAX,pax,tmp) { - printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); + //printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); if ( pax->marked == 0 ) { if ( komodo_is_issuer() != 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index 722042db6..51ab93350 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -130,7 +130,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) deposits = komodo_paxtotal(); if ( KOMODO_INITDONE == 0 || (isrealtime= komodo_isrealtime(&kmdheight)) == 0 ) { - fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f ht.%d\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN,kmdheight); + //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f ht.%d\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN,kmdheight); } else if ( deposits != 0 ) break; @@ -604,7 +604,8 @@ void static BitcoinMiner(CWallet *pwallet) } else Mining_start = 0; while (true) { - //fprintf(stderr,"%s start mining loop\n",ASSETCHAINS_SYMBOL); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"%s start mining loop\n",ASSETCHAINS_SYMBOL); // Hash state KOMODO_CHOSEN_ONE = 0; crypto_generichash_blake2b_state state; @@ -631,8 +632,8 @@ void static BitcoinMiner(CWallet *pwallet) solutionTargetChecks.increment(); if ( UintToArith256(pblock->GetHash()) > hashTarget ) { - //if ( ASSETCHAINS_SYMBOL[0] != 0 ) - // printf("missed target\n"); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + printf("missed target\n"); return false; } if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+ROUNDROBIN_DELAY ) @@ -723,24 +724,27 @@ void static BitcoinMiner(CWallet *pwallet) if (vNodes.empty() && chainparams.MiningRequiresPeers()) { if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height >= 100 ) + { + fprintf(stderr,"no nodes, break\n"); break; + } } if ((UintToArith256(pblock->nNonce) & 0xffff) == 0xffff) { if ( ASSETCHAINS_SYMBOL[0] != 0 ) - printf("0xffff, break\n"); + fprintf(stderr,"0xffff, break\n"); break; } if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60) { - //if ( ASSETCHAINS_SYMBOL[0] != 0 ) - // printf("timeout, break\n"); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"timeout, break\n"); break; } if ( pindexPrev != chainActive.Tip() ) { - //if ( ASSETCHAINS_SYMBOL[0] != 0 ) - // printf("Tip advanced, break\n"); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"Tip advanced, break\n"); break; } // Update nNonce and nTime From 986df802e07264b3e675448c89934debe7caf8e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 13:05:46 -0300 Subject: [PATCH 107/549] test --- src/komodo_gateway.h | 38 ++++++++++++++++++++++++-------------- src/miner.cpp | 18 +++++++++--------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2c6b8cf73..8beb7e152 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -51,7 +51,7 @@ struct pax_transaction *komodo_paxmark(int32_t height,struct pax_transaction *sp return(pax); } -void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight) // assetchain context +void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight) // assetchain context { struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16]; sp = komodo_stateptr(str,dest); @@ -76,7 +76,6 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char { strcpy(pax->coinaddr,coinaddr); pax->komodoshis = value; - pax->shortflag = shortflag; strcpy(pax->symbol,symbol); pax->fiatoshis = fiatoshis; memcpy(pax->rmd160,rmd160,20); @@ -101,7 +100,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint8_t int32_t i,n=0,j,len; for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; - if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) // shortflag + if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) { opretbuf++, opretlen--; for (n=len=0; nkomodoshis; } } - printf("paxtotal %.8f\n",dstr(total)); + //printf("paxtotal %.8f\n",dstr(total)); return(total); } @@ -167,10 +163,10 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to else opcode = 'X'; HASH_ITER(hh,PAX,pax,tmp) { - printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); - if ( pax->marked != 0 || strcmp(pax->symbol,ASSETCHAINS_SYMBOL) != 0 ) + //printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); + if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 ) continue; - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + //if ( ASSETCHAINS_SYMBOL[0] != 0 ) printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); txNew->vout.resize(numvouts+1); txNew->vout[numvouts].nValue = (opcode == 'I') ? pax->fiatoshis : pax->komodoshis; @@ -340,7 +336,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( komodo_paxfind(&space,txid,vout) == 0 ) { - komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,kmdheight,height); + komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height); } else printf("duplicate deposit\n"); } } @@ -359,7 +355,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 // printf("%02x",((uint8_t *)&txids[i])[j]); if ( komodo_paxmark(height,&space,txids[i],vouts[i],height) == 0 ) { - komodo_gateway_deposit(0,0,0,0,0,0,txids[i],vouts[i],height,0); + komodo_gateway_deposit(0,0,0,0,0,txids[i],vouts[i],height,0); } else { @@ -368,9 +364,23 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - else if ( tokomodo != 0 && opretbuf[0] == 'X' ) + else if ( tokomodo != 0 && opretbuf[0] == 'W' ) { // verify and update limits + for (i=0; iGetHash()) > hashTarget ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - printf("missed target\n"); + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"missed target\n"); return false; } if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+ROUNDROBIN_DELAY ) { - printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+ROUNDROBIN_DELAY-time(NULL))); + //printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+ROUNDROBIN_DELAY-time(NULL))); sleep(Mining_start+ROUNDROBIN_DELAY-time(NULL)); KOMODO_CHOSEN_ONE = 1; } @@ -725,25 +725,25 @@ void static BitcoinMiner(CWallet *pwallet) { if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height >= 100 ) { - fprintf(stderr,"no nodes, break\n"); + //fprintf(stderr,"no nodes, break\n"); break; } } if ((UintToArith256(pblock->nNonce) & 0xffff) == 0xffff) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"0xffff, break\n"); break; } if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"timeout, break\n"); break; } if ( pindexPrev != chainActive.Tip() ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"Tip advanced, break\n"); break; } From 1ed46112c263305b5e6c8ad1f9e85c959878ba27 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 14:08:31 -0300 Subject: [PATCH 108/549] test --- src/komodo_gateway.h | 73 ++++++++++++++++++++++++-------------------- src/miner.cpp | 4 +-- 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8beb7e152..0d52fabb2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -95,7 +95,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t } } -int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) +int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint8_t *opretbuf,uint64_t *values,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,int32_t opretlen,int32_t iskomodo) { int32_t i,n=0,j,len; for (i=0; i<4; i++) @@ -122,6 +122,13 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint8_t for (i=0; opretbuf[len+i]!=0&&i<3; i++) symbol[i] = opretbuf[len+i]; symbol[i] = 0; + if ( values != 0 && kmdheights != 0 && otherheights != 0 && baseids != 0 ) + { + values[i] = fiatoshis; + kmdheights[i] = height; + otherheights[i] = otherheight; + baseids[i] = komodo_baseid(symbol); + } printf(">>>>>>> iskomodo X: (%s) fiat %.8f kmdheight.%d other.%d\n",symbol,dstr(fiatoshis),height,otherheight); } } @@ -223,7 +230,11 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { - int32_t i,j,n,num,opretlen,offset=1,errs=0,matched=0; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; uint8_t *script,opcode; struct pax_transaction *pax,space; + int32_t i,j,n,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode; uint64_t values[64]; struct pax_transaction *pax,space; + memset(baseids,0xff,sizeof(baseids)); + memset(values,0,sizeof(values)); + memset(kmdheights,0,sizeof(kmdheights)); + memset(otherheights,0,sizeof(otherheights)); n = block.vtx[0].vout.size(); script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data(); if ( n <= 2 || script[0] != 0x6a ) @@ -244,7 +255,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } if ( script[offset] == opcode && opretlen < block.vtx[0].vout[n-1].scriptPubKey.size() ) { - if ( (num= komodo_issued_opreturn(base,txids,vouts,&script[offset],opretlen,opcode == 'X')) > 0 ) + if ( (num= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,&script[offset],opretlen,opcode == 'X')) > 0 ) { for (i=1; i 0 ) + if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,opretbuf,opretlen,0)) > 0 ) { for (i=0; i= 38 ) { - // verify and update limits - for (i=0; ivtx[0] = txNew; pblocktemplate->vTxFees[0] = -nFees; From 03e2d4179405f6200d37dabefee7f8b108535d3a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 14:10:48 -0300 Subject: [PATCH 109/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0d52fabb2..736283400 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -95,7 +95,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t } } -int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint8_t *opretbuf,uint64_t *values,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,int32_t opretlen,int32_t iskomodo) +int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint64_t *values,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) { int32_t i,n=0,j,len; for (i=0; i<4; i++) From 1f73d3ce9fc20e4c7c1905dd11ce287eb1adb5ff Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 14:12:26 -0300 Subject: [PATCH 110/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 736283400..593bd9064 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -379,7 +379,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,fiatoshis); typestr = "withdraw"; printf("%s kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); - if ( komodo_paxmark(height,&space,txid,vout,kmdheight)) == 0 ) + if ( komodo_paxmark(height,&space,txid,vout,kmdheight) == 0 ) { if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) != 0 ) { From 521b866bdb2b3b5b11a30aca13f28c6c085c8031 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 14:14:03 -0300 Subject: [PATCH 111/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 593bd9064..0969bf1cc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -95,7 +95,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t } } -int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint64_t *values,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) +int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) { int32_t i,n=0,j,len; for (i=0; i<4; i++) From 47837c8c5c93136b0975742720ff823a70e6d456 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 14:14:56 -0300 Subject: [PATCH 112/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0969bf1cc..626fdd7f8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -230,7 +230,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { - int32_t i,j,n,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode; uint64_t values[64]; struct pax_transaction *pax,space; + int32_t i,j,n,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode; int64_t values[64]; struct pax_transaction *pax,space; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); memset(kmdheights,0,sizeof(kmdheights)); From 02f6120cb6ae562be1a8d61a03385f84b5d23b72 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 14:29:19 -0300 Subject: [PATCH 113/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 626fdd7f8..79c7df462 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -368,7 +368,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - else if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) == 0 ) + else { if ( tokomodo != 0 && opretbuf[0] == 'W' && opretlen >= 38 ) { From 5ffc9913979ea1bac3c58181b3948bba557ea6b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 14:35:02 -0300 Subject: [PATCH 114/549] test --- src/komodo_gateway.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 79c7df462..db49aa650 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -354,7 +354,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - else if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) + else if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 || opretlen == 38 ) { if ( tokomodo == 0 && opretbuf[0] == 'I' ) // assetchain coinbase { @@ -367,10 +367,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - } - else - { - if ( tokomodo != 0 && opretbuf[0] == 'W' && opretlen >= 38 ) + else if ( tokomodo != 0 && opretbuf[0] == 'W' && opretlen >= 38 ) { iguana_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight); memset(base,0,sizeof(base)); From 01d9ed2fc67bd1651772832f02c8c06d5997a1f2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 14:38:35 -0300 Subject: [PATCH 115/549] test --- src/komodo_gateway.h | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index db49aa650..bd1c3e04e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -354,6 +354,25 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } + else if ( opretbuf[0] == 'W' && opretlen >= 38 ) + { + iguana_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight); + memset(base,0,sizeof(base)); + PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&fiatoshis); + bitcoin_address(coinaddr,addrtype,rmd160,20); + checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,fiatoshis); + typestr = "withdraw"; + printf("%s kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); + if ( komodo_paxmark(height,&space,txid,vout,kmdheight) == 0 ) + { + if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) != 0 ) + { + + } + printf("notarize %s %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),kmdheight,height); + //komodo_gateway_deposit(0,0,0,0,0,txids[i],vouts[i],height,0); + } + } else if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 || opretlen == 38 ) { if ( tokomodo == 0 && opretbuf[0] == 'I' ) // assetchain coinbase @@ -367,25 +386,6 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - else if ( tokomodo != 0 && opretbuf[0] == 'W' && opretlen >= 38 ) - { - iguana_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight); - memset(base,0,sizeof(base)); - PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&fiatoshis); - bitcoin_address(coinaddr,addrtype,rmd160,20); - checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,fiatoshis); - typestr = "withdraw"; - printf("%s kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); - if ( komodo_paxmark(height,&space,txid,vout,kmdheight) == 0 ) - { - if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) != 0 ) - { - - } - printf("notarize %s %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),kmdheight,height); - //komodo_gateway_deposit(0,0,0,0,0,txids[i],vouts[i],height,0); - } - } } return(typestr); } From 846ec673dba75ef986594f318df7e6b898f11284 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 14:47:02 -0300 Subject: [PATCH 116/549] test --- src/komodo_gateway.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index bd1c3e04e..69da35d5e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -309,7 +309,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout) { - uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; uint64_t seed; int64_t fiatoshis,checktoshis,values[64]; struct pax_transaction *pax; + uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64],str[65]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; uint64_t seed; int64_t fiatoshis,checktoshis,values[64]; struct pax_transaction *pax; const char *typestr = "unknown"; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); @@ -358,11 +358,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { iguana_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight); memset(base,0,sizeof(base)); - PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&fiatoshis); + PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&checktoshis); bitcoin_address(coinaddr,addrtype,rmd160,20); - checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,fiatoshis); + convtoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value); typestr = "withdraw"; - printf("%s kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); + printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> %s/v%d (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(convtoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,bits256_str(str,txid),vout,coinaddr); if ( komodo_paxmark(height,&space,txid,vout,kmdheight) == 0 ) { if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) != 0 ) @@ -371,7 +371,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } printf("notarize %s %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),kmdheight,height); //komodo_gateway_deposit(0,0,0,0,0,txids[i],vouts[i],height,0); - } + } else printf("withdraw already there\n"); } else if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 || opretlen == 38 ) { From 67cca2ab0a063876571ab43f62a132450b6da405 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 14:51:31 -0300 Subject: [PATCH 117/549] test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 69da35d5e..f89ce73e3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -309,7 +309,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout) { - uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64],str[65]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; uint64_t seed; int64_t fiatoshis,checktoshis,values[64]; struct pax_transaction *pax; + uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,checktoshis,values[64]; struct pax_transaction *pax; const char *typestr = "unknown"; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); @@ -362,7 +362,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,addrtype,rmd160,20); convtoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value); typestr = "withdraw"; - printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> %s/v%d (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(convtoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,bits256_str(str,txid),vout,coinaddr); + printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> %s/v%d (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(convtoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,txid.ToString.c_str(),vout,coinaddr); if ( komodo_paxmark(height,&space,txid,vout,kmdheight) == 0 ) { if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) != 0 ) @@ -371,7 +371,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } printf("notarize %s %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),kmdheight,height); //komodo_gateway_deposit(0,0,0,0,0,txids[i],vouts[i],height,0); - } else printf("withdraw already there\n"); + } else printf("%s/v%d -> %s withdraw already there\n",txid.ToString.c_str(),vout,coinaddr); } else if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 || opretlen == 38 ) { From 0157f10f31d9f53be92b87cad15c32cf7f916ed0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 14:53:31 -0300 Subject: [PATCH 118/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f89ce73e3..7f8c0117f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -362,7 +362,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,addrtype,rmd160,20); convtoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value); typestr = "withdraw"; - printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> %s/v%d (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(convtoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,txid.ToString.c_str(),vout,coinaddr); + printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(convtoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); if ( komodo_paxmark(height,&space,txid,vout,kmdheight) == 0 ) { if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) != 0 ) @@ -371,7 +371,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } printf("notarize %s %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),kmdheight,height); //komodo_gateway_deposit(0,0,0,0,0,txids[i],vouts[i],height,0); - } else printf("%s/v%d -> %s withdraw already there\n",txid.ToString.c_str(),vout,coinaddr); + } else printf(" %.8f -> %s withdraw already there\n",dstr(value),coinaddr); } else if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 || opretlen == 38 ) { From c3d94aec35ed69c32c5003d298f261c2243febef Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 15:02:06 -0300 Subject: [PATCH 119/549] test --- src/komodo_gateway.h | 17 ++++++----------- src/komodo_pax.h | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7f8c0117f..5a3d2f875 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -309,7 +309,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout) { - uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,checktoshis,values[64]; struct pax_transaction *pax; + uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,values[64]; struct pax_transaction *pax; const char *typestr = "unknown"; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); @@ -358,19 +358,14 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { iguana_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight); memset(base,0,sizeof(base)); - PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&checktoshis); + PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&komodoshis); bitcoin_address(coinaddr,addrtype,rmd160,20); - convtoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value); + checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value); typestr = "withdraw"; - printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(convtoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); - if ( komodo_paxmark(height,&space,txid,vout,kmdheight) == 0 ) + printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); + if ( (pax= komodo_paxfind(&space,txid,vout)) != 0 ) { - if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) != 0 ) - { - - } - printf("notarize %s %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),kmdheight,height); - //komodo_gateway_deposit(0,0,0,0,0,txids[i],vouts[i],height,0); + printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } else printf(" %.8f -> %s withdraw already there\n",dstr(value),coinaddr); } else if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 || opretlen == 38 ) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index f582a9721..a4af4b5aa 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -469,7 +469,7 @@ uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pu if ( fiatoshis < 0 ) shortflag = 1, fiatoshis = -fiatoshis; komodoshis = komodo_paxprice(seedp,height,base,(char *)"KMD",(uint64_t)fiatoshis); - //printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN); + printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN); if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) == 20 ) { PAX_pubkey(1,pubkey33,&addrtype,rmd160,base,&shortflag,tokomodo != 0 ? &komodoshis : &fiatoshis); From c10b348c331902ee68028e58ace879900989798b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 15:03:11 -0300 Subject: [PATCH 120/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5a3d2f875..295dc6c90 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -309,7 +309,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout) { - uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,values[64]; struct pax_transaction *pax; + uint8_t rmd160[20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64]; struct pax_transaction *pax; const char *typestr = "unknown"; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); From ffbc2f003750a18d414b57342aed266418e0aab9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 15:12:55 -0300 Subject: [PATCH 121/549] test --- src/komodo_bitcoind.h | 5 ++++- src/komodo_gateway.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 80bb43f79..163af2e97 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -580,7 +580,10 @@ uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 int32_t komodo_isrealtime(int32_t *kmdheightp) { - *kmdheightp = (int32_t)chainActive.Tip()->nHeight; + struct komodo_state *sp; + if ( (sp= komodo_stateptrget("KMD")) != 0 ) + *kmdheightp = sp->CURRENT_HEIGHT; + else *kmdheightp = 0; if ( *kmdheightp != 0 && *kmdheightp == (int32_t)komodo_longestchain() ) return(1); else return(0); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 295dc6c90..4f97224ae 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -363,7 +363,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value); typestr = "withdraw"; printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); - if ( (pax= komodo_paxfind(&space,txid,vout)) != 0 ) + if ( (pax= komodo_paxfind(&space,txid,vout)) == 0 ) { printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } else printf(" %.8f -> %s withdraw already there\n",dstr(value),coinaddr); From 8a7c9241b6c418066fd315dab8003bb247fc4709 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 15:14:36 -0300 Subject: [PATCH 122/549] test --- src/komodo_bitcoind.h | 2 +- src/komodo_utils.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 163af2e97..ae4fa58be 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -581,7 +581,7 @@ uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 int32_t komodo_isrealtime(int32_t *kmdheightp) { struct komodo_state *sp; - if ( (sp= komodo_stateptrget("KMD")) != 0 ) + if ( (sp= komodo_stateptrget((char *)"KMD")) != 0 ) *kmdheightp = sp->CURRENT_HEIGHT; else *kmdheightp = 0; if ( *kmdheightp != 0 && *kmdheightp == (int32_t)komodo_longestchain() ) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index c2b4f4b4f..d77d8ed72 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1485,20 +1485,20 @@ void komodo_nameset(char *symbol,char *dest,char *source) { if ( source[0] == 0 ) { - strcpy(symbol,"KMD"); - strcpy(dest,"BTC"); + strcpy(symbol,(char *)"KMD"); + strcpy(dest,(char *)"BTC"); } else { strcpy(symbol,source); - strcpy(dest,"KMD"); + strcpy(dest,(char *)"KMD"); } } struct komodo_state *komodo_stateptrget(char *base) { int32_t baseid; - if ( base == 0 || base[0] == 0 || strcmp(base,"KMD") == 0 ) + if ( base == 0 || base[0] == 0 || strcmp(base,(char *)"KMD") == 0 ) return(&KOMODO_STATES[33]); else if ( (baseid= komodo_baseid(base)) >= 0 ) return(&KOMODO_STATES[baseid+1]); From 0b556992bcb8a6eeae15c42f439c3dd3186a974a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 15:19:30 -0300 Subject: [PATCH 123/549] test --- src/komodo_bitcoind.h | 2 +- src/komodo_gateway.h | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ae4fa58be..a49f1a068 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -584,7 +584,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp) if ( (sp= komodo_stateptrget((char *)"KMD")) != 0 ) *kmdheightp = sp->CURRENT_HEIGHT; else *kmdheightp = 0; - if ( *kmdheightp != 0 && *kmdheightp == (int32_t)komodo_longestchain() ) + if ( chainActive.Tip()->nHeight == (int32_t)komodo_longestchain() ) return(1); else return(0); } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4f97224ae..919c3d6c2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -363,10 +363,13 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value); typestr = "withdraw"; printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); - if ( (pax= komodo_paxfind(&space,txid,vout)) == 0 ) + if ( checktoshis == komodoshis ) { - printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); - } else printf(" %.8f -> %s withdraw already there\n",dstr(value),coinaddr); + if ( (pax= komodo_paxfind(&space,txid,vout)) == 0 ) + { + printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); + } else printf(" %.8f -> %s withdraw already there\n",dstr(value),coinaddr); + } } else if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 || opretlen == 38 ) { From ea365a71c9ccb55caaab9c3c4a2bf0c407d474fd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 15:52:34 -0300 Subject: [PATCH 124/549] test --- src/komodo.h | 53 +++++++++++++++++++++++--------------------- src/komodo_gateway.h | 15 +++++++++++-- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 7e8202be0..eaeeb6b07 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -311,7 +311,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar } } -int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value) +int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized) { static uint256 zero; int32_t opretlen,nid,k,len = 0; uint256 kmdtxid,desttxid; uint8_t crypto777[33]; struct komodo_state *sp; char symbol[16],dest[16]; if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) @@ -366,7 +366,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&kmdtxid); len += iguana_rwnum(0,&scriptbuf[len],4,(uint8_t *)notarizedheightp); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); - if ( *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) + if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len]); sp->NOTARIZED_HEIGHT = *notarizedheightp; @@ -435,7 +435,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) static int32_t hwmheight; uint64_t signedmask,voutmask; char symbol[16],dest[16]; struct komodo_state *sp; uint8_t scriptbuf[4096],pubkeys[64][33],rmd160[20],scriptPubKey[35]; uint256 kmdtxid,zero,btctxid,txhash; - int32_t i,j,k,numnotaries,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; + int32_t i,j,k,numnotaries,notarized,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; memset(&zero,0,sizeof(zero)); komodo_init(pindex->nHeight); if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) @@ -469,26 +469,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); notaryid = -1; - voutmask = specialtx = notarizedheight = isratification = 0; - for (j=0; j 0 ) - { - for (k=0; k= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) + { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); - if ( signedmask != 0 && (notarizedheight != 0 || specialtx != 0) ) + notarized = 1; + } + for (j=0; j 0 ) + { + for (k=0; kfiatoshis = fiatoshis; memcpy(pax->rmd160,rmd160,20); pax->height = height; - pax->otherheight = sp->CURRENT_HEIGHT;//otherheight; + pax->otherheight = otherheight; if ( pax->marked == 0 ) { if ( addflag != 0 ) @@ -368,7 +368,18 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (pax= komodo_paxfind(&space,txid,vout)) == 0 ) { printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); - } else printf(" %.8f -> %s withdraw already there\n",dstr(value),coinaddr); + } + else + { + printf(" %.8f -> %s withdraw already there\n",dstr(value),coinaddr); + strcpy(pax->coinaddr,coinaddr); + pax->komodoshis = komodoshis; + strcpy(pax->symbol,"KMD"); + pax->fiatoshis = value; + memcpy(pax->rmd160,rmd160,20); + pax->height = kmdheight; + pax->otherheight = height; + } } } else if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 || opretlen == 38 ) From b5c6630160bcb2eb76dc76d2564563baf94a5356 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 16:04:04 -0300 Subject: [PATCH 125/549] test --- src/komodo.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index eaeeb6b07..be2dbf1b2 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -374,7 +374,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_DESTTXID = desttxid; komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0); // extract X opreturns here - } else printf("reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]); + } else printf("notarized.%d reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",notarized,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]); } else if ( i == 0 && j == 1 && opretlen == 149 ) komodo_paxpricefeed(height,&scriptbuf[len],opretlen); @@ -480,6 +480,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) signedmask |= (1LL << k); } } + printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); if ( specialtx != 0 && (((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); From fd0c033f72961797559a77077cbba78fc4a3728c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 16:13:05 -0300 Subject: [PATCH 126/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index be2dbf1b2..cbeb8185c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -483,7 +483,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); if ( specialtx != 0 && (((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) { - printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); + printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); notarized = 1; } for (j=0; j Date: Sun, 20 Nov 2016 16:45:33 -0300 Subject: [PATCH 127/549] test --- src/komodo.h | 5 +++-- src/komodo_gateway.h | 27 ++++++++++++++++++--------- src/komodo_structs.h | 2 +- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index cbeb8185c..34bcfed63 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -373,7 +373,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_HASH = kmdtxid; sp->NOTARIZED_DESTTXID = desttxid; komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0); - // extract X opreturns here + if ( opretlen > len && scriptbuf[len] == 'A' ) + komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len,j); } else printf("notarized.%d reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",notarized,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]); } else if ( i == 0 && j == 1 && opretlen == 149 ) @@ -481,7 +482,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); - if ( specialtx != 0 && (((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) + if ( (((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); notarized = 1; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a3c8c25ab..841abc21e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -155,6 +155,8 @@ uint64_t komodo_paxtotal() return(total); } +// need a function to return pending withdraws for notarizing opreturn + int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t tokomodo) { struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t mask; @@ -372,19 +374,26 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 else { printf(" %.8f -> %s withdraw already there\n",dstr(value),coinaddr); - strcpy(pax->coinaddr,coinaddr); - pax->komodoshis = komodoshis; - strcpy(pax->symbol,"KMD"); - pax->fiatoshis = value; - memcpy(pax->rmd160,rmd160,20); - pax->height = kmdheight; - pax->otherheight = height; + komodo_gateway_deposit(coinaddr,komodoshis,"KMD",value,rmd160,txid,vout,kmdheight,height); } } } - else if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 || opretlen == 38 ) + else if ( tokomodo != 0 && opretbuf[0] == 'A' ) { - if ( tokomodo == 0 && opretbuf[0] == 'I' ) // assetchain coinbase + if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,opretbuf,opretlen,0)) > 0 ) + { + for (i=0; iapproved = kmdheights[i]; + } + } + } + else if ( tokomodo == 0 && opretbuf[0] == 'I' ) + { + if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) { if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,opretbuf,opretlen,0)) > 0 ) { diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 4d09d5a81..f62e5de1a 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -57,7 +57,7 @@ struct pax_transaction UT_hash_handle hh; uint256 txid; uint64_t komodoshis,fiatoshis; - int32_t marked,height,otherheight; + int32_t marked,height,otherheight,approved; uint16_t vout; char symbol[16],coinaddr[64]; uint8_t rmd160[20],shortflag; }; From 09a235e1de769fe15491fe694f34879eb54e931c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 16:47:30 -0300 Subject: [PATCH 128/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 841abc21e..bec970bbb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -248,7 +248,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above // printf("%02x",script[i]); //printf(" height.%d checkdeposit n.%d [%02x] [%c] %d vs %d\n",height,n,script[0],script[offset],script[offset],'X'); opcode = 'X'; - strcpy(symbol,"KMD"); + strcpy(symbol,(char *)"KMD"); } else { @@ -374,7 +374,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 else { printf(" %.8f -> %s withdraw already there\n",dstr(value),coinaddr); - komodo_gateway_deposit(coinaddr,komodoshis,"KMD",value,rmd160,txid,vout,kmdheight,height); + komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height); } } } From f360ea0ad07f3b393141f39028d160c111c9a6df Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 17:10:27 -0300 Subject: [PATCH 129/549] test --- src/komodo_gateway.h | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index bec970bbb..4de8805ba 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -95,15 +95,16 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t } } -int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) +int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) { - int32_t i,n=0,j,len; + int32_t i,n=0,j,len,incr; uint8_t rmd160[20]; for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) { opretbuf++, opretlen--; - for (n=len=0; n>>>>>> iskomodo X: (%s) fiat %.8f kmdheight.%d other.%d\n",symbol,dstr(fiatoshis),height,otherheight); @@ -155,7 +158,20 @@ uint64_t komodo_paxtotal() return(total); } -// need a function to return pending withdraws for notarizing opreturn +int32_t komodo_withdraws_pending(char *opretbuf) +{ + struct pax_transaction *pax,*tmp; int32_t ht,len=0; uint64_t total = 0; + if ( komodo_isrealtime(&ht) == 0 || ASSETCHAINS_SYMBOL[0] != 0 ) + return(0); + HASH_ITER(hh,PAX,pax,tmp) + { + if ( pax->marked == 0 && strcmp((char *)"KMD",pax->symbol) == 0 && pax->approved == 0 ) + { + // add 'A' opreturn entry + } + } + return(len); +} int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t tokomodo) { @@ -232,9 +248,10 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { - int32_t i,j,n,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode; int64_t values[64]; struct pax_transaction *pax,space; + int32_t i,j,n,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; int64_t values[64]; struct pax_transaction *pax,space; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); + memset(rmd160s,0,sizeof(rmd160s)); memset(kmdheights,0,sizeof(kmdheights)); memset(otherheights,0,sizeof(otherheights)); n = block.vtx[0].vout.size(); @@ -257,7 +274,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } if ( script[offset] == opcode && opretlen < block.vtx[0].vout[n-1].scriptPubKey.size() ) { - if ( (num= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,&script[offset],opretlen,opcode == 'X')) > 0 ) + if ( (num= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,rmd160s,&script[offset],opretlen,opcode == 'X')) > 0 ) { for (i=1; i 0 ) + if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 ) { for (i=0; iapproved = kmdheights[i]; } } From 9ccd3f33c8ef859391ec9001e3556a044974fcef Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 17:15:23 -0300 Subject: [PATCH 130/549] test --- src/komodo_gateway.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4de8805ba..f46be152b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -75,12 +75,18 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( coinaddr != 0 ) { strcpy(pax->coinaddr,coinaddr); - pax->komodoshis = value; - strcpy(pax->symbol,symbol); - pax->fiatoshis = fiatoshis; - memcpy(pax->rmd160,rmd160,20); - pax->height = height; - pax->otherheight = otherheight; + if ( value != 0 ) + pax->komodoshis = value; + if ( symbol != 0 ) + strcpy(pax->symbol,symbol); + if ( fiatoshis != 0 ) + pax->fiatoshis = fiatoshis; + if ( rmd160 != 0 ) + memcpy(pax->rmd160,rmd160,20); + if ( height != 0 ) + pax->height = height; + if ( otherheight != 0 ) + pax->otherheight = otherheight; if ( pax->marked == 0 ) { if ( addflag != 0 ) @@ -414,12 +420,13 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) { - if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,opretbuf,opretlen,0)) > 0 ) + if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 ) { for (i=0; i Date: Sun, 20 Nov 2016 17:16:40 -0300 Subject: [PATCH 131/549] test --- src/komodo_gateway.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f46be152b..75170c29d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -103,7 +103,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) { - int32_t i,n=0,j,len,incr; uint8_t rmd160[20]; + int32_t i,n=0,j,len,incr,height,otherheight; uint8_t rmd160[20]; uint64_t fiatoshis; char symbol[16]; for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) @@ -122,7 +122,6 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t //printf(" issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); if ( iskomodo != 0 ) { - uint64_t fiatoshis; int32_t height,otherheight; char symbol[16]; len += iguana_rwnum(0,&opretbuf[len],sizeof(fiatoshis),&fiatoshis); len += iguana_rwnum(0,&opretbuf[len],sizeof(height),&height); len += iguana_rwnum(0,&opretbuf[len],sizeof(otherheight),&otherheight); From b21381369bf00c9bf97bb08428516d4dd180ce98 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 17:18:10 -0300 Subject: [PATCH 132/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 34bcfed63..b3e361851 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -366,7 +366,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&kmdtxid); len += iguana_rwnum(0,&scriptbuf[len],4,(uint8_t *)notarizedheightp); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); - if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) + if ( *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len]); sp->NOTARIZED_HEIGHT = *notarizedheightp; From accc2d5ef9ada44f4133e2cbd071df551a801666 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 17:27:53 -0300 Subject: [PATCH 133/549] test --- src/komodo.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index b3e361851..861e74656 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -481,7 +481,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) signedmask |= (1LL << k); } } - printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); if ( (((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); From 2cc7e8de2d35f646d4675fd8a817bc1fbf79de1e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 17:33:25 -0300 Subject: [PATCH 134/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 861e74656..4103608c0 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -366,7 +366,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&kmdtxid); len += iguana_rwnum(0,&scriptbuf[len],4,(uint8_t *)notarizedheightp); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); - if ( *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) + if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len]); sp->NOTARIZED_HEIGHT = *notarizedheightp; From e6d7eca6b9a07ee371faa174163a53d34c288828 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 17:34:26 -0300 Subject: [PATCH 135/549] test --- src/komodo.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo.h b/src/komodo.h index 4103608c0..01a3f395c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -481,6 +481,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) signedmask |= (1LL << k); } } + numvalid = bitweight(signedmask); if ( (((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); From 8f40a7a272f2539532fc3a25e0c866d7754b8884 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 17:40:52 -0300 Subject: [PATCH 136/549] test --- src/komodo.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 01a3f395c..deb2c3612 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -311,7 +311,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar } } -int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized) +int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask) { static uint256 zero; int32_t opretlen,nid,k,len = 0; uint256 kmdtxid,desttxid; uint8_t crypto777[33]; struct komodo_state *sp; char symbol[16],dest[16]; if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) @@ -375,7 +375,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0); if ( opretlen > len && scriptbuf[len] == 'A' ) komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len,j); - } else printf("notarized.%d reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",notarized,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]); + } else printf("notarized.%d %llx reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",notarized,(long long)signedmask,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]); } else if ( i == 0 && j == 1 && opretlen == 149 ) komodo_paxpricefeed(height,&scriptbuf[len],opretlen); @@ -497,7 +497,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) #else memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len); #endif - notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized); + notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask); if ( 0 && i > 0 ) { for (k=0; k Date: Sun, 20 Nov 2016 17:46:56 -0300 Subject: [PATCH 137/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index deb2c3612..3e9b14ce5 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -482,7 +482,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } numvalid = bitweight(signedmask); - if ( (((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) + if ( (((height < 76000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); notarized = 1; From 43f79eeeb5c2fed32aad86e60007c65f13a9259e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 18:05:14 -0300 Subject: [PATCH 138/549] test --- src/komodo.h | 4 ++-- src/komodo_gateway.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 3e9b14ce5..0821259ea 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -482,9 +482,9 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } numvalid = bitweight(signedmask); - if ( (((height < 76000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) + if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) { - printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); + //printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); notarized = 1; } for (j=0; j %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); - if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 ) + if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 || (strcmp(symbol,"KMD") == 0 && pax->approved == 0) ) continue; //if ( ASSETCHAINS_SYMBOL[0] != 0 ) printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); @@ -292,6 +292,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above else matched++; if ( 0 && opcode == 'X' ) printf("errs.%d i.%d match %.8f == %.8f\n",errs,i,dstr(pax != 0 ? pax->fiatoshis:-1),dstr(block.vtx[0].vout[i].nValue)); + komodo_paxmark(height,&space,txids[i-1],vouts[i-1],height); } else { @@ -317,7 +318,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } else if ( opcode == 'I' ) matched++; } - komodo_paxmark(height,&space,txids[i-1],vouts[i-1],height); } if ( matched != num ) { From 131207a1f48d4ae93b45a552f286bc0297d009e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 18:20:15 -0300 Subject: [PATCH 139/549] test --- src/komodo.h | 10 ++-------- src/komodo_gateway.h | 8 ++++++++ src/komodo_utils.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index ed05c1a46..59fbe0442 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -168,7 +168,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char return(func); } else return(-1); } - + void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout) { static FILE *fp; static int32_t errs; @@ -177,13 +177,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar return; if ( fp == 0 ) { -#ifdef WIN32 - sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"komodostate"); - //sprintf(fname2,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"minerids"); -#else - sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),(char *)"komodostate"); - //sprintf(fname2,"%s/%s",GetDataDir(false).string().c_str(),(char *)"minerids"); -#endif + komodo_statename(fname,ASSETCHAINS_SYMBOL); /*memset(Minerids,0xfe,sizeof(Minerids)); if ( (Minerfp= fopen(fname2,"rb+")) == 0 ) { diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d72c4b1c0..afb032448 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -385,6 +385,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 return(typestr); } +#ifdef pollmethod void komodo_gateway_voutupdate(char *symbol,int32_t isspecial,int32_t height,int32_t txi,bits256 txid,int32_t vout,int32_t numvouts,uint64_t value,uint8_t *script,int32_t len) { int32_t i,opretlen,offset = 0; uint256 zero,utxid; const char *typestr; @@ -531,6 +532,13 @@ void komodo_gateway_iteration(char *symbol) sleep(30); } } +#else + +void komodo_gateway_iteration(char *symbol) +{ + +} +#endif void komodo_iteration(char *symbol) { diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 78d38141d..d18dca12d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1261,6 +1261,36 @@ void komodo_userpass(char *username,char *password,FILE *fp) free(rpcpassword); } +void komodo_statename(char *fname,char *symbol) +{ + int32_t n,len; + sprintf(fname,"%s",GetDataDir(false).string().c_str()); + if ( (n= (int32_t)strlen(ASSETCHAINS_SYMBOL)) != 0 ) + { + len = (int32_t)strlen(fname); + if ( strcmp(ASSETCHAINS_SYMBOL,&fname[len - n]) == 0 ) + { + fname[len - n] = 0; + if ( symbol[0] != 0 ) + { + strcpy(&fname[len - n],symbol); +#ifdef WIN32 + strcat(fname,"\\"); +#else + strcat(fname,"//"); +#endif + } + } + else + { + printf("unexpected fname.(%s) vs %s\n",fname,ASSETCHAINS_SYMBOL); + return; + } + } + strcat(fname,(char *)"komodostate"); + printf("statename.(%s) %s\n",symbol,fname); +} + void komodo_configfile(char *symbol,uint16_t port) { static char myusername[512],mypassword[8192]; From ebec4dd8362d1e6829bf5b3481511f6c22d732fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 06:58:29 -0300 Subject: [PATCH 140/549] test --- src/assetchains | 37 +++++++++++++++++++++++++++++++++++++ src/rpcrawtransaction.cpp | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/assetchains b/src/assetchains index f3697bc2f..8f5febcff 100755 --- a/src/assetchains +++ b/src/assetchains @@ -1,6 +1,43 @@ +#!/bin/bash source pubkey.txt echo $pubkey +curl --url "http://127.0.0.1:7776" --data "{\"timeout\":60000,\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"REVS\",\"pubkey\":\"$pubkey\"}" + +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"USD\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EUR\",\"pubkey\":\"$pubkey\"}" + +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"JPY\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GBP\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"AUD\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CAD\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHF\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"NZD\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CNY\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"RUB\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MXN\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BRL\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"INR\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HKD\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"TRY\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ZAR\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PLN\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"NOK\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SEK\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DKK\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CZK\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HUF\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ILS\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KRW\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MYR\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PHP\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"RON\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SGD\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"THB\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BGN\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"IDR\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HRK\",\"pubkey\":\"$pubkey\"}" + ./komodod -pubkey=$pubkey -ac_name=REVS -ac_supply=1300000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 & diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 4b5cdae35..d54ec4ff5 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -132,7 +132,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry) { extern char ASSETCHAINS_SYMBOL[16]; interest = komodo_interest(pindex->nHeight,txout.nValue,tx.nLockTime,tipindex->nTime); - if ( strcmp("REVS",ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp("REVS",ASSETCHAINS_SYMBOL) == 0 ) fprintf(stderr,"TxtoJSON interest %llu %.8f (%d %llu %u %u)\n",(long long)interest,(double)interest/COIN,(int32_t)pindex->nHeight,(long long)txout.nValue,(uint32_t)tx.nLockTime,(int32_t)tipindex->nTime); out.push_back(Pair("interest", ValueFromAmount(interest))); } From d7161e658660c522145aa9b6f94acf521b936544 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 07:13:15 -0300 Subject: [PATCH 141/549] Revert "test" This reverts commit 131207a1f48d4ae93b45a552f286bc0297d009e1. --- src/komodo.h | 10 ++++++++-- src/komodo_gateway.h | 8 -------- src/komodo_utils.h | 30 ------------------------------ 3 files changed, 8 insertions(+), 40 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 59fbe0442..ed05c1a46 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -168,7 +168,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char return(func); } else return(-1); } - + void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout) { static FILE *fp; static int32_t errs; @@ -177,7 +177,13 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar return; if ( fp == 0 ) { - komodo_statename(fname,ASSETCHAINS_SYMBOL); +#ifdef WIN32 + sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"komodostate"); + //sprintf(fname2,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"minerids"); +#else + sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),(char *)"komodostate"); + //sprintf(fname2,"%s/%s",GetDataDir(false).string().c_str(),(char *)"minerids"); +#endif /*memset(Minerids,0xfe,sizeof(Minerids)); if ( (Minerfp= fopen(fname2,"rb+")) == 0 ) { diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index afb032448..d72c4b1c0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -385,7 +385,6 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 return(typestr); } -#ifdef pollmethod void komodo_gateway_voutupdate(char *symbol,int32_t isspecial,int32_t height,int32_t txi,bits256 txid,int32_t vout,int32_t numvouts,uint64_t value,uint8_t *script,int32_t len) { int32_t i,opretlen,offset = 0; uint256 zero,utxid; const char *typestr; @@ -532,13 +531,6 @@ void komodo_gateway_iteration(char *symbol) sleep(30); } } -#else - -void komodo_gateway_iteration(char *symbol) -{ - -} -#endif void komodo_iteration(char *symbol) { diff --git a/src/komodo_utils.h b/src/komodo_utils.h index d18dca12d..78d38141d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1261,36 +1261,6 @@ void komodo_userpass(char *username,char *password,FILE *fp) free(rpcpassword); } -void komodo_statename(char *fname,char *symbol) -{ - int32_t n,len; - sprintf(fname,"%s",GetDataDir(false).string().c_str()); - if ( (n= (int32_t)strlen(ASSETCHAINS_SYMBOL)) != 0 ) - { - len = (int32_t)strlen(fname); - if ( strcmp(ASSETCHAINS_SYMBOL,&fname[len - n]) == 0 ) - { - fname[len - n] = 0; - if ( symbol[0] != 0 ) - { - strcpy(&fname[len - n],symbol); -#ifdef WIN32 - strcat(fname,"\\"); -#else - strcat(fname,"//"); -#endif - } - } - else - { - printf("unexpected fname.(%s) vs %s\n",fname,ASSETCHAINS_SYMBOL); - return; - } - } - strcat(fname,(char *)"komodostate"); - printf("statename.(%s) %s\n",symbol,fname); -} - void komodo_configfile(char *symbol,uint16_t port) { static char myusername[512],mypassword[8192]; From e2a12abf598631bf0a45cb4be2d7b99d01daf326 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 07:39:45 -0300 Subject: [PATCH 142/549] test --- src/komodo.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0821259ea..88f801cc1 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -151,11 +151,13 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char { if ( fread(opret,1,olen,fp) != olen ) errs++; - //if ( matched != 0 ) global shared state -> global PAX - int32_t i; for (i=0; i global PAX } else printf("illegal olen.%u\n",olen); } else if ( func == 'D' ) From 66e3c53284a5cb65b014eb5cbad5c2d89d1c1214 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 08:28:11 -0300 Subject: [PATCH 143/549] test --- src/komodo_bitcoind.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a49f1a068..5e99b3924 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -510,7 +510,10 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) for (i=1; i<64; i++) { if ( komodo_minerid(height-i) == notaryid ) + { + fprintf(stderr,"ht.%d notaryid.%d already mined -i.%d\n",height,notaryid,i); return(-1); + } } return(1); } From 0b9b580674c04e4bbd80796641fba85c3b5c4147 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 09:00:25 -0300 Subject: [PATCH 144/549] test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 5e99b3924..9567ba57c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -511,7 +511,7 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) { if ( komodo_minerid(height-i) == notaryid ) { - fprintf(stderr,"ht.%d notaryid.%d already mined -i.%d\n",height,notaryid,i); + //fprintf(stderr,"ht.%d notaryid.%d already mined -i.%d\n",height,notaryid,i); return(-1); } } From 7cc6844b761f3a04eaed6c6e7d974c8b7c61ea44 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 09:43:24 -0300 Subject: [PATCH 145/549] test --- src/komodo_gateway.h | 65 ++++++++++++++++++++++++++++--------------- src/rpcblockchain.cpp | 12 ++++++++ 2 files changed, 55 insertions(+), 22 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 494fc43f0..f48910002 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -101,9 +101,27 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t } } +int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transaction *pax) +{ + int32_t i,len = 0; + for (i=0; i<32; i++) + opretbuf[len++] = ((uint8_t *)&pax->txid)[i]; + opretbuf[len++] = pax->vout & 0xff; + opretbuf[len++] = (pax->vout >> 8) & 0xff; + //printf(" issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); + len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->fiatoshis),&pax->komodoshis); + len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->fiatoshis),&pax->fiatoshis); + len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->kmdheight),&pax->kmdheight); + len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->otherheight),&pax->otherheight); + memcpy(&opretbuf[len],pax->rmd160,20), len += 20; + for (i=0; i<4; i++) + opretbuf[len++] = symbol[i]; + return(len); +} + int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) { - int32_t i,n=0,j,len,incr,height,otherheight; uint8_t rmd160[20]; uint64_t fiatoshis; char symbol[16]; + struct pax_transaction p; int32_t i,n=0,j,len,incr,height,otherheight; uint8_t rmd160[20]; uint64_t fiatoshis; char symbol[16]; for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) @@ -112,33 +130,30 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t incr = 34 + (iskomodo * (sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); for (n=len=0; n>>>>>> iskomodo X: (%s) fiat %.8f kmdheight.%d other.%d\n",symbol,dstr(fiatoshis),height,otherheight); } + else + { + for (j=0; j<32; j++) + { + ((uint8_t *)&txids[n])[j] = opretbuf[len++]; + //printf("%02x",((uint8_t *)&txids[n])[j]); + } + vouts[n] = opretbuf[len++]; + vouts[n] = (opretbuf[len++] << 8) | vouts[n]; + } } } return(n); @@ -163,9 +178,9 @@ uint64_t komodo_paxtotal() return(total); } -int32_t komodo_withdraws_pending(char *opretbuf) +int32_t komodo_pending_withdraws(char *opretstr) { - struct pax_transaction *pax,*tmp; int32_t ht,len=0; uint64_t total = 0; + struct pax_transaction *pax,*tmp; uint8_t opretbuf[10000]; int32_t ht,len=0; uint64_t total = 0; if ( komodo_isrealtime(&ht) == 0 || ASSETCHAINS_SYMBOL[0] != 0 ) return(0); HASH_ITER(hh,PAX,pax,tmp) @@ -173,8 +188,14 @@ int32_t komodo_withdraws_pending(char *opretbuf) if ( pax->marked == 0 && strcmp((char *)"KMD",pax->symbol) == 0 && pax->approved == 0 ) { // add 'A' opreturn entry + if ( len == 0 ) + opretbuf[len++] = 'A'; + len += komodo_rwapproval(1,&opretbuf[len],pax); } } + if ( len > 0 ) + init_hexbytes_noT(opretstr,opretbuf,len); + else opretstr[0] = 0; return(len); } diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 007600a91..da5fd2fdb 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -436,6 +436,18 @@ Value notaries(const Array& params, bool fHelp) return ret; } +Value withdraws_pending(const Array& params, bool fHelp) +{ + Object ret; char opretbuf[10000*2]; int32_t opretlen; + if ( fHelp || params.size() != 0 ) + throw runtime_error("withdraws_pending needs no args\n"); + LOCK(cs_main); + if ( (opretlen= komodo_pending_withdraws(opretbuf)) > 0 ) + ret.push_back(Pair("withdraws", opretbuf)); + else ret.push_back(Pair("withdraws", (char *)"")); + return ret; +} + Value paxprice(const Array& params, bool fHelp) { if ( fHelp || params.size() < 3 || params.size() > 4 ) From 3b024dafe554f2cc388d9424ad2d0ac7a004305a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 09:44:41 -0300 Subject: [PATCH 146/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f48910002..a95c7f3ae 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -111,7 +111,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio //printf(" issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->fiatoshis),&pax->komodoshis); len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->fiatoshis),&pax->fiatoshis); - len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->kmdheight),&pax->kmdheight); + len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->height),&pax->height); len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->otherheight),&pax->otherheight); memcpy(&opretbuf[len],pax->rmd160,20), len += 20; for (i=0; i<4; i++) @@ -137,7 +137,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t if ( values != 0 && kmdheights != 0 && otherheights != 0 && baseids != 0 ) { values[i] = (ASSETCHAINS_SYMBOL[0] == 0) ? p.komodoshis : p.fiatoshis; - kmdheights[i] = p.kmdheight; + kmdheights[i] = p.height; otherheights[i] = p.otherheight; memcpy(&rmd160s[n * 20],p.rmd160,20); baseids[i] = komodo_baseid(p.symbol); From d5735262cf7877d1149f4f4fed3484a711ea705f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 09:45:27 -0300 Subject: [PATCH 147/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a95c7f3ae..20c4bb1dc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -115,7 +115,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->otherheight),&pax->otherheight); memcpy(&opretbuf[len],pax->rmd160,20), len += 20; for (i=0; i<4; i++) - opretbuf[len++] = symbol[i]; + opretbuf[len++] = pax->symbol[i]; return(len); } From 9bd3a9cddcd399e2984e4029505b0bcedce0f048 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 09:48:32 -0300 Subject: [PATCH 148/549] test --- src/rpcblockchain.cpp | 6 ++++-- src/rpcclient.cpp | 1 + src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index da5fd2fdb..8bfb19629 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -436,11 +436,13 @@ Value notaries(const Array& params, bool fHelp) return ret; } -Value withdraws_pending(const Array& params, bool fHelp) +int32_t komodo_pending_withdraws(char *opretstr); + +Value paxpending(const Array& params, bool fHelp) { Object ret; char opretbuf[10000*2]; int32_t opretlen; if ( fHelp || params.size() != 0 ) - throw runtime_error("withdraws_pending needs no args\n"); + throw runtime_error("paxpending needs no args\n"); LOCK(cs_main); if ( (opretlen= komodo_pending_withdraws(opretbuf)) > 0 ) ret.push_back(Pair("withdraws", opretbuf)); diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index 30142ee82..adf10ccb7 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -108,6 +108,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "z_importkey", 1 }, { "paxprice", 4 }, { "paxprices", 3 }, + { "paxpending", 3 }, { "notaries", 1 }, }; diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index e8a9958ce..4f04bdcc1 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -301,6 +301,7 @@ static const CRPCCommand vRPCCommands[] = { "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true }, { "blockchain", "verifychain", &verifychain, true }, { "blockchain", "paxprice", &paxprice, true }, + { "blockchain", "paxpending", &paxpending, true }, { "blockchain", "paxprices", &paxprices, true }, { "blockchain", "notaries", ¬aries, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 765e27747..77a4818bb 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -245,6 +245,7 @@ extern json_spirit::Value gettxoutsetinfo(const json_spirit::Array& params, bool extern json_spirit::Value gettxout(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value notaries(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value paxprice(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value paxpending(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value paxprices(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value paxdeposit(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value paxwithdraw(const json_spirit::Array& params, bool fHelp); From 23256cca8f3465db0731e08381d227c033116eb4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 10:17:21 -0300 Subject: [PATCH 149/549] test --- src/komodo_bitcoind.h | 39 ++++++++++++++++++++++++++++----------- src/komodo_gateway.h | 1 + src/komodo_utils.h | 1 - 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 9567ba57c..48a8b5880 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -346,6 +346,34 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) return(retstr2); } +uint256 komodo_getblockhash(int32_t height) +{ + uint256 hash; char params[128]; + memset(&hash,0,sizeof(hash)); + sprintf(params,"[%d]",height); + if ( (hexstr= komodo_issuemethod(KMDUSERPASS,"getblockhash",params,7771)) != 0 ) + { + if ( is_hexstr(hexstr,0) == 64 ) + decode_hex((uint8_t *)&hash,32,hexstr); + printf("KMD hash.%d (%s)\n",height,hexstr); + free(hexstr); + } + return(hash); +} + +uint64_t komodo_seed(int32_t height) +{ + uint256 hash; uint64_t seed = 0; CBlockIndex *pindex; + memset(&hash,0,sizeof(hash)); + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + { + if ( (pindex= chainActive[height]) != 0 ) + hash = pindex->GetBlockHash(); + } else hash = komodo_getblockhash(height); + seed = arith_uint256(hash.GetHex()).GetLow64(); + return(seed); +} + uint32_t komodo_txtime(uint256 hash) { CTransaction tx; @@ -362,17 +390,6 @@ uint32_t komodo_txtime(uint256 hash) return(0); } -uint64_t komodo_seed(int32_t height) -{ - uint256 hash; uint64_t seed = 0; CBlockIndex *pindex = chainActive[height]; - if ( pindex != 0 ) - { - hash = pindex->GetBlockHash(); - seed = arith_uint256(hash.GetHex()).GetLow64(); - } - return(seed); -} - void komodo_disconnect(CBlockIndex *pindex,CBlock& block) { char symbol[16],dest[16]; struct komodo_state *sp; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 20c4bb1dc..7c44512f9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -185,6 +185,7 @@ int32_t komodo_pending_withdraws(char *opretstr) return(0); HASH_ITER(hh,PAX,pax,tmp) { + printf("pax %s marked.%u approved.%u\n",pax->symbol,pax->marked,pax->approved); if ( pax->marked == 0 && strcmp((char *)"KMD",pax->symbol) == 0 && pax->approved == 0 ) { // add 'A' opreturn entry diff --git a/src/komodo_utils.h b/src/komodo_utils.h index d77d8ed72..399fc4c69 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1456,7 +1456,6 @@ void komodo_args() int32_t komodo_baseid(char *origbase); extern int COINBASE_MATURITY; komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1); - //if ( komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 ) COINBASE_MATURITY = 1; } ASSETCHAINS_NOTARIES = GetArg("-ac_notaries",""); From 5050bd250f319aac4c0c1f7cdfd75558d8db1381 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 10:18:28 -0300 Subject: [PATCH 150/549] test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 48a8b5880..0e6bccf3e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -348,7 +348,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) uint256 komodo_getblockhash(int32_t height) { - uint256 hash; char params[128]; + uint256 hash; char params[128],*hexstr; memset(&hash,0,sizeof(hash)); sprintf(params,"[%d]",height); if ( (hexstr= komodo_issuemethod(KMDUSERPASS,"getblockhash",params,7771)) != 0 ) From 4767f1fcd5cb2d91603e070ba93a20c312b01578 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 10:22:29 -0300 Subject: [PATCH 151/549] test --- src/komodo.h | 11 ++++------- src/komodo_gateway.h | 1 + src/komodo_globals.h | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 88f801cc1..8c1445bc6 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -454,14 +454,11 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0); } komodo_currentheight_set(chainActive.Tip()->nHeight); - /*if ( komodo_is_issuer() != 0 ) + while ( KOMODO_PASSPORT_INITDONE == 0 ) { - while ( KOMODO_REALTIME == 0 || time(NULL) <= KOMODO_REALTIME ) - { - fprintf(stderr,"komodo_connect.(%s) waiting for realtime RT.%u now.%u\n",ASSETCHAINS_SYMBOL,KOMODO_REALTIME,(uint32_t)time(NULL)); - sleep(30); - } - }*/ + fprintf(stderr,"komodo_connect.(%s) waiting for KOMODO_PASSPORT_INITDONE.%u\n",ASSETCHAINS_SYMBOL,KOMODO_PASSPORT_INITDONE); + sleep(3); + } KOMODO_INITDONE = (uint32_t)time(NULL); if ( pindex != 0 ) { diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7c44512f9..efe743323 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -528,5 +528,6 @@ void komodo_passport_iteration() refsp->RTbufs[0][2] = 0; } refsp->RTmask = RTmask; + KOMODO_PASSPORT_INITDONE = 1; } diff --git a/src/komodo_globals.h b/src/komodo_globals.h index a4ab49acf..a17c29964 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -36,7 +36,7 @@ struct komodo_state KOMODO_STATES[34]; int COINBASE_MATURITY = 100; -int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES; +int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES; uint8_t NOTARY_PUBKEY33[33]; From 16db178d7979016762bbfcdad36ae40d039f4d15 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 10:24:11 -0300 Subject: [PATCH 152/549] test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0e6bccf3e..b57421a5d 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -351,7 +351,7 @@ uint256 komodo_getblockhash(int32_t height) uint256 hash; char params[128],*hexstr; memset(&hash,0,sizeof(hash)); sprintf(params,"[%d]",height); - if ( (hexstr= komodo_issuemethod(KMDUSERPASS,"getblockhash",params,7771)) != 0 ) + if ( (hexstr= komodo_issuemethod(KMDUSERPASS,(char *)"getblockhash",params,7771)) != 0 ) { if ( is_hexstr(hexstr,0) == 64 ) decode_hex((uint8_t *)&hash,32,hexstr); From cfb7d1c2758ce251f6a719d291936307a93579df Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 10:27:49 -0300 Subject: [PATCH 153/549] test --- src/komodo.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 8c1445bc6..745e5f57e 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -454,10 +454,13 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0); } komodo_currentheight_set(chainActive.Tip()->nHeight); - while ( KOMODO_PASSPORT_INITDONE == 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 ) { - fprintf(stderr,"komodo_connect.(%s) waiting for KOMODO_PASSPORT_INITDONE.%u\n",ASSETCHAINS_SYMBOL,KOMODO_PASSPORT_INITDONE); - sleep(3); + while ( KOMODO_PASSPORT_INITDONE == 0 ) + { + fprintf(stderr,"komodo_connect.(%s) waiting for KOMODO_PASSPORT_INITDONE.%u\n",ASSETCHAINS_SYMBOL,KOMODO_PASSPORT_INITDONE); + sleep(3); + } } KOMODO_INITDONE = (uint32_t)time(NULL); if ( pindex != 0 ) From ccf895cfcf489db5d0a5aa8605c4a5f6d2ac743e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 10:32:13 -0300 Subject: [PATCH 154/549] test --- src/komodo_bitcoind.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b57421a5d..619f7e556 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -348,13 +348,20 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) uint256 komodo_getblockhash(int32_t height) { - uint256 hash; char params[128],*hexstr; + uint256 hash; char params[128],*hexstr,*jsonstr; memset(&hash,0,sizeof(hash)); sprintf(params,"[%d]",height); - if ( (hexstr= komodo_issuemethod(KMDUSERPASS,(char *)"getblockhash",params,7771)) != 0 ) + if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getblockhash",params,7771)) != 0 ) { - if ( is_hexstr(hexstr,0) == 64 ) - decode_hex((uint8_t *)&hash,32,hexstr); + if ( (result= cJSON_Parse(jsonstr)) != 0 ) + { + if ( (hexstr= jstr(result,"result")) != 0 ) + { + if ( is_hexstr(hexstr,0) == 64 ) + decode_hex((uint8_t *)&hash,32,hexstr); + } + free_json(result); + } printf("KMD hash.%d (%s)\n",height,hexstr); free(hexstr); } From 9e8dd53b53656af50b51911ec509f0bc81dbf11f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 10:32:55 -0300 Subject: [PATCH 155/549] test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 619f7e556..ac6be5a01 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -348,7 +348,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) uint256 komodo_getblockhash(int32_t height) { - uint256 hash; char params[128],*hexstr,*jsonstr; + uint256 hash; char params[128],*hexstr,*jsonstr; cJSON *result; memset(&hash,0,sizeof(hash)); sprintf(params,"[%d]",height); if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getblockhash",params,7771)) != 0 ) From 253917191b2cbc5c7cea0a7a47513d53e5a58739 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 10:33:58 -0300 Subject: [PATCH 156/549] test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ac6be5a01..9f0746f94 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -355,7 +355,7 @@ uint256 komodo_getblockhash(int32_t height) { if ( (result= cJSON_Parse(jsonstr)) != 0 ) { - if ( (hexstr= jstr(result,"result")) != 0 ) + if ( (hexstr= jstr(result,(char *)"result")) != 0 ) { if ( is_hexstr(hexstr,0) == 64 ) decode_hex((uint8_t *)&hash,32,hexstr); From 17899df4ff88736a136f967cd00b3402e1de37c0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 10:46:56 -0300 Subject: [PATCH 157/549] test --- src/komodo.h | 4 ++-- src/komodo_gateway.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 745e5f57e..8f2858095 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -462,7 +462,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) sleep(3); } } - KOMODO_INITDONE = (uint32_t)time(NULL); + //KOMODO_INITDONE = (uint32_t)time(NULL); if ( pindex != 0 ) { height = pindex->nHeight; @@ -547,7 +547,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) if ( pindex->nHeight == hwmheight ) komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0); } else printf("komodo_connectblock: unexpected null pindex\n"); - KOMODO_INITDONE = (uint32_t)time(NULL); + //KOMODO_INITDONE = (uint32_t)time(NULL); } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index efe743323..a20b3868d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -459,6 +459,11 @@ void komodo_passport_iteration() { static long lastpos[34]; static char userpass[33][1024]; FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3]; cJSON *infoobj,*result; uint64_t RTmask = 0; + while ( KOMODO_INITDONE == 0 ) + { + fprintf(stderr,"PASSPORT iteration waiting for KOMODO_INITDONE\n"); + sleep(3); + } refsp = komodo_stateptr(symbol,dest); if ( ASSETCHAINS_SYMBOL[0] == 0 ) refid = 33; From 9e6d526c57ce2888cb022049cbadb95d5754fbf8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 10:52:33 -0300 Subject: [PATCH 158/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 8f2858095..0f46a9f71 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -99,7 +99,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char errs++; if ( fread(¬arized_desttxid,1,sizeof(notarized_desttxid),fp) != sizeof(notarized_desttxid) ) errs++; - //printf("%s load[%s] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,symbol,notarized_height,notarized_hash.ToString().c_str()); + printf("%s %p %p[%d] load[%s] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,sp,sp->NPOINTS,sp->NUM_NPOINTS,symbol,notarized_height,notarized_hash.ToString().c_str()); //if ( matched != 0 ) global independent states -> inside *sp komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); } From d3d31824e102702589091a1bb09e9109b957021a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 10:56:22 -0300 Subject: [PATCH 159/549] test --- src/komodo_structs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_structs.h b/src/komodo_structs.h index f62e5de1a..453bb35e0 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -16,11 +16,11 @@ #include "uthash.h" #include "utlist.h" -#ifdef WIN32 +/*#ifdef WIN32 #define PACKED #else #define PACKED __attribute__((packed)) -#endif +#endif*/ #define GENESIS_NBITS 0x1f00ffff #define KOMODO_MINRATIFY 7 @@ -50,7 +50,7 @@ struct komodo_event uint8_t type,reorged; char symbol[16]; uint8_t space[]; -} PACKED; +}; struct pax_transaction { From 71da283a42a39df2fac08fb8e575724550ca2aea Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 11:01:22 -0300 Subject: [PATCH 160/549] test --- src/komodo.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/komodo.h b/src/komodo.h index 0f46a9f71..e9b193b1b 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -192,8 +192,10 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar komodo_statefname(fname,ASSETCHAINS_SYMBOL,(char *)"komodostate"); if ( (fp= fopen(fname,"rb+")) != 0 ) { + pthread_mutex_lock(&komodo_mutex); while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) ; + pthread_mutex_unlock(&komodo_mutex); } else fp = fopen(fname,"wb+"); printf("fname.(%s) fpos.%ld\n",fname,ftell(fp)); KOMODO_INITDONE = (uint32_t)time(NULL); @@ -206,6 +208,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar if ( fp != 0 ) // write out funcid, height, other fields, call side effect function { //printf("fpos.%ld ",ftell(fp)); + pthread_mutex_lock(&komodo_mutex); if ( KMDheight != 0 ) { if ( KMDtimestamp != 0 ) @@ -310,6 +313,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar //komodo_notarized_update(height,NOTARIZED_HEIGHT,NOTARIZED_HASH,NOTARIZED_DESTTXID); } fflush(fp); + pthread_mutex_unlock(&komodo_mutex); } } From f42f928860819037276d88e4261c3e17ba086079 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 11:10:35 -0300 Subject: [PATCH 161/549] test --- src/komodo.h | 4 ---- src/komodo_events.h | 2 ++ src/komodo_notary.h | 2 ++ src/komodo_pax.h | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e9b193b1b..0f46a9f71 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -192,10 +192,8 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar komodo_statefname(fname,ASSETCHAINS_SYMBOL,(char *)"komodostate"); if ( (fp= fopen(fname,"rb+")) != 0 ) { - pthread_mutex_lock(&komodo_mutex); while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) ; - pthread_mutex_unlock(&komodo_mutex); } else fp = fopen(fname,"wb+"); printf("fname.(%s) fpos.%ld\n",fname,ftell(fp)); KOMODO_INITDONE = (uint32_t)time(NULL); @@ -208,7 +206,6 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar if ( fp != 0 ) // write out funcid, height, other fields, call side effect function { //printf("fpos.%ld ",ftell(fp)); - pthread_mutex_lock(&komodo_mutex); if ( KMDheight != 0 ) { if ( KMDtimestamp != 0 ) @@ -313,7 +310,6 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar //komodo_notarized_update(height,NOTARIZED_HEIGHT,NOTARIZED_HASH,NOTARIZED_DESTTXID); } fflush(fp); - pthread_mutex_unlock(&komodo_mutex); } } diff --git a/src/komodo_events.h b/src/komodo_events.h index d7411737f..b5178d396 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -19,6 +19,7 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char *symbol,uint8_t type,uint8_t *data,uint16_t datalen) { struct komodo_event *ep; uint16_t len = (uint16_t)(sizeof(*ep) + datalen); + portable_mutex_lock(&komodo_mutex); ep = (struct komodo_event *)calloc(1,len); ep->len = len; ep->height = height; @@ -28,6 +29,7 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char memcpy(ep->space,data,datalen); sp->Komodo_events = (struct komodo_event **)realloc(sp->Komodo_events,(1 + sp->Komodo_numevents) * sizeof(*sp->Komodo_events)); sp->Komodo_events[sp->Komodo_numevents++] = ep; + portable_mutex_unlock(&komodo_mutex); return(ep); } diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 5cea65f95..cbfca6563 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -168,6 +168,7 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not printf("komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); return; } + portable_mutex_lock(&komodo_mutex); sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); np = &sp->NPOINTS[sp->NUM_NPOINTS++]; memset(np,0,sizeof(*np)); @@ -175,6 +176,7 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; + portable_mutex_unlock(&komodo_mutex); } //struct komodo_state *komodo_stateptr(char *symbol,char *dest); diff --git a/src/komodo_pax.h b/src/komodo_pax.h index a4af4b5aa..77f7c5f1f 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -285,10 +285,12 @@ void komodo_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals) KMDBTC = ((double)kmdbtc / (1000000000. * 1000.)); BTCUSD = ((double)btcusd / (1000000000. / 1000.)); CNYUSD = ((double)cnyusd / 1000000000.); + portable_mutex_lock(&komodo_mutex); PVALS = (uint32_t *)realloc(PVALS,(NUM_PRICES+1) * sizeof(*PVALS) * 36); PVALS[36 * NUM_PRICES] = height; memcpy(&PVALS[36 * NUM_PRICES + 1],pvals,sizeof(*pvals) * 35); NUM_PRICES++; + portable_mutex_unlock(&komodo_mutex); if ( 0 ) printf("OP_RETURN.%d KMD %.8f BTC %.6f CNY %.6f NUM_PRICES.%d (%llu %llu %llu)\n",height,KMDBTC,BTCUSD,CNYUSD,NUM_PRICES,(long long)kmdbtc,(long long)btcusd,(long long)cnyusd); } From be50d0e9303fbfe3298a756fd9c327f104b9128c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 11:16:40 -0300 Subject: [PATCH 162/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a20b3868d..bd151fa76 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -486,7 +486,7 @@ void komodo_passport_iteration() if ( ftell(fp) > lastpos[baseid] ) { fseek(fp,lastpos[baseid],SEEK_SET); - while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) + while ( komodo_parsestatefile(0,fp,symbol,dest) >= 0 ) ; lastpos[baseid] = ftell(fp); //printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); From 36ec445a12baa072b61559fa82e4fcf60e751afa Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 11:19:54 -0300 Subject: [PATCH 163/549] test --- src/komodo_events.h | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index b5178d396..828be84aa 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -18,18 +18,21 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char *symbol,uint8_t type,uint8_t *data,uint16_t datalen) { - struct komodo_event *ep; uint16_t len = (uint16_t)(sizeof(*ep) + datalen); - portable_mutex_lock(&komodo_mutex); - ep = (struct komodo_event *)calloc(1,len); - ep->len = len; - ep->height = height; - ep->type = type; - strcpy(ep->symbol,symbol); - if ( datalen != 0 ) - memcpy(ep->space,data,datalen); - sp->Komodo_events = (struct komodo_event **)realloc(sp->Komodo_events,(1 + sp->Komodo_numevents) * sizeof(*sp->Komodo_events)); - sp->Komodo_events[sp->Komodo_numevents++] = ep; - portable_mutex_unlock(&komodo_mutex); + struct komodo_event *ep=0; uint16_t len = (uint16_t)(sizeof(*ep) + datalen); + if ( sp != 0 ) + { + portable_mutex_lock(&komodo_mutex); + ep = (struct komodo_event *)calloc(1,len); + ep->len = len; + ep->height = height; + ep->type = type; + strcpy(ep->symbol,symbol); + if ( datalen != 0 ) + memcpy(ep->space,data,datalen); + sp->Komodo_events = (struct komodo_event **)realloc(sp->Komodo_events,(1 + sp->Komodo_numevents) * sizeof(*sp->Komodo_events)); + sp->Komodo_events[sp->Komodo_numevents++] = ep; + portable_mutex_unlock(&komodo_mutex); + } return(ep); } @@ -124,13 +127,16 @@ void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height) void komodo_setkmdheight(struct komodo_state *sp,int32_t kmdheight,uint32_t timestamp) { - if ( kmdheight > sp->SAVEDHEIGHT ) + if ( sp != 0 ) { - sp->SAVEDHEIGHT = kmdheight; - sp->SAVEDTIMESTAMP = timestamp; + if ( kmdheight > sp->SAVEDHEIGHT ) + { + sp->SAVEDHEIGHT = kmdheight; + sp->SAVEDTIMESTAMP = timestamp; + } + if ( kmdheight > sp->CURRENT_HEIGHT ) + sp->CURRENT_HEIGHT = kmdheight; } - if ( kmdheight > sp->CURRENT_HEIGHT ) - sp->CURRENT_HEIGHT = kmdheight; } void komodo_eventadd_kmdheight(struct komodo_state *sp,char *symbol,int32_t height,int32_t kmdheight,uint32_t timestamp) From 807200e454bc2b5bb4cb2f3300e0aa88d760a4b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 11:22:48 -0300 Subject: [PATCH 164/549] test --- src/komodo.h | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0f46a9f71..0b79fee5e 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -99,7 +99,8 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char errs++; if ( fread(¬arized_desttxid,1,sizeof(notarized_desttxid),fp) != sizeof(notarized_desttxid) ) errs++; - printf("%s %p %p[%d] load[%s] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,sp,sp->NPOINTS,sp->NUM_NPOINTS,symbol,notarized_height,notarized_hash.ToString().c_str()); + if ( sp != 0 ) + printf("%s %p %p[%d] load[%s] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,sp,sp->NPOINTS,sp->NUM_NPOINTS,symbol,notarized_height,notarized_hash.ToString().c_str()); //if ( matched != 0 ) global independent states -> inside *sp komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); } @@ -297,17 +298,19 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar else if ( height != 0 ) { //printf("ht.%d func N ht.%d errs.%d\n",height,NOTARIZED_HEIGHT,errs); - fputc('N',fp); - if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) ) - errs++; - if ( fwrite(&sp->NOTARIZED_HEIGHT,1,sizeof(sp->NOTARIZED_HEIGHT),fp) != sizeof(sp->NOTARIZED_HEIGHT) ) - errs++; - if ( fwrite(&sp->NOTARIZED_HASH,1,sizeof(sp->NOTARIZED_HASH),fp) != sizeof(sp->NOTARIZED_HASH) ) - errs++; - if ( fwrite(&sp->NOTARIZED_DESTTXID,1,sizeof(sp->NOTARIZED_DESTTXID),fp) != sizeof(sp->NOTARIZED_DESTTXID) ) - errs++; - komodo_eventadd_notarized(sp,symbol,height,dest,sp->NOTARIZED_HASH,sp->NOTARIZED_DESTTXID,sp->NOTARIZED_HEIGHT); - //komodo_notarized_update(height,NOTARIZED_HEIGHT,NOTARIZED_HASH,NOTARIZED_DESTTXID); + if ( sp != 0 ) + { + fputc('N',fp); + if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) ) + errs++; + if ( fwrite(&sp->NOTARIZED_HEIGHT,1,sizeof(sp->NOTARIZED_HEIGHT),fp) != sizeof(sp->NOTARIZED_HEIGHT) ) + errs++; + if ( fwrite(&sp->NOTARIZED_HASH,1,sizeof(sp->NOTARIZED_HASH),fp) != sizeof(sp->NOTARIZED_HASH) ) + errs++; + if ( fwrite(&sp->NOTARIZED_DESTTXID,1,sizeof(sp->NOTARIZED_DESTTXID),fp) != sizeof(sp->NOTARIZED_DESTTXID) ) + errs++; + komodo_eventadd_notarized(sp,symbol,height,dest,sp->NOTARIZED_HASH,sp->NOTARIZED_DESTTXID,sp->NOTARIZED_HEIGHT); + } } fflush(fp); } From 9534c87a2e42663ca951db5a65e5dcbe4e51271e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 11:25:57 -0300 Subject: [PATCH 165/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index bd151fa76..a20b3868d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -486,7 +486,7 @@ void komodo_passport_iteration() if ( ftell(fp) > lastpos[baseid] ) { fseek(fp,lastpos[baseid],SEEK_SET); - while ( komodo_parsestatefile(0,fp,symbol,dest) >= 0 ) + while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) ; lastpos[baseid] = ftell(fp); //printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); From e8433f7a918ec50e7775c57a2efb1ee6de7dd01d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 11:39:42 -0300 Subject: [PATCH 166/549] test --- src/komodo_gateway.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a20b3868d..e91c33f85 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -108,7 +108,6 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio opretbuf[len++] = ((uint8_t *)&pax->txid)[i]; opretbuf[len++] = pax->vout & 0xff; opretbuf[len++] = (pax->vout >> 8) & 0xff; - //printf(" issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->fiatoshis),&pax->komodoshis); len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->fiatoshis),&pax->fiatoshis); len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->height),&pax->height); @@ -121,19 +120,20 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) { - struct pax_transaction p; int32_t i,n=0,j,len,incr,height,otherheight; uint8_t rmd160[20]; uint64_t fiatoshis; char symbol[16]; + struct pax_transaction p; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t rmd160[20]; uint64_t fiatoshis; char symbol[16]; for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) { opretbuf++, opretlen--; incr = 34 + (iskomodo * (sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); - for (n=len=0; n Date: Mon, 21 Nov 2016 11:47:30 -0300 Subject: [PATCH 167/549] test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e91c33f85..58d22d72b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -126,14 +126,14 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) { opretbuf++, opretlen--; - incr = 34 + (iskomodo * (sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); + incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); for (n=0; n lastpos[baseid] ) { + printf("passport refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); fseek(fp,lastpos[baseid],SEEK_SET); while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) ; From a3f1fb69d1d29d44e83394bce901d730cfb8e1ca Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 11:53:46 -0300 Subject: [PATCH 168/549] test --- src/komodo_gateway.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 58d22d72b..3b3124867 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -104,6 +104,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transaction *pax) { int32_t i,len = 0; +return(0); for (i=0; i<32; i++) opretbuf[len++] = ((uint8_t *)&pax->txid)[i]; opretbuf[len++] = pax->vout & 0xff; @@ -136,11 +137,11 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t len += komodo_rwapproval(0,&opretbuf[len],&p); if ( values != 0 && kmdheights != 0 && otherheights != 0 && baseids != 0 ) { - values[i] = (ASSETCHAINS_SYMBOL[0] == 0) ? p.komodoshis : p.fiatoshis; - kmdheights[i] = p.height; - otherheights[i] = p.otherheight; + values[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? p.komodoshis : p.fiatoshis; + kmdheights[n] = p.height; + otherheights[n] = p.otherheight; memcpy(&rmd160s[n * 20],p.rmd160,20); - baseids[i] = komodo_baseid(p.symbol); + baseids[n] = komodo_baseid(p.symbol); } printf(">>>>>>> iskomodo X: (%s) fiat %.8f kmdheight.%d other.%d\n",symbol,dstr(fiatoshis),height,otherheight); } From 1fd577185163d639aeebca969d7e9de2b105d497 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 12:00:17 -0300 Subject: [PATCH 169/549] test --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 9f0746f94..8267135d9 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -362,8 +362,8 @@ uint256 komodo_getblockhash(int32_t height) } free_json(result); } - printf("KMD hash.%d (%s)\n",height,hexstr); - free(hexstr); + printf("KMD hash.%d (%s) %x\n",height,jsonstr,*(uint32_t *)&hash); + free(jsonstr); } return(hash); } From c7caa0dab26b48d4da6fac1fa38266cda13b91ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 12:03:43 -0300 Subject: [PATCH 170/549] test --- src/komodo_gateway.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3b3124867..5ee767cc7 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -104,7 +104,6 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transaction *pax) { int32_t i,len = 0; -return(0); for (i=0; i<32; i++) opretbuf[len++] = ((uint8_t *)&pax->txid)[i]; opretbuf[len++] = pax->vout & 0xff; @@ -130,7 +129,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); for (n=0; n lastpos[baseid] ) { - printf("passport refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); + //printf("passport refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); fseek(fp,lastpos[baseid],SEEK_SET); while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) ; From 7a6cee3fde5c027ecd42f8c2bc6354d793bdf0dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 12:06:59 -0300 Subject: [PATCH 171/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 0b79fee5e..967386695 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -99,7 +99,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char errs++; if ( fread(¬arized_desttxid,1,sizeof(notarized_desttxid),fp) != sizeof(notarized_desttxid) ) errs++; - if ( sp != 0 ) + if ( 0 && sp != 0 ) printf("%s %p %p[%d] load[%s] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,sp,sp->NPOINTS,sp->NUM_NPOINTS,symbol,notarized_height,notarized_hash.ToString().c_str()); //if ( matched != 0 ) global independent states -> inside *sp komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); From e9f49d50a5ded3a46e260698b272d48d88f5e696 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 12:18:20 -0300 Subject: [PATCH 172/549] test --- src/komodo_bitcoind.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 8267135d9..2cdd9ba20 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -348,7 +348,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) uint256 komodo_getblockhash(int32_t height) { - uint256 hash; char params[128],*hexstr,*jsonstr; cJSON *result; + uint256 hash; char params[128],*hexstr,*jsonstr; cJSON *result; uint8_t revbuf[32]; memset(&hash,0,sizeof(hash)); sprintf(params,"[%d]",height); if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getblockhash",params,7771)) != 0 ) @@ -358,7 +358,11 @@ uint256 komodo_getblockhash(int32_t height) if ( (hexstr= jstr(result,(char *)"result")) != 0 ) { if ( is_hexstr(hexstr,0) == 64 ) - decode_hex((uint8_t *)&hash,32,hexstr); + { + decode_hex(revbuf,32,hexstr); + for (i=0; i<32; i++) + ((uint8_t *)&hash)[i] = revbuf[31-i]; + } } free_json(result); } From dffceecf728aa29fd80cecd74148366001b35347 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 12:19:27 -0300 Subject: [PATCH 173/549] test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2cdd9ba20..6878114b6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -348,7 +348,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) uint256 komodo_getblockhash(int32_t height) { - uint256 hash; char params[128],*hexstr,*jsonstr; cJSON *result; uint8_t revbuf[32]; + uint256 hash; char params[128],*hexstr,*jsonstr; cJSON *result; int32_t i; uint8_t revbuf[32]; memset(&hash,0,sizeof(hash)); sprintf(params,"[%d]",height); if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getblockhash",params,7771)) != 0 ) From e97777b3b6b31d0cde02d539ed547801d970e8ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 12:27:43 -0300 Subject: [PATCH 174/549] test --- src/komodo_gateway.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5ee767cc7..522cbf3a3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -416,11 +416,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } - else - { - printf(" %.8f -> %s withdraw already there\n",dstr(value),coinaddr); - komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height); - } + komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height); } } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) From 9a2ff5ad15f6ae6ed85cf0b4c9e39272bd2071cc Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 12:37:36 -0300 Subject: [PATCH 175/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 7fe6dd34b..fffbee299 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -99,7 +99,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, } #define ASSETCHAINS_MINHEIGHT 100 -#define ROUNDROBIN_DELAY 61 +#define ROUNDROBIN_DELAY 77 extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; From cd26c1f3a96e36f52a88f2b31293a91ed5d48526 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 13:08:39 -0300 Subject: [PATCH 176/549] test --- src/komodo_events.h | 2 +- src/komodo_gateway.h | 24 +++++++++++++----------- src/komodo_structs.h | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index 828be84aa..0a5034a73 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -84,7 +84,7 @@ void komodo_eventadd_opreturn(struct komodo_state *sp,char *symbol,int32_t heigh O.oplen = (int32_t)(opretlen + sizeof(O)); komodo_eventadd(sp,height,symbol,KOMODO_EVENT_OPRETURN,opret,O.oplen); if ( sp != 0 ) - komodo_opreturn(height,value,buf,opretlen,txid,vout); + komodo_opreturn(height,value,buf,opretlen,txid,vout,symbol); } void komodo_event_undo(struct komodo_state *sp,struct komodo_event *ep) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 522cbf3a3..dd90ec80c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -51,7 +51,7 @@ struct pax_transaction *komodo_paxmark(int32_t height,struct pax_transaction *sp return(pax); } -void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight) // assetchain context +void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight,char *source) // assetchain context { struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16]; sp = komodo_stateptr(str,dest); @@ -79,6 +79,8 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t pax->komodoshis = value; if ( symbol != 0 ) strcpy(pax->symbol,symbol); + if ( source != 0 ) + strcpy(pax->source,source); if ( fiatoshis != 0 ) pax->fiatoshis = fiatoshis; if ( rmd160 != 0 ) @@ -90,7 +92,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( pax->marked == 0 ) { if ( addflag != 0 ) - printf("[%s] addflag.%d ADD DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,symbol,dstr(fiatoshis),coinaddr,height,otherheight,dstr(komodo_paxtotal())); + printf("[%s] addflag.%d ADD %s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,ASSETCHAINS_SYMBOL[0]==0?"WITHDRAW":"DEPOSIT",symbol,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); } //else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height,otherheight); } @@ -114,7 +116,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->otherheight),&pax->otherheight); memcpy(&opretbuf[len],pax->rmd160,20), len += 20; for (i=0; i<4; i++) - opretbuf[len++] = pax->symbol[i]; + opretbuf[len++] = pax->source[i]; return(len); } @@ -353,7 +355,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above return(0); } -const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout) +const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64]; struct pax_transaction *pax; const char *typestr = "unknown"; @@ -394,7 +396,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( komodo_paxfind(&space,txid,vout) == 0 ) { - komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height); + komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD"); } else printf("duplicate deposit\n"); } } @@ -416,19 +418,19 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } - komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height); + komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height,source); } } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) { - if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 ) + if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) { for (i=0; i= 0 ) { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],kmdheights[i],otherheights[i]); + komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]]); } else pax->approved = kmdheights[i]; } } @@ -442,8 +444,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 for (i=0; i= 0 ) + komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]]); } } } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 453bb35e0..b7d776702 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -59,7 +59,7 @@ struct pax_transaction uint64_t komodoshis,fiatoshis; int32_t marked,height,otherheight,approved; uint16_t vout; - char symbol[16],coinaddr[64]; uint8_t rmd160[20],shortflag; + char symbol[16],source[16],coinaddr[64]; uint8_t rmd160[20],shortflag; }; //struct nutxo_entry { UT_hash_handle hh; uint256 txhash; uint64_t voutmask; int32_t notaryid,height; }; From f97d3439b412ddef0679a5999e718ad46ce2ca09 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 13:19:19 -0300 Subject: [PATCH 177/549] test --- src/komodo_gateway.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index dd90ec80c..1cc0bb9cb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -187,7 +187,7 @@ int32_t komodo_pending_withdraws(char *opretstr) return(0); HASH_ITER(hh,PAX,pax,tmp) { - printf("pax %s marked.%u approved.%u\n",pax->symbol,pax->marked,pax->approved); + //printf("pax %s marked.%u approved.%u\n",pax->symbol,pax->marked,pax->approved); if ( pax->marked == 0 && strcmp((char *)"KMD",pax->symbol) == 0 && pax->approved == 0 ) { // add 'A' opreturn entry @@ -431,7 +431,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]]); - } else pax->approved = kmdheights[i]; + } + if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) != 0 ) + pax->approved = kmdheights[i]; } } } From d7227bf643b24781d4d8bcbdbf7bc19572fe34c4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 13:52:57 -0300 Subject: [PATCH 178/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 967386695..0cf6d5324 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -444,6 +444,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) int32_t i,j,k,numnotaries,notarized,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; memset(&zero,0,sizeof(zero)); komodo_init(pindex->nHeight); + KOMODO_INITDONE = (uint32_t)time(NULL); if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) return; numnotaries = komodo_notaries(pubkeys,pindex->nHeight); @@ -465,7 +466,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) sleep(3); } } - //KOMODO_INITDONE = (uint32_t)time(NULL); if ( pindex != 0 ) { height = pindex->nHeight; From 0f99d3c46980d532dac1aab6b48d84578f22e209 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 14:07:46 -0300 Subject: [PATCH 179/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1cc0bb9cb..cfe40710f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -392,7 +392,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 for (i=0; i<33; i++) printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); - if ( value == checktoshis )//value >= checktoshis || (seed == 0 && diff < .01) ) + if ( value >= checktoshis-(checktoshis >> 10) ) { if ( komodo_paxfind(&space,txid,vout) == 0 ) { @@ -412,7 +412,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value); typestr = "withdraw"; printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); - if ( checktoshis == komodoshis ) + if ( checktoshis <= komodoshis+(komodoshis >> 10) ) { if ( (pax= komodo_paxfind(&space,txid,vout)) == 0 ) { From d90509ae2addb9177ecef3f78641c3ab82819ae1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 14:23:26 -0300 Subject: [PATCH 180/549] test --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0cf6d5324..a4a396cb5 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -458,14 +458,14 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0); } komodo_currentheight_set(chainActive.Tip()->nHeight); - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + /*if ( ASSETCHAINS_SYMBOL[0] != 0 ) { while ( KOMODO_PASSPORT_INITDONE == 0 ) { fprintf(stderr,"komodo_connect.(%s) waiting for KOMODO_PASSPORT_INITDONE.%u\n",ASSETCHAINS_SYMBOL,KOMODO_PASSPORT_INITDONE); sleep(3); } - } + }*/ if ( pindex != 0 ) { height = pindex->nHeight; From a96fd7b542c48662c1abc571792ac2d70eb1d143 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 14:30:02 -0300 Subject: [PATCH 181/549] test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index fffbee299..7f290770e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -550,8 +550,8 @@ void static BitcoinMiner(CWallet *pwallet) { if (chainparams.MiningRequiresPeers()) { - if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) - break; + //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) + // break; // Busy-wait for the network to come online so we don't waste time mining // on an obsolete chain. In regtest mode we expect to fly solo. //fprintf(stderr,"Wait for peers...\n"); From 8fc7222dcdcb048df58bb014c49d26b077d81247 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 14:35:39 -0300 Subject: [PATCH 182/549] test --- src/miner.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index 7f290770e..e2a0ca6a3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -569,6 +569,11 @@ void static BitcoinMiner(CWallet *pwallet) } while (true); //fprintf(stderr,"%s Found peers\n",ASSETCHAINS_SYMBOL); } + while ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight < 100 ) + { + fprintf(stderr,"%s waiting for block 100, ht.%d\n",ASSETCHAINS_SYMBOL,chainActive.Tip()->nHeight); + sleep(3); + } // // Create new block // From d82623d257c7846d160511691987c69b12713549 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 15:14:16 -0300 Subject: [PATCH 183/549] test --- src/komodo_bitcoind.h | 16 +++++++++------- src/miner.cpp | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 6878114b6..27d88d9b5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -550,12 +550,14 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash) { - int32_t notarized_height; uint256 notarized_hash,notarized_desttxid; CBlockIndex *notary; - notarized_height = komodo_notarizeddata(chainActive.Tip()->nHeight,¬arized_hash,¬arized_desttxid); + int32_t notarized_height; uint256 notarized_hash,notarized_desttxid; CBlockIndex *notary; CBlockIndex *pindex; + if ( (pindex= chainActive.Tip()) == 0 ) + return(-1); + notarized_height = komodo_notarizeddata(pindex->nHeight,¬arized_hash,¬arized_desttxid); *notarized_heightp = notarized_height; - if ( notarized_height >= 0 && notarized_height <= chainActive.Tip()->nHeight && (notary= mapBlockIndex[notarized_hash]) != 0 ) + if ( notarized_height >= 0 && notarized_height <= pindex->nHeight && (notary= mapBlockIndex[notarized_hash]) != 0 ) { - //printf("nHeight.%d -> (%d %s)\n",chainActive.Tip()->nHeight,notarized_height,notarized_hash.ToString().c_str()); + //printf("nHeight.%d -> (%d %s)\n",pindex->Tip()->nHeight,notarized_height,notarized_hash.ToString().c_str()); if ( notary->nHeight == notarized_height ) // if notarized_hash not in chain, reorg { if ( nHeight < notarized_height ) @@ -570,7 +572,7 @@ int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 has } } else fprintf(stderr,"unexpected error notary_hash %s ht.%d at ht.%d\n",notarized_hash.ToString().c_str(),notarized_height,notary->nHeight); } else if ( notarized_height > 0 && notarized_height != 73880 ) - fprintf(stderr,"[%s] couldnt find notarized.(%s %d) ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height,chainActive.Tip()->nHeight); + fprintf(stderr,"[%s] couldnt find notarized.(%s %d) ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height,pindex->nHeight); return(0); } @@ -611,11 +613,11 @@ uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 int32_t komodo_isrealtime(int32_t *kmdheightp) { - struct komodo_state *sp; + struct komodo_state *sp; CBlockIndex *pindex; if ( (sp= komodo_stateptrget((char *)"KMD")) != 0 ) *kmdheightp = sp->CURRENT_HEIGHT; else *kmdheightp = 0; - if ( chainActive.Tip()->nHeight == (int32_t)komodo_longestchain() ) + if ( (pindex= chainActive.Tip()) != 0 && pindex->nHeight == (int32_t)komodo_longestchain() ) return(1); else return(0); } diff --git a/src/miner.cpp b/src/miner.cpp index e2a0ca6a3..6a5fda4d1 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -569,11 +569,11 @@ void static BitcoinMiner(CWallet *pwallet) } while (true); //fprintf(stderr,"%s Found peers\n",ASSETCHAINS_SYMBOL); } - while ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight < 100 ) + /*while ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight < 100 ) { fprintf(stderr,"%s waiting for block 100, ht.%d\n",ASSETCHAINS_SYMBOL,chainActive.Tip()->nHeight); sleep(3); - } + }*/ // // Create new block // From ef1a963671edf2d4fb3eea4f893bb202359a53b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 15:29:55 -0300 Subject: [PATCH 184/549] test --- src/komodo.h | 2 +- src/komodo_events.h | 2 +- src/komodo_gateway.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index a4a396cb5..7e5e7aec0 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -139,7 +139,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char } else if ( func == 'R' ) { - uint16_t olen,v; uint64_t ovalue; uint256 txid; uint8_t opret[10000]; + uint16_t olen,v; uint64_t ovalue; uint256 txid; uint8_t opret[16384]; if ( fread(&txid,1,sizeof(txid),fp) != sizeof(txid) ) errs++; if ( fread(&v,1,sizeof(v),fp) != sizeof(v) ) diff --git a/src/komodo_events.h b/src/komodo_events.h index 0a5034a73..e38708918 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -74,7 +74,7 @@ void komodo_eventadd_pricefeed(struct komodo_state *sp,char *symbol,int32_t heig void komodo_eventadd_opreturn(struct komodo_state *sp,char *symbol,int32_t height,uint256 txid,uint64_t value,uint16_t vout,uint8_t *buf,uint16_t opretlen) { - struct komodo_event_opreturn O; uint8_t opret[10000]; + struct komodo_event_opreturn O; uint8_t opret[16384]; memset(&O,0,sizeof(O)); O.txid = txid; O.value = value; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index cfe40710f..2d95d9ea0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -182,7 +182,7 @@ uint64_t komodo_paxtotal() int32_t komodo_pending_withdraws(char *opretstr) { - struct pax_transaction *pax,*tmp; uint8_t opretbuf[10000]; int32_t ht,len=0; uint64_t total = 0; + struct pax_transaction *pax,*tmp; uint8_t opretbuf[16384]; int32_t ht,len=0; uint64_t total = 0; if ( komodo_isrealtime(&ht) == 0 || ASSETCHAINS_SYMBOL[0] != 0 ) return(0); HASH_ITER(hh,PAX,pax,tmp) @@ -204,7 +204,7 @@ int32_t komodo_pending_withdraws(char *opretstr) int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t tokomodo) { - struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t mask; + struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[16384],data[16384]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t mask; sp = komodo_stateptr(symbol,dest); strcpy(symbol,base); PENDING_KOMODO_TX = 0; From c29e766f504b1ffb65557b9d69e970f84c8d2042 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 15:44:34 -0300 Subject: [PATCH 185/549] test --- src/rpcblockchain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 8bfb19629..b79c2e90c 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -398,9 +398,9 @@ Value notaries(const Array& params, bool fHelp) if ( height < 0 ) height = 0; //fprintf(stderr,"notaries as of height.%d\n",height); - if ( height > chainActive.Height()+20000 ) - throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); - else + //if ( height > chainActive.Height()+20000 ) + // throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); + //else { if ( (n= komodo_notaries(pubkeys,height)) > 0 ) { From 7ba6b48d571f832a5afadc417d5120bc5bbf2815 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 15:59:30 -0300 Subject: [PATCH 186/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 7e5e7aec0..350b1a486 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -177,7 +177,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char //printf("load pvals ht.%d numpvals.%d\n",ht,numpvals); } else printf("error loading pvals[%d]\n",numpvals); } - else printf("illegal func.(%d %c)\n",func,func); + else printf("[%s] %s illegal func.(%d %c)\n",ASSETCHAINS_SYMBOL,symbol,func,func); return(func); } else return(-1); } From ede04b12fbad664ec4ef6972af35ee48d2dcf64f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 16:06:38 -0300 Subject: [PATCH 187/549] test --- src/komodo_gateway.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2d95d9ea0..b340954cc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -163,17 +163,21 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t uint64_t komodo_paxtotal() { - struct pax_transaction *pax,*tmp; int32_t ht; uint64_t total = 0; + struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; int32_t ht; uint64_t total = 0; if ( komodo_isrealtime(&ht) == 0 ) return(0); + komodo_stateptr(symbol,dest); HASH_ITER(hh,PAX,pax,tmp) { //printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); - if ( pax->marked == 0 ) + if ( strcmp(symbol,pax->symbol) == 0 ) { - if ( komodo_is_issuer() != 0 ) - total += pax->fiatoshis; - else total += pax->komodoshis; + if ( pax->marked == 0 ) + { + if ( komodo_is_issuer() != 0 ) + total += pax->fiatoshis; + else total += pax->komodoshis; + } } } //printf("paxtotal %.8f\n",dstr(total)); From a8aa4375611ca13634e929b35c2ba7c790ce6077 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 16:24:34 -0300 Subject: [PATCH 188/549] test --- src/miner.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 6a5fda4d1..749e31ce0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -657,10 +657,6 @@ void static BitcoinMiner(CWallet *pwallet) cancelSolver = false; } KOMODO_CHOSEN_ONE = 0; - int32_t i; uint256 hash = pblock->GetHash(); - for (i=0; i<32; i++) - fprintf(stderr,"%02x",((uint8_t *)&hash)[i]); - fprintf(stderr," <- %s Block found %d\n",ASSETCHAINS_SYMBOL,Mining_height); SetThreadPriority(THREAD_PRIORITY_LOWEST); // In regression test mode, stop mining after a block is found. if (chainparams.MineBlocksOnDemand()) { @@ -714,6 +710,10 @@ void static BitcoinMiner(CWallet *pwallet) bool found = EhOptimisedSolve(n, k, curr_state, validBlock, cancelled); ehSolverRuns.increment(); if (found) { + int32_t i; uint256 hash = pblock->GetHash(); + for (i=0; i<32; i++) + fprintf(stderr,"%02x",((uint8_t *)&hash)[i]); + fprintf(stderr," <- %s Block found %d\n",ASSETCHAINS_SYMBOL,Mining_height); break; } } catch (EhSolverCancelledException&) { From 97b426a8cdb341ce69aaed8ee6eca90fbc3ea053 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 17:36:49 -0300 Subject: [PATCH 189/549] test --- src/assetfunds | 33 +++++++++++++++++++++++++++++++++ src/script/standard.cpp | 1 + 2 files changed, 34 insertions(+) create mode 100755 src/assetfunds diff --git a/src/assetfunds b/src/assetfunds new file mode 100755 index 000000000..b2bee93c1 --- /dev/null +++ b/src/assetfunds @@ -0,0 +1,33 @@ +#!/bin/bash +./komodo-cli paxdeposit $1 aud 0.01 +./komodo-cli paxdeposit $1 bgn 0.01 +./komodo-cli paxdeposit $1 cad 0.01 +./komodo-cli paxdeposit $1 chf 0.01 +./komodo-cli paxdeposit $1 cny 0.01 +./komodo-cli paxdeposit $1 czk 0.01 +./komodo-cli paxdeposit $1 dkk 0.01 +./komodo-cli paxdeposit $1 eur 0.01 +./komodo-cli paxdeposit $1 gbp 0.01 +./komodo-cli paxdeposit $1 hkd 0.01 +./komodo-cli paxdeposit $1 hrk 0.01 +./komodo-cli paxdeposit $1 huf 0.01 +./komodo-cli paxdeposit $1 idr 0.01 +./komodo-cli paxdeposit $1 ils 0.01 +./komodo-cli paxdeposit $1 inr 0.01 +./komodo-cli paxdeposit $1 jpy 0.01 +./komodo-cli paxdeposit $1 krw 0.01 +./komodo-cli paxdeposit $1 mxn 0.01 +./komodo-cli paxdeposit $1 myr 0.01 +./komodo-cli paxdeposit $1 nok 0.01 +./komodo-cli paxdeposit $1 nzd 0.01 +./komodo-cli paxdeposit $1 php 0.01 +./komodo-cli paxdeposit $1 pln 0.01 +./komodo-cli paxdeposit $1 brl 0.01 +./komodo-cli paxdeposit $1 ron 0.01 +./komodo-cli paxdeposit $1 rub 0.01 +./komodo-cli paxdeposit $1 sek 0.01 +./komodo-cli paxdeposit $1 sgd 0.01 +./komodo-cli paxdeposit $1 thb 0.01 +./komodo-cli paxdeposit $1 try 0.01 +./komodo-cli paxdeposit $1 usd 0.01 +./komodo-cli paxdeposit $1 zar 0.01 diff --git a/src/script/standard.cpp b/src/script/standard.cpp index e4f9fc1c1..6c2cfbfbb 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -143,6 +143,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector nMaxDatacarrier.%d\n",vch1.size(),nMaxDatacarrierBytes); if (vch1.size() > nMaxDatacarrierBytes) break; } From a2829a0c4558a6fcc51b1224dd7c727e79938a7b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 17:38:24 -0300 Subject: [PATCH 190/549] test --- src/script/standard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 6c2cfbfbb..91c45c93e 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -143,7 +143,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector nMaxDatacarrier.%d\n",vch1.size(),nMaxDatacarrierBytes); + fprintf(stderr,"size.%d > nMaxDatacarrier.%d\n",(int32_t)vch1.size(),(int32_t)nMaxDatacarrierBytes); if (vch1.size() > nMaxDatacarrierBytes) break; } From cc0f93da2e920e4d8692868a453227e67483b2ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 17:47:23 -0300 Subject: [PATCH 191/549] test --- src/main.cpp | 10 +++++++--- src/script/standard.cpp | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0e1b84341..840ab46f6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -676,14 +676,18 @@ bool IsStandardTx(const CTransaction& tx, string& reason) txnouttype whichType; BOOST_FOREACH(const CTxOut& txout, tx.vout) { - if (!::IsStandard(txout.scriptPubKey, whichType)) { - reason = "scriptpubkey"; - fprintf(stderr,"vout.%d nDataout.%d\n",v,nDataOut); + if (!::IsStandard(txout.scriptPubKey, whichType)) + { + reason = "scriptpubkeyA"; + fprintf(stderr,">>>>>>>>>>>>>>> vout.%d nDataout.%d\n",v,nDataOut); return false; } if (whichType == TX_NULL_DATA) + { nDataOut++; + fprintf(stderr,"is OP_RETURN\n"); + } else if ((whichType == TX_MULTISIG) && (!fIsBareMultisigStd)) { reason = "bare-multisig"; return false; diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 91c45c93e..0fb38fb95 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -143,9 +143,11 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector nMaxDatacarrier.%d\n",(int32_t)vch1.size(),(int32_t)nMaxDatacarrierBytes); if (vch1.size() > nMaxDatacarrierBytes) + { + fprintf(stderr,"size.%d > nMaxDatacarrier.%d\n",(int32_t)vch1.size(),(int32_t)nMaxDatacarrierBytes); break; + } } else if (opcode1 != opcode2 || vch1 != vch2) { @@ -203,7 +205,8 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType) if (m < 1 || m > n) return false; } - + if ( whichtype == TX_NONSTANDARD ) + fprintf(stderr,"IsStandard nonstandard tx\n"); return whichType != TX_NONSTANDARD; } From ce71f7729c9bca3e8d6eff765acd3b3ce95c8c86 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 17:48:52 -0300 Subject: [PATCH 192/549] test --- src/script/standard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 0fb38fb95..d0ec61632 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -205,7 +205,7 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType) if (m < 1 || m > n) return false; } - if ( whichtype == TX_NONSTANDARD ) + if ( whichType == TX_NONSTANDARD ) fprintf(stderr,"IsStandard nonstandard tx\n"); return whichType != TX_NONSTANDARD; } From 7a82f2fc7383b2f83f1d70b0e97e6c12761d4e8f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 18:28:30 -0300 Subject: [PATCH 193/549] test --- src/main.cpp | 4 ++-- src/script/standard.cpp | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 840ab46f6..e2da7de1b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -678,7 +678,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason) { if (!::IsStandard(txout.scriptPubKey, whichType)) { - reason = "scriptpubkeyA"; + reason = "scriptpubkey"; fprintf(stderr,">>>>>>>>>>>>>>> vout.%d nDataout.%d\n",v,nDataOut); return false; } @@ -686,7 +686,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason) if (whichType == TX_NULL_DATA) { nDataOut++; - fprintf(stderr,"is OP_RETURN\n"); + //fprintf(stderr,"is OP_RETURN\n"); } else if ((whichType == TX_MULTISIG) && (!fIsBareMultisigStd)) { reason = "bare-multisig"; diff --git a/src/script/standard.cpp b/src/script/standard.cpp index d0ec61632..71838853d 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -205,8 +205,6 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType) if (m < 1 || m > n) return false; } - if ( whichType == TX_NONSTANDARD ) - fprintf(stderr,"IsStandard nonstandard tx\n"); return whichType != TX_NONSTANDARD; } From 06d1a655601687ca7aec91c51c6b4adea0511b70 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 18:58:25 -0300 Subject: [PATCH 194/549] test --- src/komodo.h | 3 +++ src/komodo_gateway.h | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 350b1a486..92fad493d 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -379,7 +379,10 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_DESTTXID = desttxid; komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0); if ( opretlen > len && scriptbuf[len] == 'A' ) + { + printf("Found extradata.[%d]\n",opretlen-len); komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len,j); + } } else printf("notarized.%d %llx reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",notarized,(long long)signedmask,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]); } else if ( i == 0 && j == 1 && opretlen == 149 ) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b340954cc..38aeb1847 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -427,6 +427,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) { + printf("extra 'A' opret[%d]\n",opretlen); if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) { for (i=0; iapproved = kmdheights[i]; + printf("i.%d approved.%d\n",i,kmdheights[i]); + } } } + printf("extra.[%d]\n",n); } else if ( tokomodo == 0 && opretbuf[0] == 'I' ) { From 400ee585823a2fbffe187496003e23e3892237e5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 19:07:29 -0300 Subject: [PATCH 195/549] test --- src/komodo.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 92fad493d..0731510fa 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -152,7 +152,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char { if ( fread(opret,1,olen,fp) != olen ) errs++; - if ( matched != 0 ) + //if ( matched != 0 ) { int32_t i; for (i=0; i sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len]); From bc63863b182771d2a14ff8fae79f56237741b9d5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 19:14:10 -0300 Subject: [PATCH 196/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 0731510fa..7f1dc72ba 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -99,7 +99,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char errs++; if ( fread(¬arized_desttxid,1,sizeof(notarized_desttxid),fp) != sizeof(notarized_desttxid) ) errs++; - if ( 0 && sp != 0 ) + //if ( 0 && sp != 0 ) printf("%s %p %p[%d] load[%s] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,sp,sp->NPOINTS,sp->NUM_NPOINTS,symbol,notarized_height,notarized_hash.ToString().c_str()); //if ( matched != 0 ) global independent states -> inside *sp komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); From 41f5997a57b0850a3b683d84f5bfed0e50bf4927 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 19:25:48 -0300 Subject: [PATCH 197/549] test --- src/komodo.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 7f1dc72ba..f1b06ae28 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -371,7 +371,6 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&kmdtxid); len += iguana_rwnum(0,&scriptbuf[len],4,(uint8_t *)notarizedheightp); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); -notarized = 1; if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len]); @@ -493,7 +492,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvalid = bitweight(signedmask); if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) { - //printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); + printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); notarized = 1; } for (j=0; j Date: Mon, 21 Nov 2016 19:32:48 -0300 Subject: [PATCH 198/549] test --- src/komodo.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index f1b06ae28..33a716f4b 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -461,14 +461,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0); } komodo_currentheight_set(chainActive.Tip()->nHeight); - /*if ( ASSETCHAINS_SYMBOL[0] != 0 ) - { - while ( KOMODO_PASSPORT_INITDONE == 0 ) - { - fprintf(stderr,"komodo_connect.(%s) waiting for KOMODO_PASSPORT_INITDONE.%u\n",ASSETCHAINS_SYMBOL,KOMODO_PASSPORT_INITDONE); - sleep(3); - } - }*/ if ( pindex != 0 ) { height = pindex->nHeight; @@ -490,6 +482,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } numvalid = bitweight(signedmask); + printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); From 3df533905c82fbf826f84bb84655f5afe54b84d2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 19:49:06 -0300 Subject: [PATCH 199/549] test --- src/komodo.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 33a716f4b..67dff6499 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -449,7 +449,10 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_init(pindex->nHeight); KOMODO_INITDONE = (uint32_t)time(NULL); if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) + { + fprintf(stderr,"unexpected null komodostateptr.[%s]\n",ASSETCHAINS_SYMBOL); return; + } numnotaries = komodo_notaries(pubkeys,pindex->nHeight); calc_rmd160_sha256(rmd160,pubkeys[0],33); if ( pindex->nHeight > hwmheight ) @@ -461,6 +464,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0); } komodo_currentheight_set(chainActive.Tip()->nHeight); + printf("HWM.%d connect.%d\n",chainActive.Tip()->nHeight,pindex->nHeight); if ( pindex != 0 ) { height = pindex->nHeight; @@ -545,7 +549,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } if ( pindex->nHeight == hwmheight ) komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0); - } else printf("komodo_connectblock: unexpected null pindex\n"); + } else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n"); //KOMODO_INITDONE = (uint32_t)time(NULL); } From 0dfe3f3680d77cd1208209b66812601a6603810e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 19:57:12 -0300 Subject: [PATCH 200/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 38aeb1847..51eb5f02e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -480,7 +480,7 @@ void komodo_passport_iteration() else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=0; baseid<=32; baseid++) - { + {break; sp = 0; isrealtime = 0; base = (char *)CURRENCIES[baseid]; From 40d3a54fc5d8de5a4b094d1d41ca68e682fee0dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 20:09:33 -0300 Subject: [PATCH 201/549] test --- src/komodo_bitcoind.h | 2 +- src/komodo_gateway.h | 2 +- src/pow.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 27d88d9b5..80d23b4b7 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -535,7 +535,7 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) komodo_chosennotary(¬aryid,height,pubkey33); if ( height >= 34000 && notaryid >= 0 ) { - for (i=1; i<64; i++) + for (i=1; i<60; i++) { if ( komodo_minerid(height-i) == notaryid ) { diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 51eb5f02e..38aeb1847 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -480,7 +480,7 @@ void komodo_passport_iteration() else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=0; baseid<=32; baseid++) - {break; + { sp = 0; isrealtime = 0; base = (char *)CURRENCIES[baseid]; diff --git a/src/pow.cpp b/src/pow.cpp index 8d97786e0..3b64ce72c 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -135,8 +135,8 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in special2 = komodo_is_special(height,pubkey33); if ( special2 == -2 ) printf("height.%d special2.%d special.%d\n",height,special2,special); - if ( special2 == -2 || (height < 70000 && (special != 0 || special2 > 0)) || - (height >= 70000 && special2 > 0) ) + if ( special2 == -2 || (height < 80000 && (special != 0 || special2 > 0)) || + (height >= 80000 && special2 > 0) ) { bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); flag = 1; From bef72b5025e24be13c9eab28c3ac21369d8894d4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 20:18:04 -0300 Subject: [PATCH 202/549] test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 80d23b4b7..7d14c0fc6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -535,7 +535,7 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) komodo_chosennotary(¬aryid,height,pubkey33); if ( height >= 34000 && notaryid >= 0 ) { - for (i=1; i<60; i++) + for (i=1; i<=65; i++) { if ( komodo_minerid(height-i) == notaryid ) { From 28bc6208be8e10099bd0ea2164571eca865cabd1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 20:22:04 -0300 Subject: [PATCH 203/549] test --- src/komodo_bitcoind.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 7d14c0fc6..37eca1d1d 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -531,11 +531,14 @@ int8_t komodo_minerid(int32_t height) int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) { - int32_t i,notaryid,minerid; + int32_t i,notaryid,minerid,limit; komodo_chosennotary(¬aryid,height,pubkey33); if ( height >= 34000 && notaryid >= 0 ) { - for (i=1; i<=65; i++) + if ( height < 79676 ) + limit = 64; + else limit = 66; + for (i=1; i<64; i++) { if ( komodo_minerid(height-i) == notaryid ) { From f111c84c566b347d4b4bfb81e3040d18863db531 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 20:38:39 -0300 Subject: [PATCH 204/549] test --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 67dff6499..1cb641898 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -464,7 +464,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0); } komodo_currentheight_set(chainActive.Tip()->nHeight); - printf("HWM.%d connect.%d\n",chainActive.Tip()->nHeight,pindex->nHeight); if ( pindex != 0 ) { height = pindex->nHeight; @@ -486,7 +485,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } numvalid = bitweight(signedmask); - printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); + if ( height == 79633 ) + notarized = 1; if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); From 1b3ce02cb2a7ca44b2f93f95aab3b89e1407bec6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 05:44:53 -0300 Subject: [PATCH 205/549] test --- src/komodo.h | 3 ++- src/komodo_bitcoind.h | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 1cb641898..1fcc8b5a1 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -371,6 +371,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&kmdtxid); len += iguana_rwnum(0,&scriptbuf[len],4,(uint8_t *)notarizedheightp); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); + len += 4; if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len]); @@ -378,7 +379,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_HASH = kmdtxid; sp->NOTARIZED_DESTTXID = desttxid; komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0); - if ( opretlen > len && scriptbuf[len] == 'A' ) + if ( opretlen > len )//&& scriptbuf[len] == 'A' ) { printf("Found extradata.[%d]\n",opretlen-len); komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len,j); diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 37eca1d1d..ea6cd0cbc 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -535,10 +535,12 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) komodo_chosennotary(¬aryid,height,pubkey33); if ( height >= 34000 && notaryid >= 0 ) { - if ( height < 79676 ) + if ( height < 79693 ) limit = 64; + else if ( height < 82000 ) + limit = 36; else limit = 66; - for (i=1; i<64; i++) + for (i=1; i Date: Tue, 22 Nov 2016 06:42:17 -0300 Subject: [PATCH 206/549] test --- src/miner.cpp | 2 +- src/pow.cpp | 27 +++++++-------------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 749e31ce0..0bb74a0cc 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -605,7 +605,7 @@ void static BitcoinMiner(CWallet *pwallet) if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_is_special(pindexPrev->nHeight+1,NOTARY_PUBKEY33) > 0 ) { hashTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS); - //fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); + fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); } else Mining_start = 0; while (true) { diff --git a/src/pow.cpp b/src/pow.cpp index 3b64ce72c..a5d75e7ba 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -128,31 +128,18 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in } if ( nonz == 0 ) return(true); // will come back via different path with pubkey set - //if ( height > 60000 ) + if ( notaryid >= 0 ) { - if ( notaryid >= 0 ) + special2 = komodo_is_special(height,pubkey33); + if ( special2 == -2 ) + printf("height.%d special2.%d special.%d\n",height,special2,special); + if ( special2 == -2 || (height < 80000 && (special != 0 || special2 > 0)) || + (height >= 80000 && special2 > 0) ) { - special2 = komodo_is_special(height,pubkey33); - if ( special2 == -2 ) - printf("height.%d special2.%d special.%d\n",height,special2,special); - if ( special2 == -2 || (height < 80000 && (special != 0 || special2 > 0)) || - (height >= 80000 && special2 > 0) ) - { - bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); - flag = 1; - } - } - } - /*else - { - if ( special > 0 ) // special notary id == (height % numnotaries) - { - if (UintToArith256(hash) <= bnTarget) // accept normal diff - return true; bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); flag = 1; } - }*/ + } } if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit)) return error("CheckProofOfWork(): nBits below minimum work"); From 3fe63a7d7c2e82d9db03400275c51dc4e45396c9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 06:54:06 -0300 Subject: [PATCH 207/549] test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ea6cd0cbc..dd4eda01a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -538,7 +538,7 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) if ( height < 79693 ) limit = 64; else if ( height < 82000 ) - limit = 36; + limit = 8; else limit = 66; for (i=1; i Date: Tue, 22 Nov 2016 07:02:45 -0300 Subject: [PATCH 208/549] test --- src/miner.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0bb74a0cc..fc991af62 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -609,7 +609,7 @@ void static BitcoinMiner(CWallet *pwallet) } else Mining_start = 0; while (true) { - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + //if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"%s start mining loop\n",ASSETCHAINS_SYMBOL); // Hash state KOMODO_CHOSEN_ONE = 0; @@ -637,13 +637,13 @@ void static BitcoinMiner(CWallet *pwallet) solutionTargetChecks.increment(); if ( UintToArith256(pblock->GetHash()) > hashTarget ) { - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + //if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"missed target\n"); return false; } if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+ROUNDROBIN_DELAY ) { - //printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+ROUNDROBIN_DELAY-time(NULL))); + printf("Round robin diff %d\n",(int32_t)(Mining_start+ROUNDROBIN_DELAY-time(NULL))); sleep(Mining_start+ROUNDROBIN_DELAY-time(NULL)); KOMODO_CHOSEN_ONE = 1; } From cf3a235af2d41705f4145ae9e33775064150e835 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 07:03:33 -0300 Subject: [PATCH 209/549] test --- src/miner.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index fc991af62..0bb74a0cc 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -609,7 +609,7 @@ void static BitcoinMiner(CWallet *pwallet) } else Mining_start = 0; while (true) { - //if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"%s start mining loop\n",ASSETCHAINS_SYMBOL); // Hash state KOMODO_CHOSEN_ONE = 0; @@ -637,13 +637,13 @@ void static BitcoinMiner(CWallet *pwallet) solutionTargetChecks.increment(); if ( UintToArith256(pblock->GetHash()) > hashTarget ) { - //if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"missed target\n"); return false; } if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+ROUNDROBIN_DELAY ) { - printf("Round robin diff %d\n",(int32_t)(Mining_start+ROUNDROBIN_DELAY-time(NULL))); + //printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+ROUNDROBIN_DELAY-time(NULL))); sleep(Mining_start+ROUNDROBIN_DELAY-time(NULL)); KOMODO_CHOSEN_ONE = 1; } From b3a19ed164f2af0d3b117c9caf53e4e3191d070d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 07:11:21 -0300 Subject: [PATCH 210/549] test --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 1fcc8b5a1..e0d96c42e 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -514,8 +514,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } if ( notarized != 0 && (notarizedheight != 0 || specialtx != 0) ) { - printf("%s NOTARY SIGNED.%llx numvins.%d ht.%d txi.%d notaryht.%d specialtx.%d\n",ASSETCHAINS_SYMBOL,(long long)signedmask,numvins,height,i,notarizedheight,specialtx); - printf("ht.%d specialtx.%d isratification.%d numvouts.%d signed.%llx numnotaries.%d\n",height,specialtx,isratification,numvouts,(long long)signedmask,numnotaries); + //printf("%s NOTARY SIGNED.%llx numvins.%d ht.%d txi.%d notaryht.%d specialtx.%d\n",ASSETCHAINS_SYMBOL,(long long)signedmask,numvins,height,i,notarizedheight,specialtx); + //printf("ht.%d specialtx.%d isratification.%d numvouts.%d signed.%llx numnotaries.%d\n",height,specialtx,isratification,numvouts,(long long)signedmask,numnotaries); if ( specialtx != 0 && isratification != 0 && numvouts > 2 ) { numvalid = 0; From 3237fdd4e41ea845d5b80f1bb42a5ca5ea8ec62c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 08:47:03 -0300 Subject: [PATCH 211/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index e0d96c42e..50a6941ee 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -371,7 +371,6 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&kmdtxid); len += iguana_rwnum(0,&scriptbuf[len],4,(uint8_t *)notarizedheightp); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); - len += 4; if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len]); @@ -379,6 +378,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_HASH = kmdtxid; sp->NOTARIZED_DESTTXID = desttxid; komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0); + len += 4; if ( opretlen > len )//&& scriptbuf[len] == 'A' ) { printf("Found extradata.[%d]\n",opretlen-len); From 9ce7f64fb742f19485fcb1602c7f26364a81cf62 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 08:48:09 -0300 Subject: [PATCH 212/549] test --- src/komodo.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 50a6941ee..d8543f304 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -381,7 +381,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += 4; if ( opretlen > len )//&& scriptbuf[len] == 'A' ) { - printf("Found extradata.[%d]\n",opretlen-len); + printf("Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len); komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len,j); } } else printf("notarized.%d %llx reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",notarized,(long long)signedmask,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]); @@ -486,8 +486,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } numvalid = bitweight(signedmask); - if ( height == 79633 ) - notarized = 1; + //if ( height == 79633 ) + // notarized = 1; if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); From cc448572556a18dc28d5b4193f813c87e69b27f2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 08:48:40 -0300 Subject: [PATCH 213/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 38aeb1847..51eb5f02e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -480,7 +480,7 @@ void komodo_passport_iteration() else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=0; baseid<=32; baseid++) - { + {break; sp = 0; isrealtime = 0; base = (char *)CURRENCIES[baseid]; From 939a5a457e769440bd13a799cef54db0c1bd022b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 08:52:04 -0300 Subject: [PATCH 214/549] test --- src/komodo.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index d8543f304..7faf16f5c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -159,7 +159,12 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char printf(" %s.%d load[%s] opret[%c] len.%d %.8f\n",ASSETCHAINS_SYMBOL,ht,symbol,opret[0],olen,(double)ovalue/COIN); } komodo_eventadd_opreturn(sp,symbol,ht,txid,ovalue,v,opret,olen); // global shared state -> global PAX - } else printf("illegal olen.%u\n",olen); + } else + { + for (i=0; i Date: Tue, 22 Nov 2016 08:54:54 -0300 Subject: [PATCH 215/549] test --- src/komodo.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo.h b/src/komodo.h index 7faf16f5c..141ca8f2d 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -161,6 +161,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char komodo_eventadd_opreturn(sp,symbol,ht,txid,ovalue,v,opret,olen); // global shared state -> global PAX } else { + int32_t i; for (i=0; i Date: Tue, 22 Nov 2016 14:00:51 -0300 Subject: [PATCH 216/549] test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index dd4eda01a..bc5fa3e80 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -560,7 +560,7 @@ int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 has return(-1); notarized_height = komodo_notarizeddata(pindex->nHeight,¬arized_hash,¬arized_desttxid); *notarized_heightp = notarized_height; - if ( notarized_height >= 0 && notarized_height <= pindex->nHeight && (notary= mapBlockIndex[notarized_hash]) != 0 ) + if ( nHeight >= 79700 && notarized_height >= 0 && notarized_height <= pindex->nHeight && (notary= mapBlockIndex[notarized_hash]) != 0 ) { //printf("nHeight.%d -> (%d %s)\n",pindex->Tip()->nHeight,notarized_height,notarized_hash.ToString().c_str()); if ( notary->nHeight == notarized_height ) // if notarized_hash not in chain, reorg From 81e6c3efe6d4a4b1e9e5688021595bb5f7918076 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 14:26:51 -0300 Subject: [PATCH 217/549] test --- src/komodo_bitcoind.h | 7 ++++--- src/miner.cpp | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index bc5fa3e80..574eabc08 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -535,9 +535,10 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) komodo_chosennotary(¬aryid,height,pubkey33); if ( height >= 34000 && notaryid >= 0 ) { - if ( height < 79693 ) - limit = 64; - else if ( height < 82000 ) + //if ( height < 79693 ) + // limit = 64; + //else + if ( height < 82000 ) limit = 8; else limit = 66; for (i=1; inHeight+1,NOTARY_PUBKEY33) > 0 ) { hashTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS); - fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); + //fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); } else Mining_start = 0; while (true) { From 031b1129b7492f870a56ae9a87ec4bb3ab64667d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 14:57:29 -0300 Subject: [PATCH 218/549] Revert "test" This reverts commit 81e6c3efe6d4a4b1e9e5688021595bb5f7918076. --- src/komodo_bitcoind.h | 7 +++---- src/miner.cpp | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 574eabc08..bc5fa3e80 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -535,10 +535,9 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) komodo_chosennotary(¬aryid,height,pubkey33); if ( height >= 34000 && notaryid >= 0 ) { - //if ( height < 79693 ) - // limit = 64; - //else - if ( height < 82000 ) + if ( height < 79693 ) + limit = 64; + else if ( height < 82000 ) limit = 8; else limit = 66; for (i=1; inHeight+1,NOTARY_PUBKEY33) > 0 ) { hashTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS); - //fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); + fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); } else Mining_start = 0; while (true) { From aba9ea3c91bceed6deb7601d9cc3db48035719dc Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 15:35:14 -0300 Subject: [PATCH 219/549] test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index bc5fa3e80..dd4eda01a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -560,7 +560,7 @@ int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 has return(-1); notarized_height = komodo_notarizeddata(pindex->nHeight,¬arized_hash,¬arized_desttxid); *notarized_heightp = notarized_height; - if ( nHeight >= 79700 && notarized_height >= 0 && notarized_height <= pindex->nHeight && (notary= mapBlockIndex[notarized_hash]) != 0 ) + if ( notarized_height >= 0 && notarized_height <= pindex->nHeight && (notary= mapBlockIndex[notarized_hash]) != 0 ) { //printf("nHeight.%d -> (%d %s)\n",pindex->Tip()->nHeight,notarized_height,notarized_hash.ToString().c_str()); if ( notary->nHeight == notarized_height ) // if notarized_hash not in chain, reorg From 508b0d3c8866f23af9245f1a9fc4fac5c8ebc558 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 16:05:15 -0300 Subject: [PATCH 220/549] test --- src/komodo.h | 6 +++--- src/komodo_gateway.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 141ca8f2d..350c2afab 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -370,7 +370,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr else if ( opretlen == 0x4d ) { opretlen = scriptbuf[len++]; - opretlen = (opretlen << 8) + scriptbuf[len++]; + opretlen += (scriptbuf[len++] << 8); } if ( j == 1 && opretlen >= 32*2+4 && strcmp(ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,(char *)&scriptbuf[len+32*2+4]) == 0 ) { @@ -492,8 +492,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } numvalid = bitweight(signedmask); - //if ( height == 79633 ) - // notarized = 1; + if ( height == 79633 ) + notarized = 1; if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 51eb5f02e..38aeb1847 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -480,7 +480,7 @@ void komodo_passport_iteration() else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=0; baseid<=32; baseid++) - {break; + { sp = 0; isrealtime = 0; base = (char *)CURRENCIES[baseid]; From fce96d9f6cb4d7d25c77d1232d440f38f86769b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 16:59:22 -0300 Subject: [PATCH 221/549] test --- src/chainparams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 991cc1333..9825ede9b 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -63,7 +63,7 @@ public: */ pchMessageStart[0] = 0xf9; pchMessageStart[1] = 0xee; - pchMessageStart[2] = 0xe4; + pchMessageStart[2] = 0x4e; // pre-79749 0xe4; pchMessageStart[3] = 0x8d; vAlertPubKey = ParseHex("020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9"); nDefaultPort = 7770; From 81c48dfd3b949416bfde1d870a0c9ebb69e318af Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 17:03:30 -0300 Subject: [PATCH 222/549] test --- src/chainparams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 9825ede9b..991cc1333 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -63,7 +63,7 @@ public: */ pchMessageStart[0] = 0xf9; pchMessageStart[1] = 0xee; - pchMessageStart[2] = 0x4e; // pre-79749 0xe4; + pchMessageStart[2] = 0xe4; pchMessageStart[3] = 0x8d; vAlertPubKey = ParseHex("020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9"); nDefaultPort = 7770; From 367fadca6e3be321923740dd94c39cbb6318765d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 18:07:20 -0300 Subject: [PATCH 223/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 350c2afab..4c89f3d6c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -379,12 +379,12 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { - printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len]); sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = kmdtxid; sp->NOTARIZED_DESTTXID = desttxid; komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0); len += 4; + printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s) lens.(%d %d)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len],opretlen,len); if ( opretlen > len )//&& scriptbuf[len] == 'A' ) { printf("Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len); From 826bfe519441aed0d4cbbdfff7f586f12bfbe39d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 22 Nov 2016 19:08:54 -0300 Subject: [PATCH 224/549] test --- src/komodo_gateway.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 38aeb1847..5127ce1bd 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -369,12 +369,6 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 memset(kmdheights,0,sizeof(kmdheights)); memset(otherheights,0,sizeof(otherheights)); tokomodo = (komodo_is_issuer() == 0); - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - { - for (i=0; i 0 ) { From 52e872488f0f0dd070f43b29c95526ab3dd41223 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 10:44:56 -0300 Subject: [PATCH 225/549] test --- src/komodo_gateway.h | 6 +++++- src/miner.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5127ce1bd..120952004 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -144,7 +144,11 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t memcpy(&rmd160s[n * 20],p.rmd160,20); baseids[n] = komodo_baseid(p.symbol); } - printf(">>>>>>> iskomodo X: (%s) fiat %.8f kmdheight.%d other.%d\n",symbol,dstr(fiatoshis),height,otherheight); + { + char coinaddr[64]; + bitcoin_address(coinaddr,60,p.rmd160,20); + printf(">>>>>>> approved A: (%s) fiat %.8f kmdheight.%d other.%d -> %s %.8f\n",baseids[n]>=0?CURRENCIES[baseids[n]]:"???",dstr(p.fiatoshis),p.height,p.otherheight,coinaddr,dstr(p.komodoshis)); + } } else { diff --git a/src/miner.cpp b/src/miner.cpp index 0bb74a0cc..737af64f5 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -99,7 +99,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, } #define ASSETCHAINS_MINHEIGHT 100 -#define ROUNDROBIN_DELAY 77 +#define ROUNDROBIN_DELAY 59 extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; @@ -644,7 +644,10 @@ void static BitcoinMiner(CWallet *pwallet) if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+ROUNDROBIN_DELAY ) { //printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+ROUNDROBIN_DELAY-time(NULL))); - sleep(Mining_start+ROUNDROBIN_DELAY-time(NULL)); + int32_t nseconds = Mining_start+ROUNDROBIN_DELAY-time(NULL); + if ( nseconds > 0 ) + sleep(nseconds); + MilliSleep((rand() % 2000) + 1); KOMODO_CHOSEN_ONE = 1; } // Found a solution From ddf827b285bc5823cadc8606c991df5a37cb7bab Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 11:08:44 -0300 Subject: [PATCH 226/549] test --- src/komodo_gateway.h | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 120952004..a7d1e879f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -106,17 +106,36 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transaction *pax) { int32_t i,len = 0; - for (i=0; i<32; i++) - opretbuf[len++] = ((uint8_t *)&pax->txid)[i]; - opretbuf[len++] = pax->vout & 0xff; - opretbuf[len++] = (pax->vout >> 8) & 0xff; - len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->fiatoshis),&pax->komodoshis); - len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->fiatoshis),&pax->fiatoshis); - len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->height),&pax->height); - len += iguana_rwnum(1,&opretbuf[len],sizeof(pax->otherheight),&pax->otherheight); - memcpy(&opretbuf[len],pax->rmd160,20), len += 20; - for (i=0; i<4; i++) - opretbuf[len++] = pax->source[i]; + if ( rwflag == 1 ) + { + for (i=0; i<32; i++) + opretbuf[len++] = ((uint8_t *)&pax->txid)[i]; + opretbuf[len++] = pax->vout & 0xff; + opretbuf[len++] = (pax->vout >> 8) & 0xff; + } + else + { + for (i=0; i<32; i++) + ((uint8_t *)&pax->txid)[i] = opretbuf[len++]; + pax->vout = opretbuf[len++]; + pax->vout += ((uint32_t)opretbuf[len++] << 8); + } + len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->fiatoshis),&pax->komodoshis); + len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->fiatoshis),&pax->fiatoshis); + len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->height),&pax->height); + len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->otherheight),&pax->otherheight); + if ( rwflag != 0 ) + { + memcpy(&opretbuf[len],pax->rmd160,20), len += 20; + for (i=0; i<4; i++) + opretbuf[len++] = pax->source[i]; + } + else + { + memcpy(pax->rmd160,&opretbuf[len],20), len += 20; + for (i=0; i<4; i++) + pax->source[i] = opretbuf[len++]; + } return(len); } From ad66994d08b440ae8a6654a3746ceaf1955b6530 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 11:14:55 -0300 Subject: [PATCH 227/549] test --- src/komodo_gateway.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a7d1e879f..de250015e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -116,11 +116,15 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio else { for (i=0; i<32; i++) + { ((uint8_t *)&pax->txid)[i] = opretbuf[len++]; + printf("%02x ",((uint8_t *)&pax->txid)[i]); + } pax->vout = opretbuf[len++]; pax->vout += ((uint32_t)opretbuf[len++] << 8); + printf(" txid v.%d\n",pax->vout); } - len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->fiatoshis),&pax->komodoshis); + len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->komodoshis),&pax->komodoshis); len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->fiatoshis),&pax->fiatoshis); len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->height),&pax->height); len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->otherheight),&pax->otherheight); @@ -135,6 +139,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio memcpy(pax->rmd160,&opretbuf[len],20), len += 20; for (i=0; i<4; i++) pax->source[i] = opretbuf[len++]; + printf("%02x %02x %02x %02x\n",source[0],source[1],source[2],source[3]); } return(len); } From a9b072e256c8f42d6f86a95667857f0e4ba107cc Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 11:16:15 -0300 Subject: [PATCH 228/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index de250015e..bd4cbe2e0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -139,7 +139,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio memcpy(pax->rmd160,&opretbuf[len],20), len += 20; for (i=0; i<4; i++) pax->source[i] = opretbuf[len++]; - printf("%02x %02x %02x %02x\n",source[0],source[1],source[2],source[3]); + printf("%02x %02x %02x %02x\n",pax->source[0],pax->source[1],pax->source[2],pax->source[3]); } return(len); } From 1dbea87266114ef23c82f91f01e7f1fb34c67dae Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 11:22:35 -0300 Subject: [PATCH 229/549] test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index bd4cbe2e0..49adb0f0f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -118,7 +118,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio for (i=0; i<32; i++) { ((uint8_t *)&pax->txid)[i] = opretbuf[len++]; - printf("%02x ",((uint8_t *)&pax->txid)[i]); + printf("%02x",((uint8_t *)&pax->txid)[i]); } pax->vout = opretbuf[len++]; pax->vout += ((uint32_t)opretbuf[len++] << 8); @@ -139,7 +139,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio memcpy(pax->rmd160,&opretbuf[len],20), len += 20; for (i=0; i<4; i++) pax->source[i] = opretbuf[len++]; - printf("%02x %02x %02x %02x\n",pax->source[0],pax->source[1],pax->source[2],pax->source[3]); + printf("%02x %02x %02x %02x %s\n",pax->source[0],pax->source[1],pax->source[2],pax->source[3],pax->source); } return(len); } @@ -166,7 +166,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t kmdheights[n] = p.height; otherheights[n] = p.otherheight; memcpy(&rmd160s[n * 20],p.rmd160,20); - baseids[n] = komodo_baseid(p.symbol); + baseids[n] = komodo_baseid(p.source); } { char coinaddr[64]; From f2db1a97bdf355cde48b8599c64c56d9a274266a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 11:25:34 -0300 Subject: [PATCH 230/549] test --- src/komodo.h | 2 +- src/komodo_gateway.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 4c89f3d6c..dcb31efd5 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -100,7 +100,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( fread(¬arized_desttxid,1,sizeof(notarized_desttxid),fp) != sizeof(notarized_desttxid) ) errs++; //if ( 0 && sp != 0 ) - printf("%s %p %p[%d] load[%s] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,sp,sp->NPOINTS,sp->NUM_NPOINTS,symbol,notarized_height,notarized_hash.ToString().c_str()); + printf("%s load[%s.%d] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,symbol,sp->NUM_NPOINTS,notarized_height,notarized_hash.ToString().c_str()); //if ( matched != 0 ) global independent states -> inside *sp komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 49adb0f0f..1096909de 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -204,7 +204,8 @@ uint64_t komodo_paxtotal() { if ( komodo_is_issuer() != 0 ) total += pax->fiatoshis; - else total += pax->komodoshis; + else if ( pax->approved != 0 ) + total += pax->komodoshis; } } } @@ -453,7 +454,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { for (i=0; i 0 ) @@ -473,7 +474,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - printf("extra.[%d]\n",n); + printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal()); } else if ( tokomodo == 0 && opretbuf[0] == 'I' ) { From 74a9722e8ce1762b249998915d3c938c9f7e545d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 11:29:20 -0300 Subject: [PATCH 231/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1096909de..b57e8ba22 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -454,7 +454,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { for (i=0; i 0 ) From ecfc4f44775bc2cb6e7a15c5f77dc67a321e38c2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 11:33:26 -0300 Subject: [PATCH 232/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b57e8ba22..a67633ce8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -474,7 +474,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal()); + printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal())); } else if ( tokomodo == 0 && opretbuf[0] == 'I' ) { From e8ce1079fa115638dfcb48703502b7667d632e95 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 12:20:11 -0300 Subject: [PATCH 233/549] test --- src/komodo.h | 10 ++++++---- src/komodo_gateway.h | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index dcb31efd5..82f5ec874 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -99,7 +99,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char errs++; if ( fread(¬arized_desttxid,1,sizeof(notarized_desttxid),fp) != sizeof(notarized_desttxid) ) errs++; - //if ( 0 && sp != 0 ) + if ( 0 && sp != 0 ) printf("%s load[%s.%d] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,symbol,sp->NUM_NPOINTS,notarized_height,notarized_hash.ToString().c_str()); //if ( matched != 0 ) global independent states -> inside *sp komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); @@ -384,10 +384,12 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_DESTTXID = desttxid; komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0); len += 4; - printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s) lens.(%d %d)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len],opretlen,len); - if ( opretlen > len )//&& scriptbuf[len] == 'A' ) + if ( ASSETCHAINS[0] == 0 ) + printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s) lens.(%d %d)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len],opretlen,len); + if ( ASSETCHAINS[0] == 0 && opretlen > len && scriptbuf[len] == 'A' ) { - printf("Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len); + if ( ) + printf("Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len); komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len,j); } } else printf("notarized.%d %llx reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",notarized,(long long)signedmask,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a67633ce8..55883c293 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -117,8 +117,8 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio { for (i=0; i<32; i++) { - ((uint8_t *)&pax->txid)[i] = opretbuf[len++]; - printf("%02x",((uint8_t *)&pax->txid)[i]); + ((uint8_t *)&pax->txid)[31-i] = opretbuf[len++]; + printf("%02x",((uint8_t *)&pax->txid)[31-i]); } pax->vout = opretbuf[len++]; pax->vout += ((uint32_t)opretbuf[len++] << 8); From 58033467ff5eecf53c6352a36501046acf22f8d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 12:37:07 -0300 Subject: [PATCH 234/549] test --- src/komodo.h | 9 ++++----- src/komodo_structs.h | 2 +- src/komodo_utils.h | 10 ++++++++++ src/rpcmisc.cpp | 9 +++++++++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 82f5ec874..18a1a3f1d 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -388,8 +388,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s) lens.(%d %d)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len],opretlen,len); if ( ASSETCHAINS[0] == 0 && opretlen > len && scriptbuf[len] == 'A' ) { - if ( ) - printf("Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len); + printf("Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len); komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len,j); } } else printf("notarized.%d %llx reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",notarized,(long long)signedmask,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]); @@ -419,12 +418,12 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr return(notaryid); } -int32_t komodo_isratify(int32_t isspecial,int32_t numvalid) +/*int32_t komodo_isratify(int32_t isspecial,int32_t numvalid) { if ( isspecial != 0 && numvalid >= KOMODO_MINRATIFY ) return(1); else return(0); -} +}*/ // Special tx have vout[0] -> CRYPTO777 // with more than KOMODO_MINRATIFY pay2pubkey outputs -> ratify @@ -496,7 +495,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvalid = bitweight(signedmask); if ( height == 79633 ) notarized = 1; - if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) + if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries>>1)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); notarized = 1; diff --git a/src/komodo_structs.h b/src/komodo_structs.h index b7d776702..309d7a688 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -23,7 +23,7 @@ #endif*/ #define GENESIS_NBITS 0x1f00ffff -#define KOMODO_MINRATIFY 7 +#define KOMODO_MINRATIFY ((height < 90000) ? 7 : 13) #define KOMODO_MAXBLOCKS 5000000 #define KOMODO_EVENT_RATIFY 'P' diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 399fc4c69..397ce3499 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1429,6 +1429,16 @@ void komodo_ports(uint16_t ports[MAX_CURRENCIES]) char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7778\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":1,\\\"VALIDATE\\\":1,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; +int32_t komodo_whoami(char *pubkeystr,int32_t height) +{ + int32_t i,notaryid; uint8_t + for (i=0; i<33; i++) + sprintf(&pubkeystr[i<<1],NOTARY_PUBKEY33[i]); + pubkeystr[66] = 0; + komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33); + return(notaryid); +} + void komodo_args() { std::string name,addn; char *dirname,fname[512],magicstr[9]; uint8_t magic[4]; FILE *fp; int32_t i,len; diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index e6bf47e4f..ed65e69a4 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -42,6 +42,7 @@ using namespace std; uint64_t komodo_interestsum(); int32_t komodo_longestchain(); int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp); +int32_t komodo_whoami(char *pubkeystr,int32_t height); Value getinfo(const Array& params, bool fHelp) { @@ -120,6 +121,14 @@ Value getinfo(const Array& params, bool fHelp) #endif obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); + { + char pubkeystr[65]; int32_t notaryid; + if ( (notaryid= komodo_whoami(pubkeystr,longestchain)) >= 0 ) + { + obj.push_back(Pair("notaryid", notaryid)); + obj.push_back(Pair("pubkey", pubkeystr)); + } + } return obj; } From fbd1641c2967c3cba3ce9c3683d873eb4a807192 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 12:37:36 -0300 Subject: [PATCH 235/549] test --- src/komodo_gateway.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 55883c293..e2d98777d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -116,10 +116,9 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio else { for (i=0; i<32; i++) - { ((uint8_t *)&pax->txid)[31-i] = opretbuf[len++]; - printf("%02x",((uint8_t *)&pax->txid)[31-i]); - } + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&pax->txid)[i]); pax->vout = opretbuf[len++]; pax->vout += ((uint32_t)opretbuf[len++] << 8); printf(" txid v.%d\n",pax->vout); From 2e6851a15fe9bf8ae110df31a99c68d3a4cfe64b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 12:38:58 -0300 Subject: [PATCH 236/549] test --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 18a1a3f1d..909f00a53 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -384,9 +384,9 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_DESTTXID = desttxid; komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0); len += 4; - if ( ASSETCHAINS[0] == 0 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 ) printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s) lens.(%d %d)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len],opretlen,len); - if ( ASSETCHAINS[0] == 0 && opretlen > len && scriptbuf[len] == 'A' ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && opretlen > len && scriptbuf[len] == 'A' ) { printf("Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len); komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len,j); From 2d868edf6827dc01f32f218abb88f4d0b943365e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 12:41:15 -0300 Subject: [PATCH 237/549] test --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 397ce3499..941a046c3 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1431,7 +1431,7 @@ char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7778\" --data \"{\\\ int32_t komodo_whoami(char *pubkeystr,int32_t height) { - int32_t i,notaryid; uint8_t + int32_t i,notaryid; for (i=0; i<33; i++) sprintf(&pubkeystr[i<<1],NOTARY_PUBKEY33[i]); pubkeystr[66] = 0; From dbaf1154707fa50f824fd40ebbcd546949af160f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 13:03:06 -0300 Subject: [PATCH 238/549] test --- src/komodo.h | 28 +++++++++++++++++++++++----- src/komodo_bitcoind.h | 8 ++++++++ src/rpcblockchain.cpp | 35 +++++++++++++++++++++++++++++++++++ src/rpcclient.cpp | 1 + src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + 6 files changed, 69 insertions(+), 5 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 909f00a53..ee0a27b39 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -324,7 +324,8 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask) { - static uint256 zero; int32_t opretlen,nid,k,len = 0; uint256 kmdtxid,desttxid; uint8_t crypto777[33]; struct komodo_state *sp; char symbol[16],dest[16]; + static uint256 zero; static FILE *fp; + int32_t opretlen,nid,k,len = 0; uint256 kmdtxid,desttxid; uint8_t crypto777[33]; struct komodo_state *sp; char symbol[16],dest[16]; if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) return(-1); if ( scriptlen == 35 && scriptbuf[0] == 33 && scriptbuf[34] == 0xac ) @@ -375,7 +376,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr if ( j == 1 && opretlen >= 32*2+4 && strcmp(ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,(char *)&scriptbuf[len+32*2+4]) == 0 ) { len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&kmdtxid); - len += iguana_rwnum(0,&scriptbuf[len],4,(uint8_t *)notarizedheightp); + len += iguana_rwnum(0,&scriptbuf[len],sizeof(*notarizedheightp),(uint8_t *)notarizedheightp); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { @@ -386,10 +387,27 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += 4; if ( ASSETCHAINS_SYMBOL[0] == 0 ) printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s) lens.(%d %d)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len],opretlen,len); - if ( ASSETCHAINS_SYMBOL[0] == 0 && opretlen > len && scriptbuf[len] == 'A' ) + if ( ASSETCHAINS_SYMBOL[0] == 0 ) { - printf("Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len); - komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len,j); + if ( signedfp == 0 ) + { + char fname[512]; + komodo_statefname(fname,"","signedmasks"); + if ( (signedfp= fopen(fname,"rb+")) == 0 ) + signedfp = fopen(fname,"wb"); + else fseek(signedfp,0,SEEK_END); + } + if ( signedfp != 0 ) + { + fwrite(&height,1,sizeof(height),signedfp); + fwrite(&signedmask,1,sizeof(signedmask),signedfp); + fflush(signedfp); + } + if ( opretlen > len && scriptbuf[len] == 'A' ) + { + printf("Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len); + komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len,j); + } } } else printf("notarized.%d %llx reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",notarized,(long long)signedmask,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]); } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index dd4eda01a..21a2340a5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -529,6 +529,14 @@ int8_t komodo_minerid(int32_t height) return(-1); } +int32_t komodo_minerids(uint8_t *minerids,int32_t height) +{ + int32_t i,n=0; + for (i=0; i<1000; i++,n++) + minerids[i] = komodo_minerid(height - i); + return(n); +} + int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) { int32_t i,notaryid,minerid,limit; diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index b79c2e90c..e44ff19e3 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -387,6 +387,41 @@ int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *bas int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height); char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); uint32_t komodo_interest_args(int32_t *txheightp,uint32_t *tiptimep,uint64_t *valuep,uint256 hash,int32_t n); +int32_t komodo_minerids(uint8_t *minerids,int32_t height); + +Value minerids(const Array& params, bool fHelp) +{ + Object ret; Array a; uint8_t minerids[1000],pubkeys[64][33]; int32_t i,j,n,tally[65]; + if ( fHelp || params.size() != 1 ) + throw runtime_error("minerids needs height\n"); + LOCK(cs_main); + if ( (n= komodo_minerids(minerids,height)) > 0 && n <= 64 ) + { + memset(tally,0,sizeof(tally)); + for (i=0; i= 64 ) + tally[64]++; + else tally[minerids[i]]++; + } + if ( (n= komodo_notaries(pubkeys,height)) > 0 ) + { + for (i=0; i<64; i++) + { + Object item; std::string hex; char *hexstr; + hex.resize(66); + hexstr = (char *)hex.data(); + for (j=0; j<33; j++) + sprintf(&hexstr[j*2],"%02x",pubkeys[i][j]); + item.push_back(Pair("pubkey", hex)); + item.push_back(Pair("blocks", tally[i])); + a.push_back(item); + } + } + ret.push_back(Pair("mined", a)); + } else ret.push_back(Pair("error", (char *)"couldnt extract minerids")); + return ret; +} Value notaries(const Array& params, bool fHelp) { diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index adf10ccb7..19f159a6e 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -110,6 +110,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "paxprices", 3 }, { "paxpending", 3 }, { "notaries", 1 }, + { "minerids", 1 }, }; class CRPCConvertTable diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 4f04bdcc1..6e9bf5c35 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -304,6 +304,7 @@ static const CRPCCommand vRPCCommands[] = { "blockchain", "paxpending", &paxpending, true }, { "blockchain", "paxprices", &paxprices, true }, { "blockchain", "notaries", ¬aries, true }, + { "blockchain", "minerids", &minerids, true }, /* Mining */ { "mining", "getblocktemplate", &getblocktemplate, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 77a4818bb..87ceec137 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -244,6 +244,7 @@ extern json_spirit::Value getblock(const json_spirit::Array& params, bool fHelp) extern json_spirit::Value gettxoutsetinfo(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value gettxout(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value notaries(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value minerids(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value paxprice(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value paxpending(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value paxprices(const json_spirit::Array& params, bool fHelp); From 056447a68de4eb74cd3f95e9fc3708a111966cd9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 13:07:11 -0300 Subject: [PATCH 239/549] test --- src/komodo.h | 2 +- src/komodo_bitcoind.h | 4 ++++ src/rpcblockchain.cpp | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index ee0a27b39..e11a026bf 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -385,7 +385,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_DESTTXID = desttxid; komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0); len += 4; - if ( ASSETCHAINS_SYMBOL[0] == 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] == 0 ) printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s) lens.(%d %d)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len],opretlen,len); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 21a2340a5..7f2d202a1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -533,7 +533,11 @@ int32_t komodo_minerids(uint8_t *minerids,int32_t height) { int32_t i,n=0; for (i=0; i<1000; i++,n++) + { + if ( height-i <= 0 ) + break; minerids[i] = komodo_minerid(height - i); + } return(n); } diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e44ff19e3..b8d37c9b7 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -395,6 +395,9 @@ Value minerids(const Array& params, bool fHelp) if ( fHelp || params.size() != 1 ) throw runtime_error("minerids needs height\n"); LOCK(cs_main); + int32_t height = atoi(params[0].get_str().c_str()); + if ( height < 0 ) + height = 0; if ( (n= komodo_minerids(minerids,height)) > 0 && n <= 64 ) { memset(tally,0,sizeof(tally)); From db976543db604a5eec2298e138aca0bcf4fd503e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 13:07:38 -0300 Subject: [PATCH 240/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index e11a026bf..074b76831 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -392,7 +392,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr if ( signedfp == 0 ) { char fname[512]; - komodo_statefname(fname,"","signedmasks"); + komodo_statefname(fname,"",(char *)"signedmasks"); if ( (signedfp= fopen(fname,"rb+")) == 0 ) signedfp = fopen(fname,"wb"); else fseek(signedfp,0,SEEK_END); From c96e160a3f1ed8a3d4ffb237f2f2977c53162bb8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 13:10:36 -0300 Subject: [PATCH 241/549] test --- src/komodo.h | 2 +- src/komodo_utils.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 074b76831..19d3b92b5 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -324,7 +324,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask) { - static uint256 zero; static FILE *fp; + static uint256 zero; static FILE *signedfp; int32_t opretlen,nid,k,len = 0; uint256 kmdtxid,desttxid; uint8_t crypto777[33]; struct komodo_state *sp; char symbol[16],dest[16]; if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) return(-1); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 941a046c3..5602292a5 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1433,7 +1433,7 @@ int32_t komodo_whoami(char *pubkeystr,int32_t height) { int32_t i,notaryid; for (i=0; i<33; i++) - sprintf(&pubkeystr[i<<1],NOTARY_PUBKEY33[i]); + sprintf(&pubkeystr[i<<1],"%02x",NOTARY_PUBKEY33[i]); pubkeystr[66] = 0; komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33); return(notaryid); From 403b5de8380b5ea2dc45717dca8c61ef13dbd68a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 13:12:46 -0300 Subject: [PATCH 242/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 19d3b92b5..970634402 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -392,7 +392,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr if ( signedfp == 0 ) { char fname[512]; - komodo_statefname(fname,"",(char *)"signedmasks"); + komodo_statefname(fname,(char *)"",(char *)"signedmasks"); if ( (signedfp= fopen(fname,"rb+")) == 0 ) signedfp = fopen(fname,"wb"); else fseek(signedfp,0,SEEK_END); From 47cbf8e6f035777d0b083bff5495ffad786d940e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 13:15:46 -0300 Subject: [PATCH 243/549] test --- src/rpcblockchain.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index b8d37c9b7..4e73ce9df 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -391,7 +391,7 @@ int32_t komodo_minerids(uint8_t *minerids,int32_t height); Value minerids(const Array& params, bool fHelp) { - Object ret; Array a; uint8_t minerids[1000],pubkeys[64][33]; int32_t i,j,n,tally[65]; + Object ret; Array a; uint8_t minerids[1000],pubkeys[64][33]; int32_t i,j,n,numnotaries,tally[65]; if ( fHelp || params.size() != 1 ) throw runtime_error("minerids needs height\n"); LOCK(cs_main); @@ -401,14 +401,15 @@ Value minerids(const Array& params, bool fHelp) if ( (n= komodo_minerids(minerids,height)) > 0 && n <= 64 ) { memset(tally,0,sizeof(tally)); - for (i=0; i= 64 ) - tally[64]++; - else tally[minerids[i]]++; - } - if ( (n= komodo_notaries(pubkeys,height)) > 0 ) + numnotaries = komodo_notaries(pubkeys,height); + if ( numnotaries > 0 ) { + for (i=0; i= numnotaries ) + tally[64]++; + else tally[minerids[i]]++; + } for (i=0; i<64; i++) { Object item; std::string hex; char *hexstr; @@ -421,6 +422,9 @@ Value minerids(const Array& params, bool fHelp) a.push_back(item); } } + item.push_back(Pair("pubkey", (char *)"external miner")); + item.push_back(Pair("blocks", tally[64])); + a.push_back(item); ret.push_back(Pair("mined", a)); } else ret.push_back(Pair("error", (char *)"couldnt extract minerids")); return ret; From 14ecdc679fd2f9cdd89c70f4587d3ac4712bd3a9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 13:17:15 -0300 Subject: [PATCH 244/549] test --- src/rpcblockchain.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 4e73ce9df..09d7352b9 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -421,10 +421,11 @@ Value minerids(const Array& params, bool fHelp) item.push_back(Pair("blocks", tally[i])); a.push_back(item); } + Object item; + item.push_back(Pair("pubkey", (char *)"external miners")); + item.push_back(Pair("blocks", tally[64])); + a.push_back(item); } - item.push_back(Pair("pubkey", (char *)"external miner")); - item.push_back(Pair("blocks", tally[64])); - a.push_back(item); ret.push_back(Pair("mined", a)); } else ret.push_back(Pair("error", (char *)"couldnt extract minerids")); return ret; From 55ecfab2cce5e3da4d0ba6d6287df357380bf99f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 13:33:28 -0300 Subject: [PATCH 245/549] test --- src/rpcblockchain.cpp | 6 +++--- src/rpcclient.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 09d7352b9..4d1dbcde6 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -396,8 +396,8 @@ Value minerids(const Array& params, bool fHelp) throw runtime_error("minerids needs height\n"); LOCK(cs_main); int32_t height = atoi(params[0].get_str().c_str()); - if ( height < 0 ) - height = 0; + if ( height <= 0 ) + height = chainActive.Tip()->nHeight; if ( (n= komodo_minerids(minerids,height)) > 0 && n <= 64 ) { memset(tally,0,sizeof(tally)); @@ -421,7 +421,7 @@ Value minerids(const Array& params, bool fHelp) item.push_back(Pair("blocks", tally[i])); a.push_back(item); } - Object item; + Object item; item.push_back(Pair("pubkey", (char *)"external miners")); item.push_back(Pair("blocks", tally[64])); a.push_back(item); diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index 19f159a6e..7375bbdcd 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -108,7 +108,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "z_importkey", 1 }, { "paxprice", 4 }, { "paxprices", 3 }, - { "paxpending", 3 }, + { "paxpending", 0 }, { "notaries", 1 }, { "minerids", 1 }, }; From d6be719d8ae8f4cb43f0c3be980737dd214c0f3b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 13:45:20 -0300 Subject: [PATCH 246/549] test --- src/komodo_gateway.h | 20 ++++++++++++-------- src/rpcblockchain.cpp | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e2d98777d..1461e9031 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -51,9 +51,9 @@ struct pax_transaction *komodo_paxmark(int32_t height,struct pax_transaction *sp return(pax); } -void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight,char *source) // assetchain context +void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context { - struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16]; + struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16],*s; sp = komodo_stateptr(str,dest); pthread_mutex_lock(&komodo_mutex); HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); @@ -92,7 +92,12 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( pax->marked == 0 ) { if ( addflag != 0 ) - printf("[%s] addflag.%d ADD %s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,ASSETCHAINS_SYMBOL[0]==0?"WITHDRAW":"DEPOSIT",symbol,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); + { + if ( (pax->approved= approved) != 0 ) + s = (char *)"APPROVED"; + else s = (char *)(ASSETCHAINS_SYMBOL[0]==0?"WITHDRAW":"DEPOSIT"); + printf("[%s] addflag.%d ADD %s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); + } } //else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height,otherheight); } @@ -138,7 +143,6 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio memcpy(pax->rmd160,&opretbuf[len],20), len += 20; for (i=0; i<4; i++) pax->source[i] = opretbuf[len++]; - printf("%02x %02x %02x %02x %s\n",pax->source[0],pax->source[1],pax->source[2],pax->source[3],pax->source); } return(len); } @@ -422,7 +426,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( komodo_paxfind(&space,txid,vout) == 0 ) { - komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD"); + komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } else printf("duplicate deposit\n"); } } @@ -444,7 +448,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } - komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height,source); + komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height,source,0); } } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) @@ -463,7 +467,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) == 0 && baseids[i] >= 0 ) { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]]); + komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); printf("i.%d (%s) <- %.8f\n",i,coinaddr,dstr(values[i])); } else printf("i.%d pax.%p baseids[] %d\n",i,pax,baseids[i]); if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) != 0 ) @@ -485,7 +489,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); if ( komodo_paxmark(height,&space,txids[i],vouts[i],height) == 0 && baseids[i] >= 0 ) - komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]]); + komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } } } diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 4d1dbcde6..80c462eaf 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -398,7 +398,7 @@ Value minerids(const Array& params, bool fHelp) int32_t height = atoi(params[0].get_str().c_str()); if ( height <= 0 ) height = chainActive.Tip()->nHeight; - if ( (n= komodo_minerids(minerids,height)) > 0 && n <= 64 ) + if ( (n= komodo_minerids(minerids,height)) > 0 ) { memset(tally,0,sizeof(tally)); numnotaries = komodo_notaries(pubkeys,height); From 8711ee8f28b1cb0c5c4d731fbe2abd66e009b230 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 13:57:34 -0300 Subject: [PATCH 247/549] test --- src/rpcblockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 80c462eaf..418fbc73e 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -417,6 +417,7 @@ Value minerids(const Array& params, bool fHelp) hexstr = (char *)hex.data(); for (j=0; j<33; j++) sprintf(&hexstr[j*2],"%02x",pubkeys[i][j]); + item.push_back(Pair("notaryid", i)); item.push_back(Pair("pubkey", hex)); item.push_back(Pair("blocks", tally[i])); a.push_back(item); From 75e47988cfcd03a703bfc7c8a33a9c485ed5da65 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 14:09:38 -0300 Subject: [PATCH 248/549] test --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1461e9031..441e0a9d1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -230,6 +230,7 @@ int32_t komodo_pending_withdraws(char *opretstr) if ( len == 0 ) opretbuf[len++] = 'A'; len += komodo_rwapproval(1,&opretbuf[len],pax); + printf("%s.(marked.%u approved.%d) %p\n",pax->source,pax->marked,pax->approved,pax); } } if ( len > 0 ) @@ -473,7 +474,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) != 0 ) { pax->approved = kmdheights[i]; - printf("i.%d approved.%d\n",i,kmdheights[i]); + printf("i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); } } } From dfe40c435a1b10984a09a9bcf1dab6398655239d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 14:24:26 -0300 Subject: [PATCH 249/549] test --- src/komodo_gateway.h | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 441e0a9d1..eb08ccb29 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -15,18 +15,16 @@ // paxdeposit equivalent in reverse makes opreturn and KMD does the same in reverse -struct pax_transaction *komodo_paxfind(struct pax_transaction *space,uint256 txid,uint16_t vout) +struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout) { struct pax_transaction *pax; pthread_mutex_lock(&komodo_mutex); HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); - if ( pax != 0 ) - memcpy(space,pax,sizeof(*pax)); pthread_mutex_unlock(&komodo_mutex); return(pax); } -struct pax_transaction *komodo_paxmark(int32_t height,struct pax_transaction *space,uint256 txid,uint16_t vout,int32_t mark) +struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout,int32_t mark) { struct pax_transaction *pax; pthread_mutex_lock(&komodo_mutex); @@ -45,7 +43,6 @@ struct pax_transaction *komodo_paxmark(int32_t height,struct pax_transaction *sp //int32_t i; for (i=0; i<32; i++) // printf("%02x",((uint8_t *)&txid)[i]); //printf(" paxmark.ht %d vout%d\n",mark,vout); - memcpy(space,pax,sizeof(*pax)); } pthread_mutex_unlock(&komodo_mutex); return(pax); @@ -314,7 +311,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { - int32_t i,j,n,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; int64_t values[64]; struct pax_transaction *pax,space; + int32_t i,j,n,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; int64_t values[64]; struct pax_transaction *pax; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); memset(rmd160s,0,sizeof(rmd160s)); @@ -344,7 +341,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { for (i=1; ifiatoshis == block.vtx[0].vout[i].nValue) || (opcode == 'X' && pax->komodoshis == block.vtx[0].vout[i].nValue)) ) { @@ -353,7 +350,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above else matched++; if ( 0 && opcode == 'X' ) printf("errs.%d i.%d match %.8f == %.8f\n",errs,i,dstr(pax != 0 ? pax->fiatoshis:-1),dstr(block.vtx[0].vout[i].nValue)); - komodo_paxmark(height,&space,txids[i-1],vouts[i-1],height); + komodo_paxmark(height,txids[i-1],vouts[i-1],height); } else { @@ -394,7 +391,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; struct pax_transaction space; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64]; struct pax_transaction *pax; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64]; struct pax_transaction *pax; const char *typestr = "unknown"; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); @@ -425,7 +422,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); if ( value >= checktoshis-(checktoshis >> 10) ) { - if ( komodo_paxfind(&space,txid,vout) == 0 ) + if ( komodo_paxfind(txid,vout) == 0 ) { komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } else printf("duplicate deposit\n"); @@ -445,7 +442,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); if ( checktoshis <= komodoshis+(komodoshis >> 10) ) { - if ( (pax= komodo_paxfind(&space,txid,vout)) == 0 ) + if ( (pax= komodo_paxfind(txid,vout)) == 0 ) { printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } @@ -465,16 +462,18 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { for (i=0; i= 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 && baseids[i] >= 0 ) { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); printf("i.%d (%s) <- %.8f\n",i,coinaddr,dstr(values[i])); - } else printf("i.%d pax.%p baseids[] %d\n",i,pax,baseids[i]); - if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) != 0 ) + } else printf("i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); + if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->approved = kmdheights[i]; - printf("i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); + for (j=0; j<32; i++) + printf("%02x",((uint8_t *)&txids[i])[j]); + printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); } } } @@ -489,7 +488,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 for (i=0; i= 0 ) + if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 && baseids[i] >= 0 ) komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } } From 26ffac88686fef103f27ad805be03c1575d7f06f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 14:29:48 -0300 Subject: [PATCH 250/549] test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index eb08ccb29..1a43a5444 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -462,17 +462,17 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { for (i=0; i= 0 ) { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); - printf("i.%d (%s) <- %.8f\n",i,coinaddr,dstr(values[i])); - } else printf("i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); + printf(" i.%d (%s) <- %.8f\n",i,coinaddr,dstr(values[i])); + } else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->approved = kmdheights[i]; - for (j=0; j<32; i++) - printf("%02x",((uint8_t *)&txids[i])[j]); printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); } } From 71c9af7c8efcda41b3904861229d45eb87a58a84 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 14:40:01 -0300 Subject: [PATCH 251/549] test --- src/komodo_gateway.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1a43a5444..9150518f4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -160,18 +160,18 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t { memset(&p,0,sizeof(p)); len += komodo_rwapproval(0,&opretbuf[len],&p); - if ( values != 0 && kmdheights != 0 && otherheights != 0 && baseids != 0 ) + if ( values != 0 && kmdheights != 0 && otherheights != 0 && baseids != 0 && rmd160s != 0 ) { values[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? p.komodoshis : p.fiatoshis; kmdheights[n] = p.height; otherheights[n] = p.otherheight; memcpy(&rmd160s[n * 20],p.rmd160,20); baseids[n] = komodo_baseid(p.source); - } - { - char coinaddr[64]; - bitcoin_address(coinaddr,60,p.rmd160,20); - printf(">>>>>>> approved A: (%s) fiat %.8f kmdheight.%d other.%d -> %s %.8f\n",baseids[n]>=0?CURRENCIES[baseids[n]]:"???",dstr(p.fiatoshis),p.height,p.otherheight,coinaddr,dstr(p.komodoshis)); + { + char coinaddr[64]; + bitcoin_address(coinaddr,60,&rmd160s[n * 20],20); + printf(">>>>>>> approved A: (%s) fiat %.8f kmdheight.%d other.%d -> %s %.8f\n",baseids[n]>=0?CURRENCIES[baseids[n]]:"???",dstr(p.komodoshis),kmdheights[n],otherheights[n],coinaddr,dstr(values[n])); + } } } else @@ -464,6 +464,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { for (j=0; j<32; j++) printf("%02x",((uint8_t *)&txids[i])[j]); + printf(" v%d %.8f k.%d ht.%d base.%d\n",vouts[i],dstr(values[i]),kmdheights[i],otherheights[i],baseids[i]); if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 && baseids[i] >= 0 ) { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); From 63342b19eca74f464579ca5eb3ab6296d8f0f973 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 14:46:36 -0300 Subject: [PATCH 252/549] test --- src/komodo_gateway.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9150518f4..a4d31dbf0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -162,6 +162,8 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t len += komodo_rwapproval(0,&opretbuf[len],&p); if ( values != 0 && kmdheights != 0 && otherheights != 0 && baseids != 0 && rmd160s != 0 ) { + txids[n] = p.txid; + vouts[n] = p.vout; values[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? p.komodoshis : p.fiatoshis; kmdheights[n] = p.height; otherheights[n] = p.otherheight; @@ -170,7 +172,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t { char coinaddr[64]; bitcoin_address(coinaddr,60,&rmd160s[n * 20],20); - printf(">>>>>>> approved A: (%s) fiat %.8f kmdheight.%d other.%d -> %s %.8f\n",baseids[n]>=0?CURRENCIES[baseids[n]]:"???",dstr(p.komodoshis),kmdheights[n],otherheights[n],coinaddr,dstr(values[n])); + printf(">>>>>>> approved A: (%s) fiat %.8f kmdheight.%d other.%d -> %s %.8f\n",baseids[n]>=0?CURRENCIES[baseids[n]]:"???",dstr(p.fiatoshis),kmdheights[n],otherheights[n],coinaddr,dstr(values[n])); } } } From a6972662ed0065a9210cc0efcac21dccbe7307cf Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 14:54:50 -0300 Subject: [PATCH 253/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a4d31dbf0..dd57e3d41 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -118,9 +118,9 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio else { for (i=0; i<32; i++) - ((uint8_t *)&pax->txid)[31-i] = opretbuf[len++]; + ((uint8_t *)&pax->txid)[i] = opretbuf[len++]; for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&pax->txid)[i]); + printf("%02x",((uint8_t *)&pax->txid)[31-i]); pax->vout = opretbuf[len++]; pax->vout += ((uint32_t)opretbuf[len++] << 8); printf(" txid v.%d\n",pax->vout); From b89ab77cc2966f632fa7450d5e2f2804f23d0451 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 15:15:29 -0300 Subject: [PATCH 254/549] test --- src/komodo_gateway.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index dd57e3d41..0fd4a31e2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -144,7 +144,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio return(len); } -int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) +int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int64_t *srcvalues,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) { struct pax_transaction p; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t rmd160[20]; uint64_t fiatoshis; char symbol[16]; for (i=0; i<4; i++) @@ -160,11 +160,12 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t { memset(&p,0,sizeof(p)); len += komodo_rwapproval(0,&opretbuf[len],&p); - if ( values != 0 && kmdheights != 0 && otherheights != 0 && baseids != 0 && rmd160s != 0 ) + if ( values != 0 && srcvalues != 0 && kmdheights != 0 && otherheights != 0 && baseids != 0 && rmd160s != 0 ) { txids[n] = p.txid; vouts[n] = p.vout; values[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? p.komodoshis : p.fiatoshis; + srcvalues[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? p.fiatoshis : p.komodoshis; kmdheights[n] = p.height; otherheights[n] = p.otherheight; memcpy(&rmd160s[n * 20],p.rmd160,20); @@ -313,9 +314,10 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { - int32_t i,j,n,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; int64_t values[64]; struct pax_transaction *pax; + int32_t i,j,n,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); + memset(srcvalues,0,sizeof(srcvalues)); memset(rmd160s,0,sizeof(rmd160s)); memset(kmdheights,0,sizeof(kmdheights)); memset(otherheights,0,sizeof(otherheights)); @@ -339,7 +341,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } if ( script[offset] == opcode && opretlen < block.vtx[0].vout[n-1].scriptPubKey.size() ) { - if ( (num= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,rmd160s,&script[offset],opretlen,opcode == 'X')) > 0 ) + if ( (num= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,&script[offset],opretlen,opcode == 'X')) > 0 ) { for (i=1; i 0 ) + if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) { for (i=0; i KMD %.8f vs %.8f\n",kmdheights[i],base,(double)fiatoshis/COIN,(double)values[i]/COIN,(double)checktoshis/COIN); for (j=0; j<32; j++) printf("%02x",((uint8_t *)&txids[i])[j]); printf(" v%d %.8f k.%d ht.%d base.%d\n",vouts[i],dstr(values[i]),kmdheights[i],otherheights[i],baseids[i]); - if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 && baseids[i] >= 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 ) { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); @@ -486,7 +492,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) { - if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 ) + if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 ) { for (i=0; i Date: Wed, 23 Nov 2016 15:16:57 -0300 Subject: [PATCH 255/549] test --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0fd4a31e2..935ceaed3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -395,10 +395,11 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64]; struct pax_transaction *pax; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax; const char *typestr = "unknown"; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); + memset(srcvalues,0,sizeof(srcvalues)); memset(rmd160s,0,sizeof(rmd160s)); memset(kmdheights,0,sizeof(kmdheights)); memset(otherheights,0,sizeof(otherheights)); From 0cc6ad813ffad55661687d0257efeb146abbe5ac Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 15:38:26 -0300 Subject: [PATCH 256/549] test --- src/komodo.h | 2 +- src/komodo_gateway.h | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 970634402..3bded0254 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -152,7 +152,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char { if ( fread(opret,1,olen,fp) != olen ) errs++; - //if ( matched != 0 ) + if ( 0 && matched != 0 ) { int32_t i; for (i=0; i 0 ) { for (i=0; i KMD %.8f vs %.8f\n",kmdheights[i],base,(double)fiatoshis/COIN,(double)values[i]/COIN,(double)checktoshis/COIN); + seed = 0; + while ( seed == 0 ) + { + checktoshis = komodo_paxprice(&seed,kmdheights[i],CURRENCIES[baseids[i]],(char *)"KMD",(uint64_t)srcvalues[i]); + printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",kmdheights[i],CURRENCIES[baseids[i]],(double)srcvalues[i]/COIN,(double)values[i]/COIN,(double)checktoshis/COIN); + if ( seed == 0 ) + sleep(3); + } for (j=0; j<32; j++) printf("%02x",((uint8_t *)&txids[i])[j]); printf(" v%d %.8f k.%d ht.%d base.%d\n",vouts[i],dstr(values[i]),kmdheights[i],otherheights[i],baseids[i]); if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 ) { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); + komodo_gateway_deposit(coinaddr,values[i],CURRENCIES[baseids[i]],srcvalues[i],&rmd160s[i*20],txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); printf(" i.%d (%s) <- %.8f\n",i,coinaddr,dstr(values[i])); } else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) From 992c3be5b46a177d192bec3661a44888eee1beff Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 15:56:02 -0300 Subject: [PATCH 257/549] test --- src/komodo_gateway.h | 35 +++++++++++++++++++++++++---------- src/komodo_structs.h | 2 +- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 252fe890d..b1db4c1d2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -194,7 +194,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t uint64_t komodo_paxtotal() { - struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; int32_t ht; uint64_t total = 0; + struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; int32_t ht; int64_t checktoshis; uint64_t seed,total = 0; if ( komodo_isrealtime(&ht) == 0 ) return(0); komodo_stateptr(symbol,dest); @@ -208,7 +208,25 @@ uint64_t komodo_paxtotal() if ( komodo_is_issuer() != 0 ) total += pax->fiatoshis; else if ( pax->approved != 0 ) - total += pax->komodoshis; + { + if ( pax->validated != 0 ) + total += pax->komodoshis; + else + { + seed = 0; + checktoshis = komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatvalue); + printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",pax->height,pax->symbol,(double)pax->fiatoshis/COIN,(double)pax->komodoshis/COIN,(double)checktoshis/COIN); + printf(" v%d %.8f k.%d ht.%d base.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight,pax->symbol); + if ( seed != 0 ) + { + if ( checktoshis == pax->komodoshis ) + { + total += pax->komodoshis; + pax->validated = pax->komodoshis; + } else pax->marked = pax->height; + } + } + } } } } @@ -255,7 +273,9 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to HASH_ITER(hh,PAX,pax,tmp) { //printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); - if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 || (strcmp(symbol,"KMD") == 0 && pax->approved == 0) ) + if ( strcmp(symbol,"KMD") == 0 && (pax->approved == 0 || pax->validated == 0 ) + continue; + if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 ) continue; //if ( ASSETCHAINS_SYMBOL[0] != 0 ) printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); @@ -469,13 +489,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( baseids[i] < 0 ) continue; seed = 0; - while ( seed == 0 ) - { - checktoshis = komodo_paxprice(&seed,kmdheights[i],CURRENCIES[baseids[i]],(char *)"KMD",(uint64_t)srcvalues[i]); - printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",kmdheights[i],CURRENCIES[baseids[i]],(double)srcvalues[i]/COIN,(double)values[i]/COIN,(double)checktoshis/COIN); - if ( seed == 0 ) - sleep(3); - } + checktoshis = komodo_paxprice(&seed,kmdheights[i],CURRENCIES[baseids[i]],(char *)"KMD",(uint64_t)srcvalues[i]); + printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",kmdheights[i],CURRENCIES[baseids[i]],(double)srcvalues[i]/COIN,(double)values[i]/COIN,(double)checktoshis/COIN); for (j=0; j<32; j++) printf("%02x",((uint8_t *)&txids[i])[j]); printf(" v%d %.8f k.%d ht.%d base.%d\n",vouts[i],dstr(values[i]),kmdheights[i],otherheights[i],baseids[i]); diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 309d7a688..2741fafb9 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -56,7 +56,7 @@ struct pax_transaction { UT_hash_handle hh; uint256 txid; - uint64_t komodoshis,fiatoshis; + uint64_t komodoshis,fiatoshis,validated; int32_t marked,height,otherheight,approved; uint16_t vout; char symbol[16],source[16],coinaddr[64]; uint8_t rmd160[20],shortflag; From f186b8a19d565c4ae5c16fb23e7aa74fc67c76e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 15:58:15 -0300 Subject: [PATCH 258/549] test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b1db4c1d2..dade96dde 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -214,9 +214,9 @@ uint64_t komodo_paxtotal() else { seed = 0; - checktoshis = komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatvalue); + checktoshis = komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatoshis); printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",pax->height,pax->symbol,(double)pax->fiatoshis/COIN,(double)pax->komodoshis/COIN,(double)checktoshis/COIN); - printf(" v%d %.8f k.%d ht.%d base.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight,pax->symbol); + printf(" v%d %.8f k.%d ht.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight); if ( seed != 0 ) { if ( checktoshis == pax->komodoshis ) @@ -273,7 +273,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to HASH_ITER(hh,PAX,pax,tmp) { //printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); - if ( strcmp(symbol,"KMD") == 0 && (pax->approved == 0 || pax->validated == 0 ) + if ( strcmp(symbol,"KMD") == 0 && (pax->approved == 0 || pax->validated == 0) ) continue; if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 ) continue; From e3f9967438670a121f49ca6cfb8cb3aa9b9f2a4b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 16:07:56 -0300 Subject: [PATCH 259/549] test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index dade96dde..82a11720f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -254,6 +254,7 @@ int32_t komodo_pending_withdraws(char *opretstr) if ( len > 0 ) init_hexbytes_noT(opretstr,opretbuf,len); else opretstr[0] = 0; + printf("PAXTOTAL %.8f\n",dstr(komodo_paxtotal())); return(len); } From e8cbe5fb58b222e18b118aa57505b9fa2b8c558a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 16:17:37 -0300 Subject: [PATCH 260/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 82a11720f..169818cbe 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -219,7 +219,7 @@ uint64_t komodo_paxtotal() printf(" v%d %.8f k.%d ht.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight); if ( seed != 0 ) { - if ( checktoshis == pax->komodoshis ) + if ( checktoshis >= pax->komodoshis ) { total += pax->komodoshis; pax->validated = pax->komodoshis; From 52b2e68d9da5a5388fc1d0dbf7bb4311ad9991da Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 18:16:58 -0300 Subject: [PATCH 261/549] test --- src/komodo_gateway.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 169818cbe..e164566a1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -393,7 +393,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( opcode == 'X' ) { - matched++; + //matched++; for (j=0; j<32; j++) printf("%02x",((uint8_t *)&txids[i-1])[j]); printf(" cant paxfind X txid\n"); @@ -405,8 +405,11 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( matched != num ) { // can easily happen depending on order of loading - if ( height > 60000 ) - printf("WARNING: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); + if ( height > 60000 && opcode == 'X' ) + { + printf("REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); + return(-1); + } } } //printf("opretlen.%d num.%d\n",opretlen,num); @@ -477,7 +480,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) { - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 ) { for (i=0; i Date: Wed, 23 Nov 2016 18:21:28 -0300 Subject: [PATCH 262/549] test --- src/komodo_gateway.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e164566a1..f99349149 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -528,6 +528,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } + else if ( opretbuf[0] == 'X' ) + { + printf("got X opreturn\n"); + } return(typestr); } From 4c58b338bf867a8b96a9d9eaf14a9e8958aaa3a4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 18:25:53 -0300 Subject: [PATCH 263/549] test --- src/komodo_gateway.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f99349149..5b7fc18bf 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -530,7 +530,16 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( opretbuf[0] == 'X' ) { - printf("got X opreturn\n"); + printf("got X opreturn height.%d\n",height); + if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) + { + for (i=0; i= 0 ) + komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); + } + } } return(typestr); } From cddf571e366d84dbd0b9ab14e0787808890ebf35 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 18:46:22 -0300 Subject: [PATCH 264/549] test --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5b7fc18bf..09381f2d0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -536,7 +536,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 for (i=0; i= 0 ) + printf("i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); + if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); } } From e988a431ec7ee626e7a5b07e6427a10aaf50eae4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 18:53:07 -0300 Subject: [PATCH 265/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 09381f2d0..1a1d76f65 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -155,7 +155,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); for (n=0; n Date: Wed, 23 Nov 2016 18:55:56 -0300 Subject: [PATCH 266/549] test --- src/komodo_gateway.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1a1d76f65..70ebbf061 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -149,6 +149,9 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t struct pax_transaction p; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t rmd160[20]; uint64_t fiatoshis; char symbol[16]; for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; + for (i=0; i Date: Wed, 23 Nov 2016 19:06:47 -0300 Subject: [PATCH 267/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 70ebbf061..d053696e8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -151,7 +151,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t base[i] = opretbuf[opretlen-4+i]; for (i=0; i 0 ) init_hexbytes_noT(opretstr,opretbuf,len); else opretstr[0] = 0; - printf("PAXTOTAL %.8f\n",dstr(komodo_paxtotal())); + printf("komodo_pending_withdraws len.%d PAXTOTAL %.8f\n",len,dstr(komodo_paxtotal())); return(len); } From e0357628beefc96f4423dee741f1fd335af27c27 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 19:20:00 -0300 Subject: [PATCH 268/549] test --- src/komodo_gateway.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d053696e8..4ad1c7dd2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -305,12 +305,13 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to else { //[{"prev_hash":"5d5c9a49489b558de9e84f991f996dedaae6b9d0f157f82b2fec64662476d5cf","prev_vout":2,"EUR":0.10000000,"fiat":"EUR","kmdheight":57930,"height":153,"KMD":0.78329000,"address":"RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5","rmd160":"306c507eea639e7220b3069ed9f49f3bc97eaca1"}] - len += iguana_rwnum(1,&data[len],sizeof(pax->fiatoshis),&pax->fiatoshis); + len += komodo_rwapproval(1,&data[len],pax); + /*len += iguana_rwnum(1,&data[len],sizeof(pax->fiatoshis),&pax->fiatoshis); len += iguana_rwnum(1,&data[len],sizeof(pax->height),&pax->height); len += iguana_rwnum(1,&data[len],sizeof(pax->otherheight),&pax->otherheight); for (i=0; pax->symbol[i]!=0&&i<3; i++) // must be 3 letter currency data[len++] = pax->symbol[i]; - data[len++] = 0; + data[len++] = 0;*/ PENDING_KOMODO_TX += pax->komodoshis; printf(" vout.%u DEPOSIT %.8f <- pax.%s pending %.8f | ",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX)); } From 16bed6ace19ac18a52ba31bc93cf7befc572031b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 19:27:24 -0300 Subject: [PATCH 269/549] test --- src/komodo_gateway.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4ad1c7dd2..ad069807c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -147,6 +147,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int64_t *srcvalues,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) { struct pax_transaction p; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t rmd160[20]; uint64_t fiatoshis; char symbol[16]; + incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; for (i=0; irmd160,20), script += 20; *script++ = 0x88; *script++ = 0xac; - for (i=0; i<32; i++) - { - //printf("%02x",((uint8_t *)&pax->txid)[i]); - data[len++] = ((uint8_t *)&pax->txid)[i]; - } - data[len++] = pax->vout & 0xff; - data[len++] = (pax->vout >> 8) & 0xff; if ( tokomodo == 0 ) + { + for (i=0; i<32; i++) + { + //printf("%02x",((uint8_t *)&pax->txid)[i]); + data[len++] = ((uint8_t *)&pax->txid)[i]; + } + data[len++] = pax->vout & 0xff; + data[len++] = (pax->vout >> 8) & 0xff; PENDING_KOMODO_TX += pax->fiatoshis; + } else { //[{"prev_hash":"5d5c9a49489b558de9e84f991f996dedaae6b9d0f157f82b2fec64662476d5cf","prev_vout":2,"EUR":0.10000000,"fiat":"EUR","kmdheight":57930,"height":153,"KMD":0.78329000,"address":"RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5","rmd160":"306c507eea639e7220b3069ed9f49f3bc97eaca1"}] From 947d956f553d0677efa914fd8fbabf9eaecb89af Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 19:54:20 -0300 Subject: [PATCH 270/549] test --- src/komodo_gateway.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ad069807c..9e2f1f43c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -146,7 +146,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int64_t *srcvalues,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) { - struct pax_transaction p; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t rmd160[20]; uint64_t fiatoshis; char symbol[16]; + struct pax_transaction p; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t type,rmd160[20]; uint64_t fiatoshis; char symbol[16]; incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; @@ -155,10 +155,10 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t printf(" opretlen.%d vs %d incr.%d\n",opretlen,(int32_t)(2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4),incr); if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) { + type = opretbuf[0]; opretbuf++, opretlen--; for (n=0; n>>>>>> approved A: (%s) fiat %.8f kmdheight.%d other.%d -> %s %.8f\n",baseids[n]>=0?CURRENCIES[baseids[n]]:"???",dstr(p.fiatoshis),kmdheights[n],otherheights[n],coinaddr,dstr(values[n])); + printf(">>>>>>> %s: (%s) fiat %.8f kmdheight.%d other.%d -> %s %.8f\n",type=='A'?"approvedA":"issuedX",baseids[n]>=0?CURRENCIES[baseids[n]]:"???",dstr(p.fiatoshis),kmdheights[n],otherheights[n],coinaddr,dstr(values[n])); } } } @@ -190,6 +190,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t vouts[n] = opretbuf[len++]; vouts[n] = (opretbuf[len++] << 8) | vouts[n]; } + printf(" komodo_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); } } return(n); @@ -370,6 +371,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( (num= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,&script[offset],opretlen,opcode == 'X')) > 0 ) { + printf("komodo_check_deposit opcode.%c num.%d n.%d\n",opcode,num,n); for (i=1; imarked != 0 ) errs++; else matched++; - if ( 0 && opcode == 'X' ) + if ( opcode == 'X' ) printf("errs.%d i.%d match %.8f == %.8f\n",errs,i,dstr(pax != 0 ? pax->fiatoshis:-1),dstr(block.vtx[0].vout[i].nValue)); komodo_paxmark(height,txids[i-1],vouts[i-1],height); } @@ -389,8 +391,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( opcode == 'X' ) { for (j=0; j<32; j++) - printf("%02x",((uint8_t *)&hash)[j]); - printf(" ht.%d blockhash X couldnt find vout.[%d]\n",height,i); + printf("%02x",((uint8_t *)&txids[i-1])[j]); + printf(" cant paxfind X txid\n"); // validate amount! via fiat chain } } @@ -399,11 +401,10 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( opcode == 'X' ) { - //matched++; + for (j=0; j<32; j++) - printf("%02x",((uint8_t *)&txids[i-1])[j]); - printf(" cant paxfind X txid\n"); - // validate amount! via fiat chain + printf("%02x",((uint8_t *)&hash)[j]); + printf(" ht.%d blockhash X couldnt find vout.[%d]\n",height,i); } else if ( opcode == 'I' ) matched++; } From 1d996b5f608ccb0d6e68000d97f4f6201dfa0692 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 20:03:26 -0300 Subject: [PATCH 271/549] test --- src/komodo_gateway.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9e2f1f43c..b8c4661a9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -382,12 +382,13 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above errs++; else matched++; if ( opcode == 'X' ) - printf("errs.%d i.%d match %.8f == %.8f\n",errs,i,dstr(pax != 0 ? pax->fiatoshis:-1),dstr(block.vtx[0].vout[i].nValue)); - komodo_paxmark(height,txids[i-1],vouts[i-1],height); + printf("errs.%d i.%d match %.8f == %.8f pax.%p\n",errs,i,dstr(pax != 0 ? pax->komodoshis:-1),dstr(block.vtx[0].vout[i].nValue),pax); + //komodo_paxmark(height,txids[i-1],vouts[i-1],height); + //if ( pax->marked == 0 ) + // printf("unexpected unmarked %p\n",pax); } else { - hash = block.GetHash(); if ( opcode == 'X' ) { for (j=0; j<32; j++) @@ -401,7 +402,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( opcode == 'X' ) { - + hash = block.GetHash(); for (j=0; j<32; j++) printf("%02x",((uint8_t *)&hash)[j]); printf(" ht.%d blockhash X couldnt find vout.[%d]\n",height,i); From 4cfa59e19f40c6286e6164446d1f897b9ae76964 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 20:12:39 -0300 Subject: [PATCH 272/549] test --- src/komodo_gateway.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b8c4661a9..5b0cf0b88 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -371,7 +371,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( (num= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,&script[offset],opretlen,opcode == 'X')) > 0 ) { - printf("komodo_check_deposit opcode.%c num.%d n.%d\n",opcode,num,n); for (i=1; imarked != 0 ) errs++; else matched++; - if ( opcode == 'X' ) + if ( 0 && opcode == 'X' ) printf("errs.%d i.%d match %.8f == %.8f pax.%p\n",errs,i,dstr(pax != 0 ? pax->komodoshis:-1),dstr(block.vtx[0].vout[i].nValue),pax); //komodo_paxmark(height,txids[i-1],vouts[i-1],height); //if ( pax->marked == 0 ) @@ -394,7 +393,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above for (j=0; j<32; j++) printf("%02x",((uint8_t *)&txids[i-1])[j]); printf(" cant paxfind X txid\n"); - // validate amount! via fiat chain } } } From c35c0838645da4f0e608e9ba82d8bd64e61f3d85 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 20:20:14 -0300 Subject: [PATCH 273/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5b0cf0b88..51451494e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -377,7 +377,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( ((opcode == 'I' && pax->fiatoshis == block.vtx[0].vout[i].nValue) || (opcode == 'X' && pax->komodoshis == block.vtx[0].vout[i].nValue)) ) { - if ( pax->marked != 0 ) + if ( pax->marked != 0 && height >= 80820 ) errs++; else matched++; if ( 0 && opcode == 'X' ) From 6d898f429458954931e4ccad91a28a6b8422bcee Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Nov 2016 20:36:00 -0300 Subject: [PATCH 274/549] test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 51451494e..1fa3c9877 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -150,9 +150,9 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; - for (i=0; i Date: Wed, 23 Nov 2016 20:45:22 -0300 Subject: [PATCH 275/549] test --- src/assetfunds | 64 +++++++++++++++++++++++++------------------------- src/komodo.h | 5 ++-- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/assetfunds b/src/assetfunds index b2bee93c1..df5f715a6 100755 --- a/src/assetfunds +++ b/src/assetfunds @@ -1,33 +1,33 @@ #!/bin/bash -./komodo-cli paxdeposit $1 aud 0.01 -./komodo-cli paxdeposit $1 bgn 0.01 -./komodo-cli paxdeposit $1 cad 0.01 -./komodo-cli paxdeposit $1 chf 0.01 -./komodo-cli paxdeposit $1 cny 0.01 -./komodo-cli paxdeposit $1 czk 0.01 -./komodo-cli paxdeposit $1 dkk 0.01 -./komodo-cli paxdeposit $1 eur 0.01 -./komodo-cli paxdeposit $1 gbp 0.01 -./komodo-cli paxdeposit $1 hkd 0.01 -./komodo-cli paxdeposit $1 hrk 0.01 -./komodo-cli paxdeposit $1 huf 0.01 -./komodo-cli paxdeposit $1 idr 0.01 -./komodo-cli paxdeposit $1 ils 0.01 -./komodo-cli paxdeposit $1 inr 0.01 -./komodo-cli paxdeposit $1 jpy 0.01 -./komodo-cli paxdeposit $1 krw 0.01 -./komodo-cli paxdeposit $1 mxn 0.01 -./komodo-cli paxdeposit $1 myr 0.01 -./komodo-cli paxdeposit $1 nok 0.01 -./komodo-cli paxdeposit $1 nzd 0.01 -./komodo-cli paxdeposit $1 php 0.01 -./komodo-cli paxdeposit $1 pln 0.01 -./komodo-cli paxdeposit $1 brl 0.01 -./komodo-cli paxdeposit $1 ron 0.01 -./komodo-cli paxdeposit $1 rub 0.01 -./komodo-cli paxdeposit $1 sek 0.01 -./komodo-cli paxdeposit $1 sgd 0.01 -./komodo-cli paxdeposit $1 thb 0.01 -./komodo-cli paxdeposit $1 try 0.01 -./komodo-cli paxdeposit $1 usd 0.01 -./komodo-cli paxdeposit $1 zar 0.01 +./komodo-cli paxdeposit $1 0.01 aud +./komodo-cli paxdeposit $1 0.01 bgn +./komodo-cli paxdeposit $1 0.01 cad +./komodo-cli paxdeposit $1 0.01 chf +./komodo-cli paxdeposit $1 0.01 cny +./komodo-cli paxdeposit $1 0.01 czk +./komodo-cli paxdeposit $1 0.01 dkk +./komodo-cli paxdeposit $1 0.01 eur +./komodo-cli paxdeposit $1 0.01 gbp +./komodo-cli paxdeposit $1 0.01 hkd +./komodo-cli paxdeposit $1 0.01 hrk +./komodo-cli paxdeposit $1 0.01 huf +./komodo-cli paxdeposit $1 0.01 idr +./komodo-cli paxdeposit $1 0.01 ils +./komodo-cli paxdeposit $1 0.01 inr +./komodo-cli paxdeposit $1 0.01 jpy +./komodo-cli paxdeposit $1 0.01 krw +./komodo-cli paxdeposit $1 0.01 mxn +./komodo-cli paxdeposit $1 0.01 myr +./komodo-cli paxdeposit $1 0.01 nok +./komodo-cli paxdeposit $1 0.01 nzd +./komodo-cli paxdeposit $1 0.01 php +./komodo-cli paxdeposit $1 0.01 pln +./komodo-cli paxdeposit $1 0.01 brl +./komodo-cli paxdeposit $1 0.01 ron +./komodo-cli paxdeposit $1 0.01 rub +./komodo-cli paxdeposit $1 0.01 sek +./komodo-cli paxdeposit $1 0.01 sgd +./komodo-cli paxdeposit $1 0.01 thb +./komodo-cli paxdeposit $1 0.01 try +./komodo-cli paxdeposit $1 0.01 usd +./komodo-cli paxdeposit $1 0.01 zar diff --git a/src/komodo.h b/src/komodo.h index 3bded0254..970ef50b9 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -17,9 +17,8 @@ #define H_KOMODO_H // Todo: -// 1. error check fiat redeem amounts -// 2. net balance limiter -// 3. verify: reorgs +// 1. net balance limiter +// 2. verify: reorgs // non komodod (non-hardfork) todo: // a. automate notarization fee payouts From 4307bd89d65ca16af8893dd422ae509209094039 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Nov 2016 07:23:52 -0300 Subject: [PATCH 276/549] test --- src/komodo_bitcoind.h | 2 ++ src/komodo_pax.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 7f2d202a1..db1ea8319 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -376,6 +376,8 @@ uint64_t komodo_seed(int32_t height) { uint256 hash; uint64_t seed = 0; CBlockIndex *pindex; memset(&hash,0,sizeof(hash)); + if ( height > 10 ) + height -= 10; if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( (pindex= chainActive[height]) != 0 ) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 77f7c5f1f..e7db138b1 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -348,6 +348,8 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba uint64_t _komodo_paxprice(int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t baseid=-1,relid=-1,i; uint32_t *ptr; + if ( height > 10 ) + height -= 10; if ( (baseid= komodo_baseid(base)) >= 0 && (relid= komodo_baseid(rel)) >= 0 ) { for (i=NUM_PRICES-1; i>=0; i--) From 7eb21300920b1ff81baa56ff7c9907ebcfb94d68 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Nov 2016 19:03:33 -0300 Subject: [PATCH 277/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1fa3c9877..45c9963f4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -411,7 +411,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( matched != num ) { // can easily happen depending on order of loading - if ( height > 60000 && opcode == 'X' ) + if ( height > 100000 && opcode == 'X' ) { printf("REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); return(-1); From 8c6619bc82a681dc8fb328c268a94e4116f55f1d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 11:05:25 -0300 Subject: [PATCH 278/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 45c9963f4..c523ffec7 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -380,7 +380,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( pax->marked != 0 && height >= 80820 ) errs++; else matched++; - if ( 0 && opcode == 'X' ) + if ( opcode == 'X' ) printf("errs.%d i.%d match %.8f == %.8f pax.%p\n",errs,i,dstr(pax != 0 ? pax->komodoshis:-1),dstr(block.vtx[0].vout[i].nValue),pax); //komodo_paxmark(height,txids[i-1],vouts[i-1],height); //if ( pax->marked == 0 ) From 3cbfd2b4b7be73cd3acdaa1922a8c8b71fc2e68d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 11:56:00 -0300 Subject: [PATCH 279/549] test --- src/komodo_gateway.h | 56 ++++++++++++++++++++++++++++++------------- src/komodo_structs.h | 2 +- src/rpcblockchain.cpp | 22 ++++++++++++++++- 3 files changed, 61 insertions(+), 19 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c523ffec7..dc3a067ff 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -15,6 +15,24 @@ // paxdeposit equivalent in reverse makes opreturn and KMD does the same in reverse +int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base) +{ + int32_t baseid; struct komodo_state *sp; + if ( (baseid= komodo_baseid(base)) >= 0 ) + { + if ( (sp= komodo_stateptrget(base)) != 0 ) + { + *deposited = sp->deposited; + *issued = sp->issued; + *withdrawn = sp->withdrawn; + *approved = sp->approved; + *redeemed = sp->redeemed; + return(0); + } + } + return(-1); +} + struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout) { struct pax_transaction *pax; @@ -65,7 +83,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { int32_t i; for (i=0; i<32; i++) printf("%02x",((uint8_t *)&txid)[i]); - printf(" v.%d [%s] kht.%d ht.%d create pax.%p\n",vout,ASSETCHAINS_SYMBOL,height,otherheight,pax); + printf(" v.%d [%s] kht.%d ht.%d create pax.%p symbol.%s source.%d\n",vout,ASSETCHAINS_SYMBOL,height,otherheight,pax,symbol,source); } } pthread_mutex_unlock(&komodo_mutex); @@ -92,8 +110,8 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (pax->approved= approved) != 0 ) s = (char *)"APPROVED"; - else s = (char *)(ASSETCHAINS_SYMBOL[0]==0?"WITHDRAW":"DEPOSIT"); - printf("[%s] addflag.%d ADD %s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); + else s = (char *)((ASSETCHAINS_SYMBOL[0] == 0) ? "WITHDRAW" : "DEPOSIT"); + printf("[%s] addflag.%d ADD %s/%s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,source,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); } } //else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height,otherheight); @@ -282,7 +300,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to continue; if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 ) continue; - //if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 ) printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); txNew->vout.resize(numvouts+1); txNew->vout[numvouts].nValue = (opcode == 'I') ? pax->fiatoshis : pax->komodoshis; @@ -297,24 +315,14 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to if ( tokomodo == 0 ) { for (i=0; i<32; i++) - { - //printf("%02x",((uint8_t *)&pax->txid)[i]); data[len++] = ((uint8_t *)&pax->txid)[i]; - } data[len++] = pax->vout & 0xff; data[len++] = (pax->vout >> 8) & 0xff; PENDING_KOMODO_TX += pax->fiatoshis; } else { - //[{"prev_hash":"5d5c9a49489b558de9e84f991f996dedaae6b9d0f157f82b2fec64662476d5cf","prev_vout":2,"EUR":0.10000000,"fiat":"EUR","kmdheight":57930,"height":153,"KMD":0.78329000,"address":"RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5","rmd160":"306c507eea639e7220b3069ed9f49f3bc97eaca1"}] len += komodo_rwapproval(1,&data[len],pax); - /*len += iguana_rwnum(1,&data[len],sizeof(pax->fiatoshis),&pax->fiatoshis); - len += iguana_rwnum(1,&data[len],sizeof(pax->height),&pax->height); - len += iguana_rwnum(1,&data[len],sizeof(pax->otherheight),&pax->otherheight); - for (i=0; pax->symbol[i]!=0&&i<3; i++) // must be 3 letter currency - data[len++] = pax->symbol[i]; - data[len++] = 0;*/ PENDING_KOMODO_TX += pax->komodoshis; printf(" vout.%u DEPOSIT %.8f <- pax.%s pending %.8f | ",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX)); } @@ -382,7 +390,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above else matched++; if ( opcode == 'X' ) printf("errs.%d i.%d match %.8f == %.8f pax.%p\n",errs,i,dstr(pax != 0 ? pax->komodoshis:-1),dstr(block.vtx[0].vout[i].nValue),pax); - //komodo_paxmark(height,txids[i-1],vouts[i-1],height); + //komodo_paxmark(height,txids[i-1],vouts[i-1],height); is called multiple times //if ( pax->marked == 0 ) // printf("unexpected unmarked %p\n",pax); } @@ -425,7 +433,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *basesp; const char *typestr = "unknown"; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); @@ -459,6 +467,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( komodo_paxfind(txid,vout) == 0 ) { + if ( (basesp= komodo_stateptrget(base)) != 0 ) + basesp->deposited += fiatoshis; komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } else printf("duplicate deposit\n"); } @@ -479,6 +489,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( (pax= komodo_paxfind(txid,vout)) == 0 ) { + if ( (basesp= komodo_stateptrget(base)) != 0 ) + basesp->withdraw += value; printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height,source,0); @@ -508,7 +520,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,values[i],CURRENCIES[baseids[i]],srcvalues[i],&rmd160s[i*20],txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); - printf(" i.%d (%s) <- %.8f\n",i,coinaddr,dstr(values[i])); + if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + basesp->approved += srcvalues[i]; + printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); } else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { @@ -529,7 +543,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 && baseids[i] >= 0 ) + { + if ( (basesp= komodo_stateptrget(base)) != 0 ) + basesp->issued += srcvalues[i]; komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); + } } } } @@ -544,7 +562,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,60,&rmd160s[i*20],20); printf("i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) + { + if ( (basesp= komodo_stateptrget(base)) != 0 ) + basesp->redeemed += srcvalues[i]; komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); + } } } else printf("komodo_issued_opreturn returned %d\n",n); } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 2741fafb9..75483b9f3 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -62,7 +62,6 @@ struct pax_transaction char symbol[16],source[16],coinaddr[64]; uint8_t rmd160[20],shortflag; }; -//struct nutxo_entry { UT_hash_handle hh; uint256 txhash; uint64_t voutmask; int32_t notaryid,height; }; struct knotary_entry { UT_hash_handle hh; uint8_t pubkey[33],notaryid; }; struct knotaries_entry { int32_t height,numnotaries; struct knotary_entry *Notaries; }; struct notarized_checkpoint { uint256 notarized_hash,notarized_desttxid; int32_t nHeight,notarized_height; }; @@ -72,6 +71,7 @@ struct komodo_state uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID; int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT; uint32_t SAVEDTIMESTAMP; + uint64_t deposited,issued,withdrawn,approved,redeemed; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS; struct komodo_event **Komodo_events; int32_t Komodo_numevents; uint32_t RTbufs[64][3]; uint64_t RTmask; diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 418fbc73e..9493f49f5 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -481,16 +481,36 @@ Value notaries(const Array& params, bool fHelp) } int32_t komodo_pending_withdraws(char *opretstr); +int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); +extern char CURRENCIES[][32]; Value paxpending(const Array& params, bool fHelp) { - Object ret; char opretbuf[10000*2]; int32_t opretlen; + Object ret; Array a; char opretbuf[10000*2]; int32_t opretlen,baseid; uint64_t deposited,issued,withdrawn,approved,redeemed; if ( fHelp || params.size() != 0 ) throw runtime_error("paxpending needs no args\n"); LOCK(cs_main); if ( (opretlen= komodo_pending_withdraws(opretbuf)) > 0 ) ret.push_back(Pair("withdraws", opretbuf)); else ret.push_back(Pair("withdraws", (char *)"")); + for (baseid=0; baseid<32; baseid++) + { + Object item,obj; + if ( pax_fiatstatus(&deposited,&issued,&withdrawn,&approved,&redeemed,CURRENCIES[baseid]) == 0 ) + { + if ( deposited != 0 || issued != 0 || withdrawn != 0 || approved != 0 || redeemed != 0 ) + { + item.push_back(Pair("deposited", deposited)); + item.push_back(Pair("issued", issued)); + item.push_back(Pair("withdrawn", withdrawn)); + item.push_back(Pair("approved", approved)); + item.push_back(Pair("redeemed", redeemed)); + obj.push_back(Pair(CURRENCIES[baseid],item)); + a.push_back(obj); + } + } + } + ret.push_back(Pair("fiatstatus", a)); return ret; } From 5ce8bf22a17fa2d2f58bdb5c8a677102235970a3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 11:58:02 -0300 Subject: [PATCH 280/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index dc3a067ff..da899c8a0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -83,7 +83,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { int32_t i; for (i=0; i<32; i++) printf("%02x",((uint8_t *)&txid)[i]); - printf(" v.%d [%s] kht.%d ht.%d create pax.%p symbol.%s source.%d\n",vout,ASSETCHAINS_SYMBOL,height,otherheight,pax,symbol,source); + printf(" v.%d [%s] kht.%d ht.%d create pax.%p symbol.%s source.%s\n",vout,ASSETCHAINS_SYMBOL,height,otherheight,pax,symbol,source); } } pthread_mutex_unlock(&komodo_mutex); @@ -490,7 +490,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (pax= komodo_paxfind(txid,vout)) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) - basesp->withdraw += value; + basesp->withdrawn += value; printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height,source,0); From bafc0147a10fd37ff698198c48ca165300f249de Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:03:22 -0300 Subject: [PATCH 281/549] test --- src/komodo_gateway.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index da899c8a0..92a8079aa 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -109,8 +109,25 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( addflag != 0 ) { if ( (pax->approved= approved) != 0 ) + { s = (char *)"APPROVED"; - else s = (char *)((ASSETCHAINS_SYMBOL[0] == 0) ? "WITHDRAW" : "DEPOSIT"); + if ( (basesp= komodo_stateptrget(symbol)) != 0 ) + basesp->approved += fiatoshis; + } + else + { + s = (char *)((ASSETCHAINS_SYMBOL[0] == 0) ? "WITHDRAW" : "DEPOSIT"); + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + { + if ( (basesp= komodo_stateptrget(source)) != 0 ) + basesp->withdraw += fiatoshis; + } + else + { + if ( (basesp= komodo_stateptrget(symbol)) != 0 ) + basesp->deposited += fiatoshis; + } + } printf("[%s] addflag.%d ADD %s/%s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,source,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); } } From 04652b71f49e87205007aa2fe0d6d2c838aad542 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:06:52 -0300 Subject: [PATCH 282/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 92a8079aa..18831b361 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -68,7 +68,7 @@ struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context { - struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16],*s; + struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp,*basesp; char str[16],dest[16],*s; sp = komodo_stateptr(str,dest); pthread_mutex_lock(&komodo_mutex); HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); From 854aa9b356b529473e9b4a2d2e554576089b3573 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:07:42 -0300 Subject: [PATCH 283/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 18831b361..ede1e03c1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -120,7 +120,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( (basesp= komodo_stateptrget(source)) != 0 ) - basesp->withdraw += fiatoshis; + basesp->withdrawn += fiatoshis; } else { From 0fa85cc34d96e8a6aeb36ccd0e0b735aab94babe Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:14:59 -0300 Subject: [PATCH 284/549] test --- src/komodo_gateway.h | 28 ++++++++++++++++++++++++++-- src/komodo_pax.h | 4 ++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ede1e03c1..d1e7a86fe 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -112,7 +112,10 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { s = (char *)"APPROVED"; if ( (basesp= komodo_stateptrget(symbol)) != 0 ) + { basesp->approved += fiatoshis; + printf("########### approved %s += %.8f\n",symbol,dstr(fiatoshis)); + } } else { @@ -120,12 +123,18 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( (basesp= komodo_stateptrget(source)) != 0 ) + { basesp->withdrawn += fiatoshis; + printf("########### withdrawn %s += %.8f\n",source,dstr(fiatoshis)); + } } else { if ( (basesp= komodo_stateptrget(symbol)) != 0 ) + { basesp->deposited += fiatoshis; + printf("########### deposited %s += %.8f\n",symbol,dstr(fiatoshis)); + } } } printf("[%s] addflag.%d ADD %s/%s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,source,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); @@ -254,8 +263,8 @@ uint64_t komodo_paxtotal() { seed = 0; checktoshis = komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatoshis); - printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",pax->height,pax->symbol,(double)pax->fiatoshis/COIN,(double)pax->komodoshis/COIN,(double)checktoshis/COIN); - printf(" v%d %.8f k.%d ht.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight); + //printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",pax->height,pax->symbol,(double)pax->fiatoshis/COIN,(double)pax->komodoshis/COIN,(double)checktoshis/COIN); + //printf(" v%d %.8f k.%d ht.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight); if ( seed != 0 ) { if ( checktoshis >= pax->komodoshis ) @@ -485,7 +494,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( komodo_paxfind(txid,vout) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) + { basesp->deposited += fiatoshis; + printf("########### deposited %s += %.8f\n",base,dstr(fiatoshis)); + } komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } else printf("duplicate deposit\n"); } @@ -507,7 +519,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (pax= komodo_paxfind(txid,vout)) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) + { basesp->withdrawn += value; + printf("########### withdrawn %s += %.8f\n",base,dstr(value)); + } printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height,source,0); @@ -538,7 +553,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,values[i],CURRENCIES[baseids[i]],srcvalues[i],&rmd160s[i*20],txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + { basesp->approved += srcvalues[i]; + printf("########### approved %s += %.8f\n",CURRENCIES[baseids[i]],dstr(srcvalues[i])); + } printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); } else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) @@ -562,7 +580,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 && baseids[i] >= 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) + { basesp->issued += srcvalues[i]; + printf("########### issued %s += %.8f\n",base,dstr(srcvalues[i])); + } komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } } @@ -581,7 +602,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) + { basesp->redeemed += srcvalues[i]; + printf("########### redeemed %s += %.8f\n",base,dstr(srcvalues[i])); + } komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); } } diff --git a/src/komodo_pax.h b/src/komodo_pax.h index e7db138b1..c415c2bbe 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -428,7 +428,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin } sum /= densum; sum = (sum * basevolume) / 100000; - printf("paxprice seed.%llx sum %.8f densum %.8f basevol %.8f height.%d\n",(long long)seed,dstr(sum),dstr(densum),dstr(basevolume),height); + //printf("paxprice seed.%llx sum %.8f densum %.8f basevol %.8f height.%d\n",(long long)seed,dstr(sum),dstr(densum),dstr(basevolume),height); break; } } @@ -473,7 +473,7 @@ uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pu if ( fiatoshis < 0 ) shortflag = 1, fiatoshis = -fiatoshis; komodoshis = komodo_paxprice(seedp,height,base,(char *)"KMD",(uint64_t)fiatoshis); - printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN); + //printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN); if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) == 20 ) { PAX_pubkey(1,pubkey33,&addrtype,rmd160,base,&shortflag,tokomodo != 0 ? &komodoshis : &fiatoshis); From ad16127c53ac9bbb77e7191179cdaaa286a71384 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:28:38 -0300 Subject: [PATCH 285/549] test --- src/komodo_gateway.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d1e7a86fe..71f17d5ac 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -27,6 +27,7 @@ int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; + printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,*deposited,*issued,*withdrawn,*approved,*redeemed); return(0); } } @@ -114,7 +115,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { basesp->approved += fiatoshis; - printf("########### approved %s += %.8f\n",symbol,dstr(fiatoshis)); + printf("########### %p approved %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } } else @@ -125,7 +126,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( (basesp= komodo_stateptrget(source)) != 0 ) { basesp->withdrawn += fiatoshis; - printf("########### withdrawn %s += %.8f\n",source,dstr(fiatoshis)); + printf("########### %p withdrawn %s += %.8f\n",basesp,source,dstr(fiatoshis)); } } else @@ -133,7 +134,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { basesp->deposited += fiatoshis; - printf("########### deposited %s += %.8f\n",symbol,dstr(fiatoshis)); + printf("########### %p deposited %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } } } @@ -496,7 +497,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->deposited += fiatoshis; - printf("########### deposited %s += %.8f\n",base,dstr(fiatoshis)); + printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } else printf("duplicate deposit\n"); @@ -521,7 +522,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->withdrawn += value; - printf("########### withdrawn %s += %.8f\n",base,dstr(value)); + printf("########### %p withdrawn %s += %.8f\n",basesp,base,dstr(value)); } printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } @@ -555,7 +556,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->approved += srcvalues[i]; - printf("########### approved %s += %.8f\n",CURRENCIES[baseids[i]],dstr(srcvalues[i])); + printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); } else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); @@ -582,7 +583,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->issued += srcvalues[i]; - printf("########### issued %s += %.8f\n",base,dstr(srcvalues[i])); + printf("########### %p issued %s += %.8f\n",basesp,base,dstr(srcvalues[i])); } komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } @@ -604,7 +605,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->redeemed += srcvalues[i]; - printf("########### redeemed %s += %.8f\n",base,dstr(srcvalues[i])); + printf("########### %p redeemed %s += %.8f\n",basesp,base,dstr(srcvalues[i])); } komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); } From f47488db92098e7d576d3557bd73b7c77fbbb0df Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:30:38 -0300 Subject: [PATCH 286/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 71f17d5ac..517d540e4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -27,7 +27,7 @@ int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; - printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,*deposited,*issued,*withdrawn,*approved,*redeemed); + printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); return(0); } } From ee5e5744f18c2272e788f504f939240417bd12ee Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:34:59 -0300 Subject: [PATCH 287/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 517d540e4..b045199e9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -29,8 +29,8 @@ int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn, *redeemed = sp->redeemed; printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); return(0); - } - } + } else printf("pax_fiatstatus cant get basesp.%s\n",base); + } else printf("pax_fiatstatus illegal base.%s\n",base); return(-1); } From 700606cc2b259c347432257806d16853df7e1e61 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:39:29 -0300 Subject: [PATCH 288/549] test --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 9493f49f5..b6b8780a5 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -482,7 +482,7 @@ Value notaries(const Array& params, bool fHelp) int32_t komodo_pending_withdraws(char *opretstr); int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); -extern char CURRENCIES[][32]; +extern char CURRENCIES[][8]; Value paxpending(const Array& params, bool fHelp) { From 1db587b509e53c99ce668a4641d7cd5927086ed4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:52:00 -0300 Subject: [PATCH 289/549] test --- src/komodo_gateway.h | 61 +++++++++++++++++++++++-------------------- src/komodo_structs.h | 2 +- src/rpcblockchain.cpp | 10 +++---- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b045199e9..2ed1623bc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -27,7 +27,7 @@ int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; - printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); + //printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); return(0); } else printf("pax_fiatstatus cant get basesp.%s\n",base); } else printf("pax_fiatstatus illegal base.%s\n",base); @@ -105,39 +105,44 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t pax->height = height; if ( otherheight != 0 ) pax->otherheight = otherheight; + if ( pax->didstats == 0 && fiatoshis == 0 ) + { + if ( (pax->approved= approved) != 0 ) + { + if ( (basesp= komodo_stateptrget(symbol)) != 0 ) + { + basesp->approved += fiatoshis; + printf("########### %p approved %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); + } + } + else + { + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + { + if ( (basesp= komodo_stateptrget(source)) != 0 ) + { + basesp->withdrawn += fiatoshis; + printf("########### %p withdrawn %s += %.8f\n",basesp,source,dstr(fiatoshis)); + } + } + else + { + if ( (basesp= komodo_stateptrget(symbol)) != 0 ) + { + basesp->deposited += fiatoshis; + printf("########### %p deposited %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); + } + } + } + pax->didstats = 1; + } if ( pax->marked == 0 ) { if ( addflag != 0 ) { if ( (pax->approved= approved) != 0 ) - { s = (char *)"APPROVED"; - if ( (basesp= komodo_stateptrget(symbol)) != 0 ) - { - basesp->approved += fiatoshis; - printf("########### %p approved %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); - } - } - else - { - s = (char *)((ASSETCHAINS_SYMBOL[0] == 0) ? "WITHDRAW" : "DEPOSIT"); - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { - if ( (basesp= komodo_stateptrget(source)) != 0 ) - { - basesp->withdrawn += fiatoshis; - printf("########### %p withdrawn %s += %.8f\n",basesp,source,dstr(fiatoshis)); - } - } - else - { - if ( (basesp= komodo_stateptrget(symbol)) != 0 ) - { - basesp->deposited += fiatoshis; - printf("########### %p deposited %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); - } - } - } + else s = (char *)((ASSETCHAINS_SYMBOL[0] == 0) ? "WITHDRAW" : "DEPOSIT"); printf("[%s] addflag.%d ADD %s/%s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,source,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); } } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 75483b9f3..402d6a859 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -57,7 +57,7 @@ struct pax_transaction UT_hash_handle hh; uint256 txid; uint64_t komodoshis,fiatoshis,validated; - int32_t marked,height,otherheight,approved; + int32_t marked,height,otherheight,approved,didstats; uint16_t vout; char symbol[16],source[16],coinaddr[64]; uint8_t rmd160[20],shortflag; }; diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index b6b8780a5..4b1102005 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -500,11 +500,11 @@ Value paxpending(const Array& params, bool fHelp) { if ( deposited != 0 || issued != 0 || withdrawn != 0 || approved != 0 || redeemed != 0 ) { - item.push_back(Pair("deposited", deposited)); - item.push_back(Pair("issued", issued)); - item.push_back(Pair("withdrawn", withdrawn)); - item.push_back(Pair("approved", approved)); - item.push_back(Pair("redeemed", redeemed)); + item.push_back(Pair("deposited", ValueFromAmount(deposited))); + item.push_back(Pair("issued", ValueFromAmount(issued))); + item.push_back(Pair("withdrawn", ValueFromAmount(withdrawn))); + item.push_back(Pair("approved", ValueFromAmount(approved))); + item.push_back(Pair("redeemed", ValueFromAmount(redeemed))); obj.push_back(Pair(CURRENCIES[baseid],item)); a.push_back(obj); } From 1c6e217d21b77c17ad31905d7e5c1baf253325f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 13:07:38 -0300 Subject: [PATCH 290/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2ed1623bc..9c905f9d4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -484,7 +484,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,addrtype,rmd160,20); checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,fiatoshis); typestr = "deposit"; - printf("%s kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); + printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); if ( kmdheight <= height ) { if ( tokomodo == 0 && strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) From c98b3a088d244d77547ad2951bb58beb27b65ffc Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 13:18:52 -0300 Subject: [PATCH 291/549] test --- src/komodo_gateway.h | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9c905f9d4..38bf6cf79 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -487,26 +487,24 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); if ( kmdheight <= height ) { - if ( tokomodo == 0 && strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&txid)[i]); + printf(" <- txid.v%u ",vout); + for (i=0; i<33; i++) + printf("%02x",pubkey33[i]); + printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); + if ( value >= checktoshis-(checktoshis >> 10) ) { - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&txid)[i]); - printf(" <- txid.v%u ",vout); - for (i=0; i<33; i++) - printf("%02x",pubkey33[i]); - printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); - if ( value >= checktoshis-(checktoshis >> 10) ) + if ( komodo_paxfind(txid,vout) == 0 ) { - if ( komodo_paxfind(txid,vout) == 0 ) + if ( (basesp= komodo_stateptrget(base)) != 0 ) { - if ( (basesp= komodo_stateptrget(base)) != 0 ) - { - basesp->deposited += fiatoshis; - printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); - } + basesp->deposited += fiatoshis; + printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); + } + if ( tokomodo == 0 && strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); - } else printf("duplicate deposit\n"); - } + } else printf("duplicate deposit\n"); } } } From d61cc4794aace9422c5dc59c4f581907f41f0d29 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 14:08:57 -0300 Subject: [PATCH 292/549] test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 38bf6cf79..5ffb5952f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -574,7 +574,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( tokomodo == 0 && opretbuf[0] == 'I' ) { - if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) + //if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) { if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 ) { @@ -583,7 +583,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,60,&rmd160s[i*20],20); if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 && baseids[i] >= 0 ) { - if ( (basesp= komodo_stateptrget(base)) != 0 ) + if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->issued += srcvalues[i]; printf("########### %p issued %s += %.8f\n",basesp,base,dstr(srcvalues[i])); @@ -605,7 +605,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { - if ( (basesp= komodo_stateptrget(base)) != 0 ) + if ( baseids[i] >= 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->redeemed += srcvalues[i]; printf("########### %p redeemed %s += %.8f\n",basesp,base,dstr(srcvalues[i])); From f5e3cdfa8ad771f4e0c78b882f264198c28e8e2a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 14:22:08 -0300 Subject: [PATCH 293/549] test --- src/komodo_gateway.h | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5ffb5952f..3eaffddc2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -422,9 +422,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above else matched++; if ( opcode == 'X' ) printf("errs.%d i.%d match %.8f == %.8f pax.%p\n",errs,i,dstr(pax != 0 ? pax->komodoshis:-1),dstr(block.vtx[0].vout[i].nValue),pax); - //komodo_paxmark(height,txids[i-1],vouts[i-1],height); is called multiple times - //if ( pax->marked == 0 ) - // printf("unexpected unmarked %p\n",pax); } else { @@ -465,7 +462,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *basesp; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *basesp; const char *typestr = "unknown"; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); @@ -493,17 +490,23 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 for (i=0; i<33; i++) printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); - if ( value >= checktoshis-(checktoshis >> 10) ) + didstats = 0; + if ( value >= checktoshis-(checktoshis >> 8) ) { if ( komodo_paxfind(txid,vout) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->deposited += fiatoshis; + didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } if ( tokomodo == 0 && strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) + { komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); + if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) + pax->didstats = 1; + } } else printf("duplicate deposit\n"); } } @@ -518,6 +521,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value); typestr = "withdraw"; printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); + didstats = 0; if ( checktoshis <= komodoshis+(komodoshis >> 10) ) { if ( (pax= komodo_paxfind(txid,vout)) == 0 ) @@ -525,11 +529,14 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->withdrawn += value; + didstats = 1; printf("########### %p withdrawn %s += %.8f\n",basesp,base,dstr(value)); } printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height,source,0); + if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) + pax->didstats = 1; } } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) @@ -546,6 +553,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( baseids[i] < 0 ) continue; + didstats = 0; seed = 0; checktoshis = komodo_paxprice(&seed,kmdheights[i],CURRENCIES[baseids[i]],(char *)"KMD",(uint64_t)srcvalues[i]); printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",kmdheights[i],CURRENCIES[baseids[i]],(double)srcvalues[i]/COIN,(double)values[i]/COIN,(double)checktoshis/COIN); @@ -559,6 +567,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->approved += srcvalues[i]; + didstats = 1; printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); @@ -566,6 +575,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->approved = kmdheights[i]; + if ( didstats != 0 ) + pax->didstats = 1; printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); } } @@ -574,22 +585,31 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( tokomodo == 0 && opretbuf[0] == 'I' ) { - //if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) + if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) { if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 ) { for (i=0; i= 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->issued += srcvalues[i]; printf("########### %p issued %s += %.8f\n",basesp,base,dstr(srcvalues[i])); } + didstats = 1; + } + if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) + { komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } + if ( didstats != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) + pax->didstats = 1; } } } @@ -601,17 +621,25 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { for (i=0; i %s\n",i,n,dstr(values[i]),coinaddr); - if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 ) { if ( baseids[i] >= 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->redeemed += srcvalues[i]; + didstats = 1; printf("########### %p redeemed %s += %.8f\n",basesp,base,dstr(srcvalues[i])); } + didstats = 1; + } + if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) + { komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); } + if ( didstats != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) + pax->didstats = 1; } } else printf("komodo_issued_opreturn returned %d\n",n); } From 3f9cad6dac5f08d7b5f5aa26dfd15bbf458734a4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 14:34:00 -0300 Subject: [PATCH 294/549] test --- src/komodo_gateway.h | 43 +++++++++++++++++++++++++++++++------------ src/miner.cpp | 4 ++-- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3eaffddc2..54ab9eed6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -493,7 +493,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 0; if ( value >= checktoshis-(checktoshis >> 8) ) { - if ( komodo_paxfind(txid,vout) == 0 ) + if ( (pax= komodo_paxfind(txid,vout)) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { @@ -504,10 +504,19 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( tokomodo == 0 && strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) { komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); - if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) - pax->didstats = 1; } - } else printf("duplicate deposit\n"); + } + else if ( pax->didstats == 0 ) + { + if ( (basesp= komodo_stateptrget(base)) != 0 ) + { + basesp->deposited += fiatoshis; + didstats = 1; + printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); + } + } + if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) + pax->didstats = 1; } } } @@ -524,7 +533,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 0; if ( checktoshis <= komodoshis+(komodoshis >> 10) ) { - if ( (pax= komodo_paxfind(txid,vout)) == 0 ) + if ( (pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { @@ -571,7 +580,17 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); - } else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); + } + else if ( pax->didstats == 0 ) + { + if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + { + basesp->approved += srcvalues[i]; + didstats = 1; + printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); + } + } + else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->approved = kmdheights[i]; @@ -595,7 +614,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 continue; didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0 ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { @@ -621,23 +640,23 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { for (i=0; i %s\n",i,n,dstr(values[i]),coinaddr); - if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0 ) { - if ( baseids[i] >= 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->redeemed += srcvalues[i]; didstats = 1; - printf("########### %p redeemed %s += %.8f\n",basesp,base,dstr(srcvalues[i])); + printf("########### %p redeemed %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } didstats = 1; } if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) - { komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); - } if ( didstats != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) pax->didstats = 1; } diff --git a/src/miner.cpp b/src/miner.cpp index 737af64f5..939e60371 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -99,7 +99,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, } #define ASSETCHAINS_MINHEIGHT 100 -#define ROUNDROBIN_DELAY 59 +#define ROUNDROBIN_DELAY 60 extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; @@ -647,7 +647,7 @@ void static BitcoinMiner(CWallet *pwallet) int32_t nseconds = Mining_start+ROUNDROBIN_DELAY-time(NULL); if ( nseconds > 0 ) sleep(nseconds); - MilliSleep((rand() % 2000) + 1); + MilliSleep((rand() % 5000) + 1); KOMODO_CHOSEN_ONE = 1; } // Found a solution From e97061cb0ff1ee2c65fac4e36ef2a8ebc7ddcc92 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 14:43:42 -0300 Subject: [PATCH 295/549] test --- src/komodo_gateway.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 54ab9eed6..442eea667 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -460,9 +460,19 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above return(0); } +int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) +{ + if ( seed == 0 ) + { + value >>= 7; + checkvalue >>= 7; + } + return(value != checkvalue); +} + const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *basesp; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *basesp; double diff; const char *typestr = "unknown"; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); @@ -491,7 +501,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); didstats = 0; - if ( value >= checktoshis-(checktoshis >> 8) ) + if ( komodo_paxcmp(value,checktoshis,seed) == 0 )//value >= checktoshis-(checktoshis >> 8) ) { if ( (pax= komodo_paxfind(txid,vout)) == 0 ) { @@ -531,7 +541,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 typestr = "withdraw"; printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); didstats = 0; - if ( checktoshis <= komodoshis+(komodoshis >> 10) ) + if ( komodo_paxcmp(komodoshis,checktoshis,seed) == 0 ) //checktoshis <= komodoshis+(komodoshis >> 10) ) { if ( (pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0 ) { From e5e64f55f5ea0030526de9291e3a82ed34163ce8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 14:48:34 -0300 Subject: [PATCH 296/549] test --- src/komodo_gateway.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 442eea667..15469d6ed 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -462,10 +462,14 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) { + int32_t ratio; if ( seed == 0 ) { - value >>= 7; - checkvalue >>= 7; + value <<= 10; + ratio = (checkvalue / value); + if ( ratio >= 1023 && ratio <= 1025 ) + return(0); + else return(-1); } return(value != checkvalue); } From 85586b43cf23134f41e15fabb557c587abc5cf68 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 14:50:54 -0300 Subject: [PATCH 297/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 15469d6ed..6f2385990 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -466,7 +466,7 @@ int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) if ( seed == 0 ) { value <<= 10; - ratio = (checkvalue / value); + ratio = (value / checkvalue); if ( ratio >= 1023 && ratio <= 1025 ) return(0); else return(-1); From 02862b723560e1021141d10f9f20776b67c1b796 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 14:57:45 -0300 Subject: [PATCH 298/549] test --- src/komodo_gateway.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6f2385990..d385996a6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -105,7 +105,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t pax->height = height; if ( otherheight != 0 ) pax->otherheight = otherheight; - if ( pax->didstats == 0 && fiatoshis == 0 ) + if ( pax->didstats == 0 && fiatoshis != 0 ) { if ( (pax->approved= approved) != 0 ) { @@ -465,11 +465,14 @@ int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) int32_t ratio; if ( seed == 0 ) { - value <<= 10; - ratio = (value / checkvalue); + ratio = ((value << 10) / checkvalue); if ( ratio >= 1023 && ratio <= 1025 ) return(0); - else return(-1); + else + { + printf("value %lld vs checkvalue %lld -> ratio.%d\n",(long long)value,(long long)checkvalue,ratio); + return(-1); + } } return(value != checkvalue); } From c1bc18049c47489618990d091f3ffca782a62c67 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 12:03:42 -0300 Subject: [PATCH 299/549] test --- src/komodo_gateway.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d385996a6..035d766a0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -647,7 +647,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( didstats != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) pax->didstats = 1; } - } + } else printf("opreturn none issued?\n"); } } else if ( opretbuf[0] == 'X' ) @@ -701,6 +701,8 @@ void komodo_passport_iteration() sp = 0; isrealtime = 0; base = (char *)CURRENCIES[baseid]; +if ( strcmp("EUR",base) != 0 && baseid < 32 ) + continue; if ( baseid+1 != refid ) { komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"komodostate"); From 20e098469562284af6bb0f3559531fdc55f0e388 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 12:18:30 -0300 Subject: [PATCH 300/549] test --- src/komodo_gateway.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 035d766a0..d02a117df 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -619,7 +619,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal())); } - else if ( tokomodo == 0 && opretbuf[0] == 'I' ) + else if ( opretbuf[0] == 'I' ) { if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) { @@ -642,7 +642,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { - komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); + if ( tokomodo == 0 ) + komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } if ( didstats != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) pax->didstats = 1; From b971ca89331f1a12a7185c6ddeb97e4ea6acfe1d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 12:25:56 -0300 Subject: [PATCH 301/549] test --- src/komodo_gateway.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d02a117df..fff8beb47 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -628,7 +628,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 for (i=0; ididstats == 0 ) @@ -649,7 +652,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax->didstats = 1; } } else printf("opreturn none issued?\n"); - } + } else printf("opreturn matches KMD? %s\n",(char *)&opretbuf[opretlen-4]); } else if ( opretbuf[0] == 'X' ) { From 0e1af8ed0051bad3883f6d2acae9249c8ffee93e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 12:33:08 -0300 Subject: [PATCH 302/549] test --- src/komodo_gateway.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index fff8beb47..105dfa2b6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -200,8 +200,9 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; - //for (i=0; i Date: Sat, 26 Nov 2016 12:55:36 -0300 Subject: [PATCH 303/549] test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 105dfa2b6..1ff88ad5a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -240,6 +240,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t } vouts[n] = opretbuf[len++]; vouts[n] = (opretbuf[len++] << 8) | vouts[n]; + baseids[n] = komodo_baseid(base); } //printf(" komodo_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); } From 54661780d87674258ceb243aaa156b710cc467c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 13:12:38 -0300 Subject: [PATCH 304/549] test --- src/komodo_gateway.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1ff88ad5a..da854eccb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -196,7 +196,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int64_t *srcvalues,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) { - struct pax_transaction p; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t type,rmd160[20]; uint64_t fiatoshis; char symbol[16]; + struct pax_transaction p,*pax; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t type,rmd160[20]; uint64_t fiatoshis; char symbol[16]; incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; @@ -241,6 +241,14 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t vouts[n] = opretbuf[len++]; vouts[n] = (opretbuf[len++] << 8) | vouts[n]; baseids[n] = komodo_baseid(base); + if ( (pax= komodo_paxfind(txids[n],vouts[n])) != 0 ) + { + values[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? pax->komodoshis : pax->fiatoshis; + srcvalues[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? pax->fiatoshis : pax->komodoshis; + kmdheights[n] = pax->height; + otherheights[n] = pax->otherheight; + memcpy(&rmd160s[n * 20],pax->rmd160,20); + } } //printf(" komodo_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); } @@ -325,8 +333,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to opcode = 'I'; if ( komodo_isrealtime(&ht) == 0 ) return(0); - } - else opcode = 'X'; + } else opcode = 'X'; HASH_ITER(hh,PAX,pax,tmp) { //printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); From ca75995d16e1da8ad57522435d5619f1dc02df52 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 14:13:02 -0300 Subject: [PATCH 305/549] test --- src/komodo_gateway.h | 74 ++++++++++++++++++++++++++++++++++++-------- src/komodo_structs.h | 2 +- 2 files changed, 62 insertions(+), 14 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index da854eccb..c00558719 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -258,9 +258,36 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t uint64_t komodo_paxtotal() { - struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; int32_t ht; int64_t checktoshis; uint64_t seed,total = 0; + struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[16],dest[16]; int32_t ht; int64_t checktoshis; uint64_t seed,total = 0; struct komodo_state *basesp; if ( komodo_isrealtime(&ht) == 0 ) return(0); + else + { + HASH_ITER(hh,PAX,pax,tmp) + { + if ( pax->didstats == 0 && pax->type == 'I' ) + { + HASH_ITER(hh,PAX,pax2,tmp2) + { + if ( pax != pax2 && pax->txid == pax2->txid ) + { + if ( pax2->fiatoshis != 0 ) + { + pax->fiatoshis = pax2->fiatoshis; + pax->komodoshis = pax2->komodoshis; + memcpy(pax->rmd160,pax2->rmd160,20); + if ( (basesp= komodo_stateptrget(pax->source)) != 0 ) + { + basep->issued += pax->fiatoshis; + pax->didstats = 1; + printf("found match for %s %.8f\n",pax->symbol,dstr(pax->fiatoshis)); + } else printf("paxtotal cant find.(%s)\n",pax->source); + } + } + } + } + } + } komodo_stateptr(symbol,dest); HASH_ITER(hh,PAX,pax,tmp) { @@ -424,6 +451,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( (pax= komodo_paxfind(txids[i-1],vouts[i-1])) != 0 ) { + pax->type = opcode; if ( ((opcode == 'I' && pax->fiatoshis == block.vtx[0].vout[i].nValue) || (opcode == 'X' && pax->komodoshis == block.vtx[0].vout[i].nValue)) ) { if ( pax->marked != 0 && height >= 80820 ) @@ -532,17 +560,24 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } } - else if ( pax->didstats == 0 ) + else { - if ( (basesp= komodo_stateptrget(base)) != 0 ) + pax->type = opretbuf[0]; + if ( pax->didstats == 0 ) { - basesp->deposited += fiatoshis; - didstats = 1; - printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); + if ( (basesp= komodo_stateptrget(base)) != 0 ) + { + basesp->deposited += fiatoshis; + didstats = 1; + printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); + } } } if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) + { pax->didstats = 1; + pax->type = opretbuf[0]; + } } } } @@ -570,8 +605,12 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height,source,0); - if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) - pax->didstats = 1; + if ( (pax= komodo_paxfind(txid,vout)) != 0 ) + { + if ( didstats != 0 ) + pax->didstats = 1; + pax->type = opretbuf[0]; + } } } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) @@ -619,6 +658,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { + pax->type = opretbuf[0]; pax->approved = kmdheights[i]; if ( didstats != 0 ) pax->didstats = 1; @@ -643,7 +683,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0 ) + if ( srcvalues[i] != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0 ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { @@ -657,8 +697,12 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( tokomodo == 0 ) komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } - if ( didstats != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) - pax->didstats = 1; + if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) + { + pax->type = opretbuf[0]; + if ( didstats != 0 ) + pax->didstats = 1; + } } } else printf("opreturn none issued?\n"); } else printf("opreturn matches KMD? %s\n",(char *)&opretbuf[opretlen-4]); @@ -687,8 +731,12 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); - if ( didstats != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) - pax->didstats = 1; + if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) + { + pax->type = opretbuf[0]; + if ( didstats != 0 ) + pax->didstats = 1; + } } } else printf("komodo_issued_opreturn returned %d\n",n); } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 402d6a859..f3ef90172 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -59,7 +59,7 @@ struct pax_transaction uint64_t komodoshis,fiatoshis,validated; int32_t marked,height,otherheight,approved,didstats; uint16_t vout; - char symbol[16],source[16],coinaddr[64]; uint8_t rmd160[20],shortflag; + char symbol[16],source[16],coinaddr[64]; uint8_t rmd160[20],type; }; struct knotary_entry { UT_hash_handle hh; uint8_t pubkey[33],notaryid; }; From 0a8db1a89e17d017d214270fe85913e73fb2ea00 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 14:13:52 -0300 Subject: [PATCH 306/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c00558719..b39c11c66 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -278,7 +278,7 @@ uint64_t komodo_paxtotal() memcpy(pax->rmd160,pax2->rmd160,20); if ( (basesp= komodo_stateptrget(pax->source)) != 0 ) { - basep->issued += pax->fiatoshis; + basesp->issued += pax->fiatoshis; pax->didstats = 1; printf("found match for %s %.8f\n",pax->symbol,dstr(pax->fiatoshis)); } else printf("paxtotal cant find.(%s)\n",pax->source); From 610030d012204de1d56a14aea2602777aa25b3df Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 14:19:25 -0300 Subject: [PATCH 307/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b39c11c66..2dbec9001 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -683,7 +683,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - if ( srcvalues[i] != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0 ) + if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { From 34f0c3a4d94fac620965ea1867cffd94ecaa962d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 14:47:37 -0300 Subject: [PATCH 308/549] test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2dbec9001..7ca78591e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -267,6 +267,7 @@ uint64_t komodo_paxtotal() { if ( pax->didstats == 0 && pax->type == 'I' ) { + printf("pax.%p didstats.0 type.%c\n",pax,pax->type); HASH_ITER(hh,PAX,pax2,tmp2) { if ( pax != pax2 && pax->txid == pax2->txid ) From ecc5c3598a5c7ae940b7c3912f3484da6cef5f66 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 14:59:14 -0300 Subject: [PATCH 309/549] test --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7ca78591e..f51b2f5e7 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -272,6 +272,7 @@ uint64_t komodo_paxtotal() { if ( pax != pax2 && pax->txid == pax2->txid ) { + printf("matched txid\n"); if ( pax2->fiatoshis != 0 ) { pax->fiatoshis = pax2->fiatoshis; @@ -283,7 +284,7 @@ uint64_t komodo_paxtotal() pax->didstats = 1; printf("found match for %s %.8f\n",pax->symbol,dstr(pax->fiatoshis)); } else printf("paxtotal cant find.(%s)\n",pax->source); - } + } else printf("null fiatoshis\n"); } } } From 36bb53ce26cb9da3f3ab30d31d653bb2c6883fca Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:02:05 -0300 Subject: [PATCH 310/549] test --- src/komodo_gateway.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f51b2f5e7..0e7b455c4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -258,7 +258,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t uint64_t komodo_paxtotal() { - struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[16],dest[16]; int32_t ht; int64_t checktoshis; uint64_t seed,total = 0; struct komodo_state *basesp; + struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[16],dest[16]; int32_t i,ht; int64_t checktoshis; uint64_t seed,total = 0; struct komodo_state *basesp; if ( komodo_isrealtime(&ht) == 0 ) return(0); else @@ -267,9 +267,14 @@ uint64_t komodo_paxtotal() { if ( pax->didstats == 0 && pax->type == 'I' ) { - printf("pax.%p didstats.0 type.%c\n",pax,pax->type); + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&pax->txid)[i]); + printf(" pax.%p didstats.0 type.%c\n",pax,pax->type); HASH_ITER(hh,PAX,pax2,tmp2) { + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&pax2->txid)[i]); + printf(" pax2.%p\n",pax2); if ( pax != pax2 && pax->txid == pax2->txid ) { printf("matched txid\n"); From e69107f81df7d161dbaad53477b9abaf5600a715 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:13:06 -0300 Subject: [PATCH 311/549] test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0e7b455c4..a206fb8f4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -269,8 +269,8 @@ uint64_t komodo_paxtotal() { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); - printf(" pax.%p didstats.0 type.%c\n",pax,pax->type); - HASH_ITER(hh,PAX,pax2,tmp2) + printf(" pax.%p didstats.0 type.%c (%s) k.%d %.8f h.%d %.8f\n",pax,pax->type,pax->symbol,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); + /*HASH_ITER(hh,PAX,pax2,tmp2) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax2->txid)[i]); @@ -291,7 +291,7 @@ uint64_t komodo_paxtotal() } else printf("paxtotal cant find.(%s)\n",pax->source); } else printf("null fiatoshis\n"); } - } + }*/ } } } @@ -552,7 +552,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); didstats = 0; - if ( komodo_paxcmp(value,checktoshis,seed) == 0 )//value >= checktoshis-(checktoshis >> 8) ) + if ( komodo_paxcmp(value,checktoshis,seed) == 0 ) { if ( (pax= komodo_paxfind(txid,vout)) == 0 ) { From 16e7ab0f88f4d4ceeacd858b65010357ee32a523 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:16:47 -0300 Subject: [PATCH 312/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a206fb8f4..31eb68645 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -265,7 +265,7 @@ uint64_t komodo_paxtotal() { HASH_ITER(hh,PAX,pax,tmp) { - if ( pax->didstats == 0 && pax->type == 'I' ) + //if ( pax->didstats == 0 && pax->type == 'I' ) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); From a73709a30b8865bc8b77329d3926c2af831cbe5b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:27:00 -0300 Subject: [PATCH 313/549] test --- src/komodo_gateway.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 31eb68645..dd5f8fa6b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -258,7 +258,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t uint64_t komodo_paxtotal() { - struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[16],dest[16]; int32_t i,ht; int64_t checktoshis; uint64_t seed,total = 0; struct komodo_state *basesp; + struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[16],dest[16],*str; int32_t i,ht; int64_t checktoshis; uint64_t seed,total = 0; struct komodo_state *basesp; if ( komodo_isrealtime(&ht) == 0 ) return(0); else @@ -269,7 +269,10 @@ uint64_t komodo_paxtotal() { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); - printf(" pax.%p didstats.0 type.%c (%s) k.%d %.8f h.%d %.8f\n",pax,pax->type,pax->symbol,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); + if ( pax->type == 'X' || pax->type == 'A' ) + str = pax->symbol; + else str = pax->source; + printf(" pax.%p didstats.0 type.%c (%s) k.%d %.8f h.%d %.8f\n",pax,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); /*HASH_ITER(hh,PAX,pax2,tmp2) { for (i=0; i<32; i++) @@ -567,7 +570,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } } - else + if ( (pax= komodo_paxfind(txid,vout)) != 0 ) { pax->type = opretbuf[0]; if ( pax->didstats == 0 ) From 069953a4fd9d722126845bae808297ea75f2ff73 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:30:23 -0300 Subject: [PATCH 314/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index dd5f8fa6b..bfa984d19 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -565,7 +565,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } - if ( tokomodo == 0 && strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) + if ( strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) //tokomodo == 0 && { komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } From 645ecdd51eb9bc9c01c0fc8354622f5eb2b43c0e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:33:04 -0300 Subject: [PATCH 315/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index bfa984d19..646f082b5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -565,7 +565,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } - if ( strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) //tokomodo == 0 && + //if ( strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) //tokomodo == 0 && { komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } @@ -704,7 +704,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { - if ( tokomodo == 0 ) + //if ( tokomodo == 0 ) komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) From ceabe3dffb23bcaf537ef88daa1aab3bd6cc08a4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:36:43 -0300 Subject: [PATCH 316/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 646f082b5..35f8368f5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -269,7 +269,7 @@ uint64_t komodo_paxtotal() { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); - if ( pax->type == 'X' || pax->type == 'A' ) + if ( pax->type == 'X' || pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) str = pax->symbol; else str = pax->source; printf(" pax.%p didstats.0 type.%c (%s) k.%d %.8f h.%d %.8f\n",pax,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); From 3f2d5618b6038e7018cfd65bfd7decba43c54ff9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:41:38 -0300 Subject: [PATCH 317/549] test --- src/komodo_gateway.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 35f8368f5..a41bca553 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -705,11 +705,13 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { //if ( tokomodo == 0 ) + printf("I: %s\n",CURRENCIES[baseids[i]]); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->type = opretbuf[0]; + strcpy(pax->source,(char *)&opretbuf[opretlen-4]); if ( didstats != 0 ) pax->didstats = 1; } From fa81b5ae2aee17b28b132a9503f54459ec374f1a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:59:03 -0300 Subject: [PATCH 318/549] test --- src/komodo_gateway.h | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a41bca553..33ef81089 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -272,29 +272,20 @@ uint64_t komodo_paxtotal() if ( pax->type == 'X' || pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) str = pax->symbol; else str = pax->source; - printf(" pax.%p didstats.0 type.%c (%s) k.%d %.8f h.%d %.8f\n",pax,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); - /*HASH_ITER(hh,PAX,pax2,tmp2) + if ( pax->didstats == 0 && pax->fiatoshis != 0 ) { - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&pax2->txid)[i]); - printf(" pax2.%p\n",pax2); - if ( pax != pax2 && pax->txid == pax2->txid ) + if ( pax->type == 'I' ) { - printf("matched txid\n"); - if ( pax2->fiatoshis != 0 ) - { - pax->fiatoshis = pax2->fiatoshis; - pax->komodoshis = pax2->komodoshis; - memcpy(pax->rmd160,pax2->rmd160,20); - if ( (basesp= komodo_stateptrget(pax->source)) != 0 ) - { - basesp->issued += pax->fiatoshis; - pax->didstats = 1; - printf("found match for %s %.8f\n",pax->symbol,dstr(pax->fiatoshis)); - } else printf("paxtotal cant find.(%s)\n",pax->source); - } else printf("null fiatoshis\n"); + basesp->issued += pax->fiatoshis; + pax->didstats = 1; } - }*/ + else if ( pax->type == 'X' ) + { + basesp->redeemed += pax->fiatoshis; + pax->didstats = 1; + } + } + printf(" didstats.0 type.%c (%s) k.%d %.8f h.%d %.8f\n",pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); } } } @@ -705,7 +696,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { //if ( tokomodo == 0 ) - printf("I: %s\n",CURRENCIES[baseids[i]]); + //printf("I: %s\n",CURRENCIES[baseids[i]]); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) From c5f534f4449b4e0a4e4463ddec7b4fe74c901b5e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:05:55 -0300 Subject: [PATCH 319/549] test --- src/komodo_gateway.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 33ef81089..1663496ba 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -272,20 +272,23 @@ uint64_t komodo_paxtotal() if ( pax->type == 'X' || pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) str = pax->symbol; else str = pax->source; - if ( pax->didstats == 0 && pax->fiatoshis != 0 ) + if ( komodo_baseid(str) >= 0 && pax->didstats == 0 && pax->fiatoshis != 0 ) { - if ( pax->type == 'I' ) + if ( (basesp= komodo_stateptrget(str)) != 0 ) { - basesp->issued += pax->fiatoshis; - pax->didstats = 1; - } - else if ( pax->type == 'X' ) - { - basesp->redeemed += pax->fiatoshis; - pax->didstats = 1; + if ( pax->type == 'I' ) + { + basesp->issued += pax->fiatoshis; + pax->didstats = 1; + } + else if ( pax->type == 'X' ) + { + basesp->redeemed += pax->fiatoshis; + pax->didstats = 1; + } } } - printf(" didstats.0 type.%c (%s) k.%d %.8f h.%d %.8f\n",pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); + printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); } } } From 042e3b9fc445b5577118df8ec8a79caaa4f4f969 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:15:41 -0300 Subject: [PATCH 320/549] test --- src/komodo_gateway.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1663496ba..df27805fa 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -111,6 +111,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { + pax->didstats = 1; basesp->approved += fiatoshis; printf("########### %p approved %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } @@ -121,6 +122,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (basesp= komodo_stateptrget(source)) != 0 ) { + pax->didstats = 1; basesp->withdrawn += fiatoshis; printf("########### %p withdrawn %s += %.8f\n",basesp,source,dstr(fiatoshis)); } @@ -129,12 +131,12 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { + pax->didstats = 1; basesp->deposited += fiatoshis; printf("########### %p deposited %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } } } - pax->didstats = 1; } if ( pax->marked == 0 ) { @@ -267,8 +269,8 @@ uint64_t komodo_paxtotal() { //if ( pax->didstats == 0 && pax->type == 'I' ) { - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&pax->txid)[i]); + //for (i=0; i<32; i++) + // printf("%02x",((uint8_t *)&pax->txid)[i]); if ( pax->type == 'X' || pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) str = pax->symbol; else str = pax->source; @@ -287,8 +289,8 @@ uint64_t komodo_paxtotal() pax->didstats = 1; } } + printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } - printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); } } } @@ -598,7 +600,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 0; if ( komodo_paxcmp(komodoshis,checktoshis,seed) == 0 ) //checktoshis <= komodoshis+(komodoshis >> 10) ) { - if ( (pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0 ) + if ( value != 0 & ((pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0) ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { @@ -642,7 +644,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,values[i],CURRENCIES[baseids[i]],srcvalues[i],&rmd160s[i*20],txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); - if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + if ( srcvalues[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->approved += srcvalues[i]; didstats = 1; @@ -650,7 +652,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); } - else if ( pax->didstats == 0 ) + else if ( pax->didstats == 0 && srcvalues[i] != 0 ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { @@ -725,7 +727,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); printf("i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); - if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0 ) + if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { From 4adf625a85e0ac2b37f9b4e49300dc4bd6642796 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:20:53 -0300 Subject: [PATCH 321/549] test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index df27805fa..d24071417 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -289,8 +289,8 @@ uint64_t komodo_paxtotal() pax->didstats = 1; } } - printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } + printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } } } @@ -602,11 +602,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( value != 0 & ((pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0) ) { - if ( (basesp= komodo_stateptrget(base)) != 0 ) + if ( (basesp= komodo_stateptrget(pax->source)) != 0 ) { basesp->withdrawn += value; didstats = 1; - printf("########### %p withdrawn %s += %.8f\n",basesp,base,dstr(value)); + printf("########### %p withdrawn %s += %.8f\n",basesp,pax->source,dstr(value)); } printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } @@ -694,7 +694,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->issued += srcvalues[i]; - printf("########### %p issued %s += %.8f\n",basesp,base,dstr(srcvalues[i])); + printf("########### %p issued %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } didstats = 1; } From 33319f82fac851af3706f056c3a52c9d6573ea73 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:26:18 -0300 Subject: [PATCH 322/549] test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d24071417..32cce25ad 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -120,11 +120,11 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( ASSETCHAINS_SYMBOL[0] == 0 ) { - if ( (basesp= komodo_stateptrget(source)) != 0 ) + if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { pax->didstats = 1; basesp->withdrawn += fiatoshis; - printf("########### %p withdrawn %s += %.8f\n",basesp,source,dstr(fiatoshis)); + printf("########### %p withdrawn %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } } else @@ -602,11 +602,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( value != 0 & ((pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0) ) { - if ( (basesp= komodo_stateptrget(pax->source)) != 0 ) + if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->withdrawn += value; didstats = 1; - printf("########### %p withdrawn %s += %.8f\n",basesp,pax->source,dstr(value)); + printf("########### %p withdrawn %s += %.8f\n",basesp,base,dstr(value)); } printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } From 1113e57b498d6eee15a9d5a55af15a4f5d3c8600 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:30:26 -0300 Subject: [PATCH 323/549] test --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 32cce25ad..ffe3f3faa 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -274,9 +274,10 @@ uint64_t komodo_paxtotal() if ( pax->type == 'X' || pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) str = pax->symbol; else str = pax->source; + basesp = komodo_stateptrget(str); if ( komodo_baseid(str) >= 0 && pax->didstats == 0 && pax->fiatoshis != 0 ) { - if ( (basesp= komodo_stateptrget(str)) != 0 ) + if ( basesp != 0 ) { if ( pax->type == 'I' ) { From 19cba879d39d2171fded109ca2b050ff1262d9f4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:34:00 -0300 Subject: [PATCH 324/549] test --- src/komodo_gateway.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ffe3f3faa..2bdf2fff9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -690,7 +690,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) + /*if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { @@ -698,7 +698,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("########### %p issued %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } didstats = 1; - } + }*/ if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { //if ( tokomodo == 0 ) @@ -727,8 +727,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 continue; didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - printf("i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); - if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) + printf("X i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); + /*if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { @@ -737,7 +737,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("########### %p redeemed %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } didstats = 1; - } + }*/ if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) From 28231c88146430a4703f68fd0972f65544737f10 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:38:53 -0300 Subject: [PATCH 325/549] test --- src/komodo_gateway.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2bdf2fff9..990917d23 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -283,11 +283,13 @@ uint64_t komodo_paxtotal() { basesp->issued += pax->fiatoshis; pax->didstats = 1; + printf("Iset dstats %.8f += %.8f\n",dstr(basesp->issued),dstr(pax->fiatoshis)); } else if ( pax->type == 'X' ) { basesp->redeemed += pax->fiatoshis; pax->didstats = 1; + printf("Xset dstats %.8f += %.8f\n",dstr(basesp->redeemed),dstr(pax->fiatoshis)); } } } @@ -688,7 +690,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%d of %d illegal baseid.%d\n",i,n,baseids[i]); continue; } - didstats = 0; + //didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); /*if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) { @@ -709,8 +711,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { pax->type = opretbuf[0]; strcpy(pax->source,(char *)&opretbuf[opretlen-4]); - if ( didstats != 0 ) - pax->didstats = 1; + //if ( didstats != 0 ) + // pax->didstats = 1; } } } else printf("opreturn none issued?\n"); From d506f4ec6c9fe3547728072081c9788fb2321312 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:53:23 -0300 Subject: [PATCH 326/549] test --- src/komodo_gateway.h | 46 ++++++++++---------------------------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 990917d23..ec597bae6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -111,7 +111,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { - pax->didstats = 1; + //pax->didstats = 1; basesp->approved += fiatoshis; printf("########### %p approved %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } @@ -122,7 +122,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { - pax->didstats = 1; + //pax->didstats = 1; basesp->withdrawn += fiatoshis; printf("########### %p withdrawn %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } @@ -131,7 +131,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { - pax->didstats = 1; + //pax->didstats = 1; basesp->deposited += fiatoshis; printf("########### %p deposited %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } @@ -584,7 +584,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) { - pax->didstats = 1; + //pax->didstats = 1; pax->type = opretbuf[0]; } } @@ -601,9 +601,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 typestr = "withdraw"; printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); didstats = 0; - if ( komodo_paxcmp(komodoshis,checktoshis,seed) == 0 ) //checktoshis <= komodoshis+(komodoshis >> 10) ) + if ( komodo_paxcmp(komodoshis,checktoshis,seed) == 0 ) { - if ( value != 0 & ((pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0) ) + if ( value != 0 && ((pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0) ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { @@ -616,8 +616,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height,source,0); if ( (pax= komodo_paxfind(txid,vout)) != 0 ) { - if ( didstats != 0 ) - pax->didstats = 1; + //if ( didstats != 0 ) + // pax->didstats = 1; pax->type = opretbuf[0]; } } @@ -669,8 +669,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { pax->type = opretbuf[0]; pax->approved = kmdheights[i]; - if ( didstats != 0 ) - pax->didstats = 1; + //if ( didstats != 0 ) + // pax->didstats = 1; printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); } } @@ -690,29 +690,16 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%d of %d illegal baseid.%d\n",i,n,baseids[i]); continue; } - //didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - /*if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) - { - if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) - { - basesp->issued += srcvalues[i]; - printf("########### %p issued %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); - } - didstats = 1; - }*/ if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { //if ( tokomodo == 0 ) - //printf("I: %s\n",CURRENCIES[baseids[i]]); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->type = opretbuf[0]; strcpy(pax->source,(char *)&opretbuf[opretlen-4]); - //if ( didstats != 0 ) - // pax->didstats = 1; } } } else printf("opreturn none issued?\n"); @@ -727,26 +714,13 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( baseids[i] < 0 ) continue; - didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); printf("X i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); - /*if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) - { - if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) - { - basesp->redeemed += srcvalues[i]; - didstats = 1; - printf("########### %p redeemed %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); - } - didstats = 1; - }*/ if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->type = opretbuf[0]; - if ( didstats != 0 ) - pax->didstats = 1; } } } else printf("komodo_issued_opreturn returned %d\n",n); From bad52cb2c441c097aed433891d6077511a88560c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:57:23 -0300 Subject: [PATCH 327/549] test --- src/komodo_gateway.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ec597bae6..4f63e8737 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -131,7 +131,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { - //pax->didstats = 1; + pax->didstats = 1; basesp->deposited += fiatoshis; printf("########### %p deposited %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } @@ -582,9 +582,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) + if ( (pax= komodo_paxfind(txid,vout)) != 0 ) { - //pax->didstats = 1; + if ( didstats != 0 ) + pax->didstats = 1; pax->type = opretbuf[0]; } } From a6ef924b745c296c33a5187e508fa8fbe33a3e59 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:01:54 -0300 Subject: [PATCH 328/549] test --- src/komodo_gateway.h | 43 +++++-------------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4f63e8737..e5fba5d85 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -69,7 +69,7 @@ struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context { - struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp,*basesp; char str[16],dest[16],*s; + struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16],*s; sp = komodo_stateptr(str,dest); pthread_mutex_lock(&komodo_mutex); HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); @@ -105,39 +105,6 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t pax->height = height; if ( otherheight != 0 ) pax->otherheight = otherheight; - if ( pax->didstats == 0 && fiatoshis != 0 ) - { - if ( (pax->approved= approved) != 0 ) - { - if ( (basesp= komodo_stateptrget(symbol)) != 0 ) - { - //pax->didstats = 1; - basesp->approved += fiatoshis; - printf("########### %p approved %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); - } - } - else - { - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { - if ( (basesp= komodo_stateptrget(symbol)) != 0 ) - { - //pax->didstats = 1; - basesp->withdrawn += fiatoshis; - printf("########### %p withdrawn %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); - } - } - else - { - if ( (basesp= komodo_stateptrget(symbol)) != 0 ) - { - pax->didstats = 1; - basesp->deposited += fiatoshis; - printf("########### %p deposited %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); - } - } - } - } if ( pax->marked == 0 ) { if ( addflag != 0 ) @@ -617,8 +584,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height,source,0); if ( (pax= komodo_paxfind(txid,vout)) != 0 ) { - //if ( didstats != 0 ) - // pax->didstats = 1; + if ( didstats != 0 ) + pax->didstats = 1; pax->type = opretbuf[0]; } } @@ -670,8 +637,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { pax->type = opretbuf[0]; pax->approved = kmdheights[i]; - //if ( didstats != 0 ) - // pax->didstats = 1; + if ( didstats != 0 ) + pax->didstats = 1; printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); } } From c6eca1572064248303a37025d4ab451e1f0a1edf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:11:31 -0300 Subject: [PATCH 329/549] test --- src/komodo_gateway.h | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e5fba5d85..a28ebe347 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -252,12 +252,6 @@ uint64_t komodo_paxtotal() pax->didstats = 1; printf("Iset dstats %.8f += %.8f\n",dstr(basesp->issued),dstr(pax->fiatoshis)); } - else if ( pax->type == 'X' ) - { - basesp->redeemed += pax->fiatoshis; - pax->didstats = 1; - printf("Xset dstats %.8f += %.8f\n",dstr(basesp->redeemed),dstr(pax->fiatoshis)); - } } } printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); @@ -528,7 +522,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->deposited += fiatoshis; - didstats = 1; + pax->didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } //if ( strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) //tokomodo == 0 && @@ -544,17 +538,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->deposited += fiatoshis; - didstats = 1; + pax->didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } } } - if ( (pax= komodo_paxfind(txid,vout)) != 0 ) - { - if ( didstats != 0 ) - pax->didstats = 1; - pax->type = opretbuf[0]; - } } } } @@ -659,10 +647,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 continue; } bitcoin_address(coinaddr,60,&rmd160s[i*20],20); + printf("ISSUE %s %.8f %.8f\n",CURRENCIES[baseids[i]],dstr(values[i]),dstr(srcvalues[i])); + komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { - //if ( tokomodo == 0 ) - komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { @@ -684,11 +672,17 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 continue; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); printf("X i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); + komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) - komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); + ; if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->type = opretbuf[0]; + if ( srcvalues[i] != 0 ) + { + pax->redeemed += srcvalues[i]; + pax->didstats = 1; + } } } } else printf("komodo_issued_opreturn returned %d\n",n); From e649b292fbf885241820975a83a821557a37d141 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:12:59 -0300 Subject: [PATCH 330/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a28ebe347..f49ab58aa 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -678,9 +678,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->type = opretbuf[0]; - if ( srcvalues[i] != 0 ) + if ( baseids[i] >= 0 && srcvalues[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { - pax->redeemed += srcvalues[i]; + basesp->redeemed += srcvalues[i]; pax->didstats = 1; } } From 22a31d52aa1a4da4ebdd2bcbb9bdef0c799c5bce Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:15:36 -0300 Subject: [PATCH 331/549] test --- src/komodo_gateway.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f49ab58aa..43653acbc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -522,7 +522,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->deposited += fiatoshis; - pax->didstats = 1; + didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } //if ( strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) //tokomodo == 0 && @@ -533,15 +533,17 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (pax= komodo_paxfind(txid,vout)) != 0 ) { pax->type = opretbuf[0]; - if ( pax->didstats == 0 ) + if ( didstats == 0 && pax->didstats == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->deposited += fiatoshis; - pax->didstats = 1; + didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } } + if ( didstats != 0 ) + pax->didstats = 1; } } } From 14941d4ca6a37ea770059596722887ea7b74f4e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:21:21 -0300 Subject: [PATCH 332/549] test --- src/komodo_gateway.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 43653acbc..e7f7c51cf 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -542,8 +542,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } } - if ( didstats != 0 ) - pax->didstats = 1; + //if ( didstats != 0 ) + // pax->didstats = 1; } } } @@ -574,8 +574,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height,source,0); if ( (pax= komodo_paxfind(txid,vout)) != 0 ) { - if ( didstats != 0 ) - pax->didstats = 1; + //if ( didstats != 0 ) + // pax->didstats = 1; pax->type = opretbuf[0]; } } @@ -627,8 +627,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { pax->type = opretbuf[0]; pax->approved = kmdheights[i]; - if ( didstats != 0 ) - pax->didstats = 1; + //if ( didstats != 0 ) + // pax->didstats = 1; printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); } } @@ -683,7 +683,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( baseids[i] >= 0 && srcvalues[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->redeemed += srcvalues[i]; - pax->didstats = 1; + //pax->didstats = 1; } } } From 51e5d952cdf1333fed3b1daccc1634b8427f1237 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:32:20 -0300 Subject: [PATCH 333/549] test --- src/komodo_gateway.h | 69 ++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e7f7c51cf..f30e90ab5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -34,26 +34,37 @@ int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn, return(-1); } -struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout) +void pax_keyset(uint8_t *buf,uint256 txid,uint16_t vout,uint8_t type) { - struct pax_transaction *pax; + memcpy(buf,&txid,32); + memcpy(&buf[32],&vout,2); + buf[34] = type; +} + +struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) +{ + struct pax_transaction *pax; uint8_t buf[35]; pthread_mutex_lock(&komodo_mutex); - HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); + pax_keyset(buf,txid,vout,type); + HASH_FIND(hh,PAX,buf,sizeof(buf),pax); pthread_mutex_unlock(&komodo_mutex); return(pax); } -struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout,int32_t mark) +struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout,uint8_t type,int32_t mark) { - struct pax_transaction *pax; + struct pax_transaction *pax; uint8_t buf[35]; pthread_mutex_lock(&komodo_mutex); - HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); + pax_keyset(buf,txid,vout,type); + HASH_FIND(hh,PAX,buf,sizeof(buf),pax); if ( pax == 0 ) { pax = (struct pax_transaction *)calloc(1,sizeof(*pax)); pax->txid = txid; pax->vout = vout; - HASH_ADD_KEYPTR(hh,PAX,&pax->txid,sizeof(pax->txid),pax); + pax->type = type; + memcpy(pax->buf,buf,sizeof(pax->buf)); + HASH_ADD_KEYPTR(hh,PAX,pax->buf,sizeof(pax->buf),pax); //printf("ht.%d create pax.%p mark.%d\n",height,pax,mark); } if ( pax != 0 ) @@ -67,18 +78,21 @@ struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout return(pax); } -void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context +void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,uint8_t type,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context { - struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16],*s; + struct pax_transaction *pax; uint8_t buf[35]; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16],*s; sp = komodo_stateptr(str,dest); pthread_mutex_lock(&komodo_mutex); - HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); + pax_keyset(buf,txid,vout,type); + HASH_FIND(hh,PAX,buf,sizeof(buf),pax); if ( pax == 0 ) { pax = (struct pax_transaction *)calloc(1,sizeof(*pax)); pax->txid = txid; pax->vout = vout; - HASH_ADD_KEYPTR(hh,PAX,&pax->txid,sizeof(pax->txid),pax); + pax->type = type; + memcpy(pax->buf,buf,sizeof(pax->buf)); + HASH_ADD_KEYPTR(hh,PAX,pax->buf,sizeof(pax->buf),pax); addflag = 1; if ( ASSETCHAINS_SYMBOL[0] == 0 ) { @@ -527,12 +541,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } //if ( strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) //tokomodo == 0 && { - komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); + komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); } } - if ( (pax= komodo_paxfind(txid,vout)) != 0 ) + if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) { - pax->type = opretbuf[0]; if ( didstats == 0 && pax->didstats == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) @@ -542,8 +555,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } } - //if ( didstats != 0 ) - // pax->didstats = 1; + if ( didstats != 0 ) + pax->didstats = 1; } } } @@ -561,7 +574,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 0; if ( komodo_paxcmp(komodoshis,checktoshis,seed) == 0 ) { - if ( value != 0 && ((pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0) ) + if ( value != 0 && ((pax= komodo_paxfind(txid,vout,'W')) == 0 || pax->didstats == 0) ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { @@ -571,8 +584,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } - komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height,source,0); - if ( (pax= komodo_paxfind(txid,vout)) != 0 ) + komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,'W',kmdheight,height,source,0); + if ( (pax= komodo_paxfind(txid,vout,'W')) != 0 ) { //if ( didstats != 0 ) // pax->didstats = 1; @@ -601,10 +614,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 for (j=0; j<32; j++) printf("%02x",((uint8_t *)&txids[i])[j]); printf(" v%d %.8f k.%d ht.%d base.%d\n",vouts[i],dstr(values[i]),kmdheights[i],otherheights[i],baseids[i]); - if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i],'A')) == 0 ) { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - komodo_gateway_deposit(coinaddr,values[i],CURRENCIES[baseids[i]],srcvalues[i],&rmd160s[i*20],txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); + komodo_gateway_deposit(coinaddr,values[i],CURRENCIES[baseids[i]],srcvalues[i],&rmd160s[i*20],txids[i],vouts[i],'A',kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); if ( srcvalues[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->approved += srcvalues[i]; @@ -623,7 +636,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); - if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i],'A')) != 0 ) { pax->type = opretbuf[0]; pax->approved = kmdheights[i]; @@ -650,11 +663,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } bitcoin_address(coinaddr,60,&rmd160s[i*20],20); printf("ISSUE %s %.8f %.8f\n",CURRENCIES[baseids[i]],dstr(values[i]),dstr(srcvalues[i])); - komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); - if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) + komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'I',height,0,CURRENCIES[baseids[i]],0); + if ( komodo_paxmark(height,txids[i],vouts[i],'I',height) == 0 ) { } - if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i],'I')) != 0 ) { pax->type = opretbuf[0]; strcpy(pax->source,(char *)&opretbuf[opretlen-4]); @@ -674,10 +687,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 continue; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); printf("X i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); - komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); - if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) + komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'X',height,0,(char *)"KMD",0); + if ( komodo_paxmark(height,txids[i],vouts[i],'X',height) == 0 ) ; - if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i],'X')) != 0 ) { pax->type = opretbuf[0]; if ( baseids[i] >= 0 && srcvalues[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) From c5c0e52706ffa466a4027e6728ef0ec098383b14 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:38:08 -0300 Subject: [PATCH 334/549] test --- src/komodo_gateway.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f30e90ab5..d8be42f38 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -51,6 +51,15 @@ struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) return(pax); } +struct pax_transaction *komodo_paxfinds(uint256 txid,uint16_t vout) +{ + uint8_t types[] = { 'D', 'I', 'W', 'A', 'X' }; + for (i=0; ikomodoshis : pax->fiatoshis; srcvalues[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? pax->fiatoshis : pax->komodoshis; From b915be35e6147c5ea4397a29c2612277608d92e3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:42:47 -0300 Subject: [PATCH 335/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d8be42f38..ea51fcd56 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -442,7 +442,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { for (i=1; itype = opcode; if ( ((opcode == 'I' && pax->fiatoshis == block.vtx[0].vout[i].nValue) || (opcode == 'X' && pax->komodoshis == block.vtx[0].vout[i].nValue)) ) @@ -540,7 +540,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 0; if ( komodo_paxcmp(value,checktoshis,seed) == 0 ) { - if ( (pax= komodo_paxfind(txid,vout)) == 0 ) + if ( (pax= komodo_paxfind(txid,vout,'D')) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { From afa0d2b9ca5986f5fb3379d62aea5264b1eb8f8c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:44:01 -0300 Subject: [PATCH 336/549] test --- src/komodo_structs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_structs.h b/src/komodo_structs.h index f3ef90172..bbca9c25f 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -59,7 +59,7 @@ struct pax_transaction uint64_t komodoshis,fiatoshis,validated; int32_t marked,height,otherheight,approved,didstats; uint16_t vout; - char symbol[16],source[16],coinaddr[64]; uint8_t rmd160[20],type; + char symbol[16],source[16],coinaddr[64]; uint8_t rmd160[20],type,buf[35]; }; struct knotary_entry { UT_hash_handle hh; uint8_t pubkey[33],notaryid; }; From 095dce5832967937d83fc5f28dfe6e286c335732 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:44:56 -0300 Subject: [PATCH 337/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ea51fcd56..510d99188 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -54,7 +54,7 @@ struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) struct pax_transaction *komodo_paxfinds(uint256 txid,uint16_t vout) { uint8_t types[] = { 'D', 'I', 'W', 'A', 'X' }; - for (i=0; i Date: Sat, 26 Nov 2016 17:45:37 -0300 Subject: [PATCH 338/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 510d99188..f0878477e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -53,7 +53,7 @@ struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) struct pax_transaction *komodo_paxfinds(uint256 txid,uint16_t vout) { - uint8_t types[] = { 'D', 'I', 'W', 'A', 'X' }; + struct pax_transaction *pax; uint8_t types[] = { 'D', 'I', 'W', 'A', 'X' }; for (i=0; i Date: Sat, 26 Nov 2016 17:46:21 -0300 Subject: [PATCH 339/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f0878477e..3881de127 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -53,7 +53,7 @@ struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) struct pax_transaction *komodo_paxfinds(uint256 txid,uint16_t vout) { - struct pax_transaction *pax; uint8_t types[] = { 'D', 'I', 'W', 'A', 'X' }; + struct pax_transaction *pax; int32_t i; uint8_t types[] = { 'D', 'I', 'W', 'A', 'X' }; for (i=0; i Date: Sat, 26 Nov 2016 17:51:41 -0300 Subject: [PATCH 340/549] test --- src/komodo_gateway.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3881de127..604a98c91 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -596,8 +596,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,'W',kmdheight,height,source,0); if ( (pax= komodo_paxfind(txid,vout,'W')) != 0 ) { - //if ( didstats != 0 ) - // pax->didstats = 1; + if ( didstats != 0 ) + pax->didstats = 1; pax->type = opretbuf[0]; } } @@ -649,8 +649,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { pax->type = opretbuf[0]; pax->approved = kmdheights[i]; - //if ( didstats != 0 ) - // pax->didstats = 1; + if ( didstats != 0 ) + pax->didstats = 1; printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); } } @@ -705,7 +705,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( baseids[i] >= 0 && srcvalues[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->redeemed += srcvalues[i]; - //pax->didstats = 1; + pax->didstats = 1; } } } From 929b383db3bff241865043ee00af7edd2b136449 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:09:58 -0300 Subject: [PATCH 341/549] test --- src/komodo_gateway.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 604a98c91..9d90b6160 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -265,16 +265,15 @@ uint64_t komodo_paxtotal() str = pax->symbol; else str = pax->source; basesp = komodo_stateptrget(str); - if ( komodo_baseid(str) >= 0 && pax->didstats == 0 && pax->fiatoshis != 0 ) + if ( basesp != 0 && pax->didstats == 0 && pax->type == 'I' ) { - if ( basesp != 0 ) + if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'D')) != 0 && pax2->fiatoshis != 0 ) { - if ( pax->type == 'I' ) - { - basesp->issued += pax->fiatoshis; - pax->didstats = 1; - printf("Iset dstats %.8f += %.8f\n",dstr(basesp->issued),dstr(pax->fiatoshis)); - } + pax->komodoshis = pax2->komodoshis; + pax->fiatoshis = pax2->fiatoshis; + basesp->issued += pax->fiatoshis; + pax->didstats = 1; + printf("Iset dstats %.8f += %.8f\n",dstr(basesp->issued),dstr(pax->fiatoshis)); } } printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); From b69651118afaff9337beaeeb2255b4d5886e6216 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:16:26 -0300 Subject: [PATCH 342/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9d90b6160..5c1745b7a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -261,7 +261,7 @@ uint64_t komodo_paxtotal() { //for (i=0; i<32; i++) // printf("%02x",((uint8_t *)&pax->txid)[i]); - if ( pax->type == 'X' || pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) + if ( pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) str = pax->symbol; else str = pax->source; basesp = komodo_stateptrget(str); @@ -273,7 +273,7 @@ uint64_t komodo_paxtotal() pax->fiatoshis = pax2->fiatoshis; basesp->issued += pax->fiatoshis; pax->didstats = 1; - printf("Iset dstats %.8f += %.8f\n",dstr(basesp->issued),dstr(pax->fiatoshis)); + printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); } } printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); From f7183b2bee796849c09ee30682ec19446ece638d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:19:41 -0300 Subject: [PATCH 343/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5c1745b7a..c96750fce 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -261,7 +261,7 @@ uint64_t komodo_paxtotal() { //for (i=0; i<32; i++) // printf("%02x",((uint8_t *)&pax->txid)[i]); - if ( pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) + if ( pax->type == 'A' || pax->type == 'D' ) str = pax->symbol; else str = pax->source; basesp = komodo_stateptrget(str); From 7572a37183da042eb66eba07714ac22940517bd0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:27:34 -0300 Subject: [PATCH 344/549] test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c96750fce..196b5cc51 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -261,7 +261,7 @@ uint64_t komodo_paxtotal() { //for (i=0; i<32; i++) // printf("%02x",((uint8_t *)&pax->txid)[i]); - if ( pax->type == 'A' || pax->type == 'D' ) + if ( pax->type == 'A' || pax->type == 'D' || pax->type == 'X' ) str = pax->symbol; else str = pax->source; basesp = komodo_stateptrget(str); @@ -275,8 +275,8 @@ uint64_t komodo_paxtotal() pax->didstats = 1; printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); } + printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } - printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } } } @@ -694,7 +694,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( baseids[i] < 0 ) continue; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - printf("X i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); + printf("%s X i.%d of %d: %.8f -> %s\n",CURRENCIES[baseids[i]],i,n,dstr(values[i]),coinaddr); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'X',height,0,(char *)"KMD",0); if ( komodo_paxmark(height,txids[i],vouts[i],'X',height) == 0 ) ; From ab689bb647b880fbee6759305ddd301561379fbd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:35:07 -0300 Subject: [PATCH 345/549] test --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 196b5cc51..b60f9a9b2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -275,7 +275,8 @@ uint64_t komodo_paxtotal() pax->didstats = 1; printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); } - printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); + if ( strcmp(str,"HRK") == 0 ) + printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } } } From 161abb4b10547be320444572c6212a7fd947b73c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:43:39 -0300 Subject: [PATCH 346/549] test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b60f9a9b2..97c381f78 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -134,7 +134,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (pax->approved= approved) != 0 ) s = (char *)"APPROVED"; - else s = (char *)((ASSETCHAINS_SYMBOL[0] == 0) ? "WITHDRAW" : "DEPOSIT"); + else s = (char *)((strcmp(pax->symbol,"KMD") == 0) ? "WITHDRAW" : "DEPOSIT"); printf("[%s] addflag.%d ADD %s/%s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,source,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); } } @@ -275,10 +275,10 @@ uint64_t komodo_paxtotal() pax->didstats = 1; printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); } - if ( strcmp(str,"HRK") == 0 ) - printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } } + if ( strcmp(str,"HRK") == 0 ) + printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } } komodo_stateptr(symbol,dest); From 8577908727ff8c82f133026222cc597672c6cf9a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:49:44 -0300 Subject: [PATCH 347/549] test --- src/komodo_gateway.h | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 97c381f78..5fb14682d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -257,28 +257,27 @@ uint64_t komodo_paxtotal() { HASH_ITER(hh,PAX,pax,tmp) { - //if ( pax->didstats == 0 && pax->type == 'I' ) + if ( pax->type == 'A' || pax->type == 'D' || pax->type == 'X' ) + str = pax->symbol; + else str = pax->source; + basesp = komodo_stateptrget(str); + if ( basesp != 0 && pax->didstats == 0 && pax->type == 'I' ) { - //for (i=0; i<32; i++) - // printf("%02x",((uint8_t *)&pax->txid)[i]); - if ( pax->type == 'A' || pax->type == 'D' || pax->type == 'X' ) - str = pax->symbol; - else str = pax->source; - basesp = komodo_stateptrget(str); - if ( basesp != 0 && pax->didstats == 0 && pax->type == 'I' ) + if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'D')) != 0 && pax2->fiatoshis != 0 ) { - if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'D')) != 0 && pax2->fiatoshis != 0 ) - { - pax->komodoshis = pax2->komodoshis; - pax->fiatoshis = pax2->fiatoshis; - basesp->issued += pax->fiatoshis; - pax->didstats = 1; - printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); - } + pax->komodoshis = pax2->komodoshis; + pax->fiatoshis = pax2->fiatoshis; + basesp->issued += pax->fiatoshis; + pax->didstats = 1; + printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); } } - if ( strcmp(str,"HRK") == 0 ) + if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) + { + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&pax->txid)[i]); printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); + } } } komodo_stateptr(symbol,dest); From b9dec008d7875f9d510aad5d08baafb2d9d5132d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:58:40 -0300 Subject: [PATCH 348/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5fb14682d..8d97c6068 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -272,7 +272,7 @@ uint64_t komodo_paxtotal() printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); } } - if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) + if ( pax->type == 'D' || strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); From 3cfd48376de175e6cb4337f90871ef3647d2cbef Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 19:06:41 -0300 Subject: [PATCH 349/549] test --- src/komodo_gateway.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8d97c6068..1609ada83 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -263,16 +263,20 @@ uint64_t komodo_paxtotal() basesp = komodo_stateptrget(str); if ( basesp != 0 && pax->didstats == 0 && pax->type == 'I' ) { - if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'D')) != 0 && pax2->fiatoshis != 0 ) + if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'D')) != 0 ) { - pax->komodoshis = pax2->komodoshis; - pax->fiatoshis = pax2->fiatoshis; - basesp->issued += pax->fiatoshis; - pax->didstats = 1; - printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); + printf("%.8f pax2.%p vs pax.%p\n",dstr(pax2->fiatoshis),pax2,pax); + if ( pax2->fiatoshis != 0 ) + { + pax->komodoshis = pax2->komodoshis; + pax->fiatoshis = pax2->fiatoshis; + basesp->issued += pax->fiatoshis; + pax->didstats = 1; + printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); + } } } - if ( pax->type == 'D' || strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) + if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); From ea0bce0fd6d6d28d7f86536fb9bafd5205372c23 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 19:09:56 -0300 Subject: [PATCH 350/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1609ada83..ab9d6e31b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -736,7 +736,7 @@ void komodo_passport_iteration() sp = 0; isrealtime = 0; base = (char *)CURRENCIES[baseid]; -if ( strcmp("EUR",base) != 0 && baseid < 32 ) +if ( strcmp("HRK",base) != 0 && baseid < 32 ) continue; if ( baseid+1 != refid ) { From ff80d273017cab2db9dbe937a212004c5b8c1010 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 19:13:08 -0300 Subject: [PATCH 351/549] test --- src/komodo_gateway.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ab9d6e31b..3b418b1c4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -736,8 +736,6 @@ void komodo_passport_iteration() sp = 0; isrealtime = 0; base = (char *)CURRENCIES[baseid]; -if ( strcmp("HRK",base) != 0 && baseid < 32 ) - continue; if ( baseid+1 != refid ) { komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"komodostate"); From 9a6744f2440744159fcc5ec2292554dacae51076 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 19:35:06 -0300 Subject: [PATCH 352/549] test --- src/komodo_gateway.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3b418b1c4..37c76be40 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -685,8 +685,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 strcpy(pax->source,(char *)&opretbuf[opretlen-4]); } } - } else printf("opreturn none issued?\n"); - } else printf("opreturn matches KMD? %s\n",(char *)&opretbuf[opretlen-4]); + } //else printf("opreturn none issued?\n"); + } //else printf("opreturn matches KMD? %s\n",(char *)&opretbuf[opretlen-4]); } else if ( opretbuf[0] == 'X' ) { @@ -740,18 +740,19 @@ void komodo_passport_iteration() { komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"komodostate"); komodo_nameset(symbol,dest,base); - //port = komodo_port(base,10,&magic) + 1; if ( (fp= fopen(fname,"rb")) != 0 && (sp= komodo_stateptrget(symbol)) != 0 ) { fseek(fp,0,SEEK_END); if ( ftell(fp) > lastpos[baseid] ) { - //printf("passport refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); + if ( strcmp(symbol,"KMD") == 0 ) + printf("passport refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); fseek(fp,lastpos[baseid],SEEK_SET); while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) ; lastpos[baseid] = ftell(fp); - //printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); + if ( strcmp(symbol,"KMD") == 0 ) + printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); } From c3152c23d952f5b62f6a535f14d7f746e6b2a559 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 19:42:22 -0300 Subject: [PATCH 353/549] test --- src/komodo_gateway.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 37c76be40..328069bf2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -196,7 +196,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t printf("%02x",opretbuf[i]); printf(" opretlen.%d (%s)\n",opretlen,base); //printf(" opretlen.%d vs %d incr.%d\n",opretlen,(int32_t)(2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4),incr); - if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) + //if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) { type = opretbuf[0]; opretbuf++, opretlen--; @@ -210,8 +210,8 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t { txids[n] = p.txid; vouts[n] = p.vout; - values[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? p.komodoshis : p.fiatoshis; - srcvalues[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? p.fiatoshis : p.komodoshis; + values[n] = (strcmp("KMD",base) == 0) ? p.komodoshis : p.fiatoshis; + srcvalues[n] = (strcmp("KMD",base) == 0) ? p.fiatoshis : p.komodoshis; kmdheights[n] = p.height; otherheights[n] = p.otherheight; memcpy(&rmd160s[n * 20],p.rmd160,20); @@ -235,8 +235,8 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t baseids[n] = komodo_baseid(base); if ( (pax= komodo_paxfinds(txids[n],vouts[n])) != 0 ) { - values[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? pax->komodoshis : pax->fiatoshis; - srcvalues[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? pax->fiatoshis : pax->komodoshis; + values[n] = (strcmp("KMD",base) == 0) ? pax->komodoshis : pax->fiatoshis; + srcvalues[n] = (strcmp("KMD",base) == 0) ? pax->fiatoshis : pax->komodoshis; kmdheights[n] = pax->height; otherheights[n] = pax->otherheight; memcpy(&rmd160s[n * 20],pax->rmd160,20); From 4d4194d3acad88c48c0b8586489134c689389b13 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 19:57:52 -0300 Subject: [PATCH 354/549] test --- src/komodo_gateway.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 328069bf2..6b061146c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -135,7 +135,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( (pax->approved= approved) != 0 ) s = (char *)"APPROVED"; else s = (char *)((strcmp(pax->symbol,"KMD") == 0) ? "WITHDRAW" : "DEPOSIT"); - printf("[%s] addflag.%d ADD %s/%s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,source,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); + printf("[%s] addflag.%d ADD %s/%s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,source,dstr(strcmp(pax->symbol,"KMD")==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); } } //else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height,otherheight); @@ -520,7 +520,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 memset(rmd160s,0,sizeof(rmd160s)); memset(kmdheights,0,sizeof(kmdheights)); memset(otherheights,0,sizeof(otherheights)); - tokomodo = (komodo_is_issuer() == 0); + tokomodo = (komodo_baseid(source) >= 0 && komodo_baseid(source) != 32); //(komodo_is_issuer() == 0); if ( opretbuf[0] == 'D' ) { if ( opretlen == 38 ) // any KMD tx @@ -551,10 +551,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } - //if ( strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) //tokomodo == 0 && - { - komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); - } + komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); } if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) { From 5b1fa6614534cb1b688ee5da981303ef70118d82 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:05:25 -0300 Subject: [PATCH 355/549] test --- src/komodo_gateway.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6b061146c..b9d2c7191 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -276,7 +276,7 @@ uint64_t komodo_paxtotal() } } } - if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) + //if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); @@ -671,7 +671,6 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 continue; } bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - printf("ISSUE %s %.8f %.8f\n",CURRENCIES[baseids[i]],dstr(values[i]),dstr(srcvalues[i])); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'I',height,0,CURRENCIES[baseids[i]],0); if ( komodo_paxmark(height,txids[i],vouts[i],'I',height) == 0 ) { @@ -687,7 +686,6 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( opretbuf[0] == 'X' ) { - printf("got X opreturn height.%d\n",height); if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) { for (i=0; i %s\n",CURRENCIES[baseids[i]],i,n,dstr(values[i]),coinaddr); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'X',height,0,(char *)"KMD",0); if ( komodo_paxmark(height,txids[i],vouts[i],'X',height) == 0 ) ; @@ -742,13 +739,13 @@ void komodo_passport_iteration() fseek(fp,0,SEEK_END); if ( ftell(fp) > lastpos[baseid] ) { - if ( strcmp(symbol,"KMD") == 0 ) + if ( 0 && strcmp(symbol,"KMD") == 0 ) printf("passport refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); fseek(fp,lastpos[baseid],SEEK_SET); while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) ; lastpos[baseid] = ftell(fp); - if ( strcmp(symbol,"KMD") == 0 ) + if ( 0 && strcmp(symbol,"KMD") == 0 ) printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); From 4508aa2f00209fe39e5d76e64d4cdb1d9672277f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:08:24 -0300 Subject: [PATCH 356/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b9d2c7191..87f4af839 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -27,7 +27,7 @@ int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; - //printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); + printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); return(0); } else printf("pax_fiatstatus cant get basesp.%s\n",base); } else printf("pax_fiatstatus illegal base.%s\n",base); From 959782f9b1c81a7016d4057057f733cc1285dea0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:15:04 -0300 Subject: [PATCH 357/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 87f4af839..560101ddc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -725,7 +725,7 @@ void komodo_passport_iteration() refid = 33; else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); - for (baseid=0; baseid<=32; baseid++) + for (baseid=32; baseid>=0; baseid--) { sp = 0; isrealtime = 0; From 79ba59762dd4faa61f2868dfc4c7e7e20dc7645a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:18:25 -0300 Subject: [PATCH 358/549] test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 560101ddc..1cdf7c2bb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -276,7 +276,7 @@ uint64_t komodo_paxtotal() } } } - //if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) + if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); @@ -739,13 +739,13 @@ void komodo_passport_iteration() fseek(fp,0,SEEK_END); if ( ftell(fp) > lastpos[baseid] ) { - if ( 0 && strcmp(symbol,"KMD") == 0 ) + if ( lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) printf("passport refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); fseek(fp,lastpos[baseid],SEEK_SET); while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) ; lastpos[baseid] = ftell(fp); - if ( 0 && strcmp(symbol,"KMD") == 0 ) + if ( lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); From 1d19bf5dded6024db3b84b839248ea324d3c836c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:26:28 -0300 Subject: [PATCH 359/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1cdf7c2bb..44c15101b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -498,8 +498,8 @@ int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) int32_t ratio; if ( seed == 0 ) { - ratio = ((value << 10) / checkvalue); - if ( ratio >= 1023 && ratio <= 1025 ) + ratio = ((value << 8) / checkvalue); + if ( ratio >= 255 && ratio <= 257 ) return(0); else { From bc2b6b691a563c10a893df4073409b28750b77d2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:35:56 -0300 Subject: [PATCH 360/549] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 44c15101b..1ee234451 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -498,8 +498,8 @@ int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) int32_t ratio; if ( seed == 0 ) { - ratio = ((value << 8) / checkvalue); - if ( ratio >= 255 && ratio <= 257 ) + ratio = ((value << 6) / checkvalue); + if ( ratio >= 63 && ratio <= 65 ) return(0); else { From 3fe781e1318fc346358362d9650c100ef2161537 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:48:46 -0300 Subject: [PATCH 361/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 939e60371..84d188432 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -637,7 +637,7 @@ void static BitcoinMiner(CWallet *pwallet) solutionTargetChecks.increment(); if ( UintToArith256(pblock->GetHash()) > hashTarget ) { - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"missed target\n"); return false; } From dcdcccaad51a90892ccc2827a3f893acb4e5c09b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:50:15 -0300 Subject: [PATCH 362/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 84d188432..e01161ed0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -637,7 +637,7 @@ void static BitcoinMiner(CWallet *pwallet) solutionTargetChecks.increment(); if ( UintToArith256(pblock->GetHash()) > hashTarget ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"missed target\n"); return false; } From b3183e3e195628c641ecfd27b3b6d2d1806166ef Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:59:21 -0300 Subject: [PATCH 363/549] test --- src/komodo_gateway.h | 14 +++++++------- src/miner.cpp | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1ee234451..ffbe81bf7 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -192,9 +192,9 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; - for (i=0; itxid,pax->vout,'D')) != 0 ) { - printf("%.8f pax2.%p vs pax.%p\n",dstr(pax2->fiatoshis),pax2,pax); if ( pax2->fiatoshis != 0 ) { pax->komodoshis = pax2->komodoshis; @@ -276,12 +275,12 @@ uint64_t komodo_paxtotal() } } } - if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) + /*if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); - } + }*/ } } komodo_stateptr(symbol,dest); @@ -480,8 +479,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } if ( matched != num ) { + printf("WOULD REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); // can easily happen depending on order of loading - if ( height > 100000 && opcode == 'X' ) + if ( height > 100000 ) //&& opcode == 'X' ) { printf("REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); return(-1); diff --git a/src/miner.cpp b/src/miner.cpp index e01161ed0..2879561c4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -637,7 +637,7 @@ void static BitcoinMiner(CWallet *pwallet) solutionTargetChecks.increment(); if ( UintToArith256(pblock->GetHash()) > hashTarget ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"missed target\n"); return false; } @@ -648,8 +648,8 @@ void static BitcoinMiner(CWallet *pwallet) if ( nseconds > 0 ) sleep(nseconds); MilliSleep((rand() % 5000) + 1); - KOMODO_CHOSEN_ONE = 1; } + KOMODO_CHOSEN_ONE = 1; // Found a solution SetThreadPriority(THREAD_PRIORITY_NORMAL); LogPrintf("KomodoMiner:\n"); From eeac75281d49b3fb663f0526d32e846e08116b68 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 21:05:42 -0300 Subject: [PATCH 364/549] test --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ffbe81bf7..fc7d8d38d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -363,7 +363,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to continue; if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 ) continue; - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); txNew->vout.resize(numvouts+1); txNew->vout[numvouts].nValue = (opcode == 'I') ? pax->fiatoshis : pax->komodoshis; @@ -789,6 +789,7 @@ void komodo_passport_iteration() if ( sp != 0 && isrealtime == 0 ) refsp->RTbufs[0][2] = 0; } + komodo_paxtotal(); refsp->RTmask = RTmask; KOMODO_PASSPORT_INITDONE = 1; } From d683083dd38c60d5198ac6add972105e6dccd884 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 21:09:55 -0300 Subject: [PATCH 365/549] test --- src/komodo_gateway.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index fc7d8d38d..065e04ff1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -452,29 +452,29 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( pax->marked != 0 && height >= 80820 ) errs++; else matched++; - if ( opcode == 'X' ) - printf("errs.%d i.%d match %.8f == %.8f pax.%p\n",errs,i,dstr(pax != 0 ? pax->komodoshis:-1),dstr(block.vtx[0].vout[i].nValue),pax); + //if ( opcode == 'X' ) + printf("%c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); } else { - if ( opcode == 'X' ) + //if ( opcode == 'X' ) { for (j=0; j<32; j++) printf("%02x",((uint8_t *)&txids[i-1])[j]); - printf(" cant paxfind X txid\n"); + printf(" cant paxfind %c txid\n".opcode); } } } else { - if ( opcode == 'X' ) + //if ( opcode == 'X' ) { hash = block.GetHash(); for (j=0; j<32; j++) printf("%02x",((uint8_t *)&hash)[j]); printf(" ht.%d blockhash X couldnt find vout.[%d]\n",height,i); - } else if ( opcode == 'I' ) - matched++; + } //else if ( opcode == 'I' ) + // matched++; } } if ( matched != num ) From f37822dc9fad13d66427f0c8450951de6661312f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 21:10:44 -0300 Subject: [PATCH 366/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 065e04ff1..23a23b110 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -461,7 +461,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { for (j=0; j<32; j++) printf("%02x",((uint8_t *)&txids[i-1])[j]); - printf(" cant paxfind %c txid\n".opcode); + printf(" cant paxfind %c txid\n",opcode); } } } From 916a36c93e3fdfed1df3930fa7781d29fac0eb74 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 21:12:39 -0300 Subject: [PATCH 367/549] test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 23a23b110..eadc2780b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -462,6 +462,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above for (j=0; j<32; j++) printf("%02x",((uint8_t *)&txids[i-1])[j]); printf(" cant paxfind %c txid\n",opcode); + printf("%c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); } } } From 784c01124964058bd61cbe3feb2d1f3af14a56e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 21:15:26 -0300 Subject: [PATCH 368/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index eadc2780b..682067e71 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -447,7 +447,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) { pax->type = opcode; - if ( ((opcode == 'I' && pax->fiatoshis == block.vtx[0].vout[i].nValue) || (opcode == 'X' && pax->komodoshis == block.vtx[0].vout[i].nValue)) ) + if ( ((opcode == 'I' && (pax->fiatoshis == 0 || pax->fiatoshis == block.vtx[0].vout[i].nValue)) || (opcode == 'X' && (pax->komodoshis == 0 || pax->komodoshis == block.vtx[0].vout[i].nValue))) ) { if ( pax->marked != 0 && height >= 80820 ) errs++; From c3111e7be4103ff8cad0aa2f3edcd183fd0d6eda Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 21:18:54 -0300 Subject: [PATCH 369/549] test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 682067e71..254d88815 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -272,6 +272,7 @@ uint64_t komodo_paxtotal() basesp->issued += pax->fiatoshis; pax->didstats = 1; printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); + pax2->marked = pax->height; } } } From f4fd24268931215bd55416b44a8f626b62eaff1b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 06:43:50 -0300 Subject: [PATCH 370/549] dns seeds --- src/chainparams.cpp | 1 + src/komodo.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 991cc1333..34b042749 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -95,6 +95,7 @@ public: assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b")); vFixedSeeds.clear(); vSeeds.clear(); + vSeeds.push_back(CDNSSeedData("komodo.mewhub.com", "seeds.komodo.mewhub.com")); // @kolo // TODO: set up bootstrapping for mainnet base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,60); base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,85); diff --git a/src/komodo.h b/src/komodo.h index 970ef50b9..b0b64b16d 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -17,7 +17,7 @@ #define H_KOMODO_H // Todo: -// 1. net balance limiter +// 1. net balance limiter, wait for notarized // 2. verify: reorgs // non komodod (non-hardfork) todo: From aa114a60954bd5d7b4ee6221d27b891867804256 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 09:34:23 -0300 Subject: [PATCH 371/549] test --- src/komodo.h | 9 +++++---- src/komodo_gateway.h | 35 +++++++++++++++++++++++++---------- src/komodo_pax.h | 3 ++- src/komodo_structs.h | 4 ++-- src/komodo_utils.h | 11 +++++++++++ src/miner.cpp | 2 +- src/rpcblockchain.cpp | 5 +++-- src/wallet/rpcwallet.cpp | 3 +++ 8 files changed, 52 insertions(+), 20 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index b0b64b16d..d9c45fa9c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -17,13 +17,14 @@ #define H_KOMODO_H // Todo: -// 1. net balance limiter, wait for notarized -// 2. verify: reorgs +// verify: reorgs // non komodod (non-hardfork) todo: // a. automate notarization fee payouts // b. automated distribution of test REVS snapshot +#define KOMODO_ASSETCHAINS_WAITNOTARIZE + #include #include #include @@ -512,7 +513,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvalid = bitweight(signedmask); if ( height == 79633 ) notarized = 1; - if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries>>1)) ) + if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries/3)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); notarized = 1; @@ -563,7 +564,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } } - if ( ((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1) ) + if ( ((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries/3) ) { memset(&txhash,0,sizeof(txhash)); komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 254d88815..e15460837 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -15,9 +15,10 @@ // paxdeposit equivalent in reverse makes opreturn and KMD does the same in reverse -int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base) +int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base) { - int32_t baseid; struct komodo_state *sp; + int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed; + *available = *deposited = *issued = *withdrawn = *approved = *redeemed = 0; if ( (baseid= komodo_baseid(base)) >= 0 ) { if ( (sp= komodo_stateptrget(base)) != 0 ) @@ -27,7 +28,11 @@ int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; - printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); + netliability = (sp->deposited - sp->withdrawn) - sp->shorted; + maxallowed = komodo_maxallowed(baseid); + if ( netliability < maxallowed ) + *available = (maxallowed - netliability); + //printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); return(0); } else printf("pax_fiatstatus cant get basesp.%s\n",base); } else printf("pax_fiatstatus illegal base.%s\n",base); @@ -360,9 +365,17 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to HASH_ITER(hh,PAX,pax,tmp) { //printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); - if ( strcmp(symbol,"KMD") == 0 && (pax->approved == 0 || pax->validated == 0) ) + if ( strcmp(symbol,"KMD") == 0 && pax->approved == 0 ) continue; - if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 ) + else if ( strcmp(symbol,"KMD") != 0 ) + { +#ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE + struct komodo_state *kmdsp = komodo_stateptrget("KMD"); + if ( kmdsp != 0 && kmdsp->notarized_height >= pax->height ) // assumes same chain as notarize + pax->validated = kmdsp->notarized_height; +#endif + } + if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 ) continue; if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); @@ -629,6 +642,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,values[i],CURRENCIES[baseids[i]],srcvalues[i],&rmd160s[i*20],txids[i],vouts[i],'A',kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); + komodo_paxmark(height,txids[i],vouts[i],'W',height); + komodo_paxmark(height,txids[i],vouts[i],'A',height); if ( srcvalues[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->approved += srcvalues[i]; @@ -674,9 +689,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'I',height,0,CURRENCIES[baseids[i]],0); - if ( komodo_paxmark(height,txids[i],vouts[i],'I',height) == 0 ) - { - } + komodo_paxmark(height,txids[i],vouts[i],'D',height); + komodo_paxmark(height,txids[i],vouts[i],'I',height); if ( (pax= komodo_paxfind(txids[i],vouts[i],'I')) != 0 ) { pax->type = opretbuf[0]; @@ -696,8 +710,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 continue; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'X',height,0,(char *)"KMD",0); - if ( komodo_paxmark(height,txids[i],vouts[i],'X',height) == 0 ) - ; + komodo_paxmark(height,txids[i],vouts[i],'W',height); + komodo_paxmark(height,txids[i],vouts[i],'A',height); + komodo_paxmark(height,txids[i],vouts[i],'X',height); if ( (pax= komodo_paxfind(txids[i],vouts[i],'X')) != 0 ) { pax->type = opretbuf[0]; diff --git a/src/komodo_pax.h b/src/komodo_pax.h index c415c2bbe..2bcab56de 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -309,7 +309,8 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba { if ( relid == MAX_CURRENCIES ) { - kmdbtc = pvals[MAX_CURRENCIES]; + if ( (kmdbtc= pvals[MAX_CURRENCIES]) < 25000 ) + kmdbtc = 25000; btcusd = pvals[MAX_CURRENCIES + 1]; if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { diff --git a/src/komodo_structs.h b/src/komodo_structs.h index bbca9c25f..b62a76d3c 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -23,7 +23,7 @@ #endif*/ #define GENESIS_NBITS 0x1f00ffff -#define KOMODO_MINRATIFY ((height < 90000) ? 7 : 13) +#define KOMODO_MINRATIFY ((height < 90000) ? 7 : 11) #define KOMODO_MAXBLOCKS 5000000 #define KOMODO_EVENT_RATIFY 'P' @@ -71,7 +71,7 @@ struct komodo_state uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID; int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT; uint32_t SAVEDTIMESTAMP; - uint64_t deposited,issued,withdrawn,approved,redeemed; + uint64_t deposited,issued,withdrawn,approved,redeemed,shorted; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS; struct komodo_event **Komodo_events; int32_t Komodo_numevents; uint32_t RTbufs[64][3]; uint64_t RTmask; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 5602292a5..98cccdf0c 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -785,6 +785,17 @@ char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", "CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", "KMD" }; +uint64_t komodo_maxallowed(int32_t baseid) +{ + uint64_t mult,val = (uint64_t)10000 * COIN; + if ( baseid < 0 || baseid >= 32 ) + return(0); + if ( baseid < 10 ) + val *= 10; + mult = MINDENOMS[baseid] / MIND; + return(mult * val); +} + int32_t komodo_baseid(char *origbase) { int32_t i; char base[64]; diff --git a/src/miner.cpp b/src/miner.cpp index 2879561c4..6201e21dd 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -99,7 +99,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, } #define ASSETCHAINS_MINHEIGHT 100 -#define ROUNDROBIN_DELAY 60 +#define ROUNDROBIN_DELAY 59 extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 4b1102005..f5140de1b 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -481,12 +481,12 @@ Value notaries(const Array& params, bool fHelp) } int32_t komodo_pending_withdraws(char *opretstr); -int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); +int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); extern char CURRENCIES[][8]; Value paxpending(const Array& params, bool fHelp) { - Object ret; Array a; char opretbuf[10000*2]; int32_t opretlen,baseid; uint64_t deposited,issued,withdrawn,approved,redeemed; + Object ret; Array a; char opretbuf[10000*2]; int32_t opretlen,baseid; uint64_t available,deposited,issued,withdrawn,approved,redeemed; if ( fHelp || params.size() != 0 ) throw runtime_error("paxpending needs no args\n"); LOCK(cs_main); @@ -500,6 +500,7 @@ Value paxpending(const Array& params, bool fHelp) { if ( deposited != 0 || issued != 0 || withdrawn != 0 || approved != 0 || redeemed != 0 ) { + item.push_back(Pair("available", ValueFromAmount(available))); item.push_back(Pair("deposited", ValueFromAmount(deposited))); item.push_back(Pair("issued", ValueFromAmount(issued))); item.push_back(Pair("withdrawn", ValueFromAmount(withdrawn))); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b96b0a48a..261d52959 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -482,6 +482,7 @@ extern char ASSETCHAINS_SYMBOL[16]; int32_t komodo_is_issuer(); int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); int32_t komodo_isrealtime(int32_t *kmdheightp); +int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); Value paxdeposit(const Array& params, bool fHelp) { @@ -501,6 +502,8 @@ Value paxdeposit(const Array& params, bool fHelp) std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; + if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,CURRENCIES[baseid]) != 0 || available < fiatoshis ) + throw runtime_error("paxdeposit no available inventory"); komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO777_KMDADDR); From 5334d5ad70b312c7a163d91fed253b6f7a9e9651 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 09:36:51 -0300 Subject: [PATCH 372/549] test --- src/komodo_gateway.h | 6 +++--- src/komodo_pax.h | 11 +++++++++++ src/komodo_utils.h | 11 ----------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e15460837..b386f2393 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -370,9 +370,9 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to else if ( strcmp(symbol,"KMD") != 0 ) { #ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE - struct komodo_state *kmdsp = komodo_stateptrget("KMD"); - if ( kmdsp != 0 && kmdsp->notarized_height >= pax->height ) // assumes same chain as notarize - pax->validated = kmdsp->notarized_height; + struct komodo_state *kmdsp = komodo_stateptrget((char *)"KMD"); + if ( kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height ) // assumes same chain as notarize + pax->validated = kmdsp->NOTARIZED_HEIGHT; #endif } if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 ) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 2bcab56de..d9236b7b5 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -94,6 +94,17 @@ uint64_t peggy_smooth_coeffs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)] = // numpri 1, 1, 1, 1, 1, 1, 0, 0, // isum 100000000000 }; +uint64_t komodo_maxallowed(int32_t baseid) +{ + uint64_t mult,val = (uint64_t)10000 * COIN; + if ( baseid < 0 || baseid >= 32 ) + return(0); + if ( baseid < 10 ) + val *= 10; + mult = MINDENOMS[baseid] / MIND; + return(mult * val); +} + uint64_t komodo_paxvol(uint64_t volume,uint64_t price) { if ( volume < 10000000000 ) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 98cccdf0c..5602292a5 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -785,17 +785,6 @@ char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", "CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", "KMD" }; -uint64_t komodo_maxallowed(int32_t baseid) -{ - uint64_t mult,val = (uint64_t)10000 * COIN; - if ( baseid < 0 || baseid >= 32 ) - return(0); - if ( baseid < 10 ) - val *= 10; - mult = MINDENOMS[baseid] / MIND; - return(mult * val); -} - int32_t komodo_baseid(char *origbase) { int32_t i; char base[64]; From 1c05f0b501013f5c53363372d8b3e56ac835b587 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 09:45:54 -0300 Subject: [PATCH 373/549] test --- src/komodo_gateway.h | 38 ++++++++++++++++++++------------------ src/komodo_pax.h | 2 +- src/wallet/rpcwallet.cpp | 4 ++-- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b386f2393..f2fd7e3af 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -352,7 +352,7 @@ int32_t komodo_pending_withdraws(char *opretstr) int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t tokomodo) { - struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[16384],data[16384]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t mask; + struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[16384],data[16384]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t available,deposited,issued,withdrawn,approved,redeemed,mask; sp = komodo_stateptr(symbol,dest); strcpy(symbol,base); PENDING_KOMODO_TX = 0; @@ -375,6 +375,11 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to pax->validated = kmdsp->NOTARIZED_HEIGHT; #endif } + if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis ) + { + printf("miner: skip %s %.8f when avail %.8f\n",symbol,dstr(pax->fiatoshis),dstr(available)); + continue; + } if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 ) continue; if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) @@ -427,7 +432,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { - int32_t i,j,n,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; + int32_t i,j,n,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); memset(srcvalues,0,sizeof(srcvalues)); @@ -461,35 +466,32 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) { pax->type = opcode; + if ( opcode == 'I' && pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis ) + { + printf("checkdeposit: skip %s %.8f when avail %.8f\n",pax->symbol,dstr(pax->fiatoshis),dstr(available)); + continue; + } if ( ((opcode == 'I' && (pax->fiatoshis == 0 || pax->fiatoshis == block.vtx[0].vout[i].nValue)) || (opcode == 'X' && (pax->komodoshis == 0 || pax->komodoshis == block.vtx[0].vout[i].nValue))) ) { if ( pax->marked != 0 && height >= 80820 ) errs++; else matched++; - //if ( opcode == 'X' ) printf("%c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); } else { - //if ( opcode == 'X' ) - { - for (j=0; j<32; j++) - printf("%02x",((uint8_t *)&txids[i-1])[j]); - printf(" cant paxfind %c txid\n",opcode); - printf("%c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); - } + for (j=0; j<32; j++) + printf("%02x",((uint8_t *)&txids[i-1])[j]); + printf(" cant paxfind %c txid\n",opcode); + printf("%c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); } } else { - //if ( opcode == 'X' ) - { - hash = block.GetHash(); - for (j=0; j<32; j++) - printf("%02x",((uint8_t *)&hash)[j]); - printf(" ht.%d blockhash X couldnt find vout.[%d]\n",height,i); - } //else if ( opcode == 'I' ) - // matched++; + hash = block.GetHash(); + for (j=0; j<32; j++) + printf("%02x",((uint8_t *)&hash)[j]); + printf(" ht.%d blockhash X couldnt find vout.[%d]\n",height,i); } } if ( matched != num ) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index d9236b7b5..a8a8727de 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -96,7 +96,7 @@ uint64_t peggy_smooth_coeffs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)] = // numpri uint64_t komodo_maxallowed(int32_t baseid) { - uint64_t mult,val = (uint64_t)10000 * COIN; + uint64_t mult,val = COIN; // * (uint64_t)10000; if ( baseid < 0 || baseid >= 32 ) return(0); if ( baseid < 10 ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 261d52959..87fc11a35 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -486,7 +486,7 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued, Value paxdeposit(const Array& params, bool fHelp) { - uint64_t seed,komodoshis = 0; int32_t height; char destaddr[64]; uint8_t i,pubkey37[33]; + uint64_t available,deposited,issued,withdrawn,approved,redeemed,seed,komodoshis = 0; int32_t height; char destaddr[64]; uint8_t i,pubkey37[33]; bool fSubtractFeeFromAmount = false; if ( komodo_is_issuer() != 0 ) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "paxdeposit only from KMD"); @@ -502,7 +502,7 @@ Value paxdeposit(const Array& params, bool fHelp) std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; - if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,CURRENCIES[baseid]) != 0 || available < fiatoshis ) + if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) throw runtime_error("paxdeposit no available inventory"); komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); From 51ee9373f1bb4e8543f98ab3a711e63299a713ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 09:47:38 -0300 Subject: [PATCH 374/549] test --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f5140de1b..b87eaf942 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -496,7 +496,7 @@ Value paxpending(const Array& params, bool fHelp) for (baseid=0; baseid<32; baseid++) { Object item,obj; - if ( pax_fiatstatus(&deposited,&issued,&withdrawn,&approved,&redeemed,CURRENCIES[baseid]) == 0 ) + if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,CURRENCIES[baseid]) == 0 ) { if ( deposited != 0 || issued != 0 || withdrawn != 0 || approved != 0 || redeemed != 0 ) { From bff51d678814c2cbd47a741b8da3a03fd7d233f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 10:02:45 -0300 Subject: [PATCH 375/549] test --- src/komodo_gateway.h | 70 ++++++++++++++++++++++------------------ src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f2fd7e3af..9a3a76647 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -108,7 +108,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t memcpy(pax->buf,buf,sizeof(pax->buf)); HASH_ADD_KEYPTR(hh,PAX,pax->buf,sizeof(pax->buf),pax); addflag = 1; - if ( ASSETCHAINS_SYMBOL[0] == 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] == 0 ) { int32_t i; for (i=0; i<32; i++) printf("%02x",((uint8_t *)&txid)[i]); @@ -135,7 +135,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t pax->otherheight = otherheight; if ( pax->marked == 0 ) { - if ( addflag != 0 ) + if ( 0 && addflag != 0 ) { if ( (pax->approved= approved) != 0 ) s = (char *)"APPROVED"; @@ -148,7 +148,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t else { pax->marked = height; - printf("pax.%p MARK DEPOSIT ht.%d other.%d\n",pax,height,otherheight); + //printf("pax.%p MARK DEPOSIT ht.%d other.%d\n",pax,height,otherheight); } } @@ -166,11 +166,11 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio { for (i=0; i<32; i++) ((uint8_t *)&pax->txid)[i] = opretbuf[len++]; - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&pax->txid)[31-i]); + //for (i=0; i<32; i++) + // printf("%02x",((uint8_t *)&pax->txid)[31-i]); pax->vout = opretbuf[len++]; pax->vout += ((uint32_t)opretbuf[len++] << 8); - printf(" txid v.%d\n",pax->vout); + //printf(" txid v.%d\n",pax->vout); } len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->komodoshis),&pax->komodoshis); len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->fiatoshis),&pax->fiatoshis); @@ -221,6 +221,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t otherheights[n] = p.otherheight; memcpy(&rmd160s[n * 20],p.rmd160,20); baseids[n] = komodo_baseid(p.source); + if ( 0 ) { char coinaddr[64]; bitcoin_address(coinaddr,60,&rmd160s[n * 20],20); @@ -276,7 +277,7 @@ uint64_t komodo_paxtotal() pax->fiatoshis = pax2->fiatoshis; basesp->issued += pax->fiatoshis; pax->didstats = 1; - printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); + //printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); pax2->marked = pax->height; } } @@ -340,13 +341,13 @@ int32_t komodo_pending_withdraws(char *opretstr) if ( len == 0 ) opretbuf[len++] = 'A'; len += komodo_rwapproval(1,&opretbuf[len],pax); - printf("%s.(marked.%u approved.%d) %p\n",pax->source,pax->marked,pax->approved,pax); + //printf("%s.(marked.%u approved.%d) %p\n",pax->source,pax->marked,pax->approved,pax); } } if ( len > 0 ) init_hexbytes_noT(opretstr,opretbuf,len); else opretstr[0] = 0; - printf("komodo_pending_withdraws len.%d PAXTOTAL %.8f\n",len,dstr(komodo_paxtotal())); + fprintf(stderr,"komodo_pending_withdraws len.%d PAXTOTAL %.8f\n",len,dstr(komodo_paxtotal())); return(len); } @@ -406,7 +407,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to { len += komodo_rwapproval(1,&data[len],pax); PENDING_KOMODO_TX += pax->komodoshis; - printf(" vout.%u DEPOSIT %.8f <- pax.%s pending %.8f | ",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX)); + //printf(" vout.%u DEPOSIT %.8f <- pax.%s pending %.8f | ",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX)); } if ( numvouts++ >= 64 ) break; @@ -548,15 +549,15 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,addrtype,rmd160,20); checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,fiatoshis); typestr = "deposit"; - printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); + //printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); if ( kmdheight <= height ) { - for (i=0; i<32; i++) + /*for (i=0; i<32; i++) printf("%02x",((uint8_t *)&txid)[i]); printf(" <- txid.v%u ",vout); for (i=0; i<33; i++) printf("%02x",pubkey33[i]); - printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); + printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height);*/ didstats = 0; if ( komodo_paxcmp(value,checktoshis,seed) == 0 ) { @@ -566,7 +567,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); + if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); } @@ -578,7 +580,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); + if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } } if ( didstats != 0 ) @@ -596,7 +599,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,addrtype,rmd160,20); checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value); typestr = "withdraw"; - printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); + //printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); didstats = 0; if ( komodo_paxcmp(komodoshis,checktoshis,seed) == 0 ) { @@ -606,9 +609,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->withdrawn += value; didstats = 1; - printf("########### %p withdrawn %s += %.8f\n",basesp,base,dstr(value)); + if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p withdrawn %s += %.8f\n",basesp,base,dstr(value)); } - printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); + //printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,'W',kmdheight,height,source,0); if ( (pax= komodo_paxfind(txid,vout,'W')) != 0 ) @@ -621,7 +625,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) { for (i=0; i KMD %.8f vs %.8f\n",kmdheights[i],CURRENCIES[baseids[i]],(double)srcvalues[i]/COIN,(double)values[i]/COIN,(double)checktoshis/COIN); + /*printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",kmdheights[i],CURRENCIES[baseids[i]],(double)srcvalues[i]/COIN,(double)values[i]/COIN,(double)checktoshis/COIN); for (j=0; j<32; j++) printf("%02x",((uint8_t *)&txids[i])[j]); - printf(" v%d %.8f k.%d ht.%d base.%d\n",vouts[i],dstr(values[i]),kmdheights[i],otherheights[i],baseids[i]); + printf(" v%d %.8f k.%d ht.%d base.%d\n",vouts[i],dstr(values[i]),kmdheights[i],otherheights[i],baseids[i]);*/ if ( (pax= komodo_paxfind(txids[i],vouts[i],'A')) == 0 ) { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); @@ -650,9 +654,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->approved += srcvalues[i]; didstats = 1; - printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); + if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } - printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); + //printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); } else if ( pax->didstats == 0 && srcvalues[i] != 0 ) { @@ -660,21 +665,22 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->approved += srcvalues[i]; didstats = 1; - printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); + if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } - } - else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); + } //else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); if ( (pax= komodo_paxfind(txids[i],vouts[i],'A')) != 0 ) { pax->type = opretbuf[0]; pax->approved = kmdheights[i]; if ( didstats != 0 ) pax->didstats = 1; - printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); + if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); } } } - printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal())); + //printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal())); } else if ( opretbuf[0] == 'I' ) { @@ -722,6 +728,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->redeemed += srcvalues[i]; pax->didstats = 1; + if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p redeemed %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } } } @@ -758,13 +766,13 @@ void komodo_passport_iteration() fseek(fp,0,SEEK_END); if ( ftell(fp) > lastpos[baseid] ) { - if ( lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) + if ( 0 && lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) printf("passport refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); fseek(fp,lastpos[baseid],SEEK_SET); while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) ; lastpos[baseid] = ftell(fp); - if ( lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) + if ( 0 && lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); @@ -783,7 +791,7 @@ void komodo_passport_iteration() } //else fprintf(stderr,"%s not RT\n",base); } //else fprintf(stderr,"%s size error RT\n",base); fclose(fp); - } else fprintf(stderr,"%s open error RT\n",base); + } //else fprintf(stderr,"%s open error RT\n",base); } else { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 87fc11a35..61b287512 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -503,7 +503,7 @@ Value paxdeposit(const Array& params, bool fHelp) std::string dest; height = chainActive.Tip()->nHeight; if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) - throw runtime_error("paxdeposit no available inventory"); + throw runtime_error("paxdeposit not enough available inventory"); komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO777_KMDADDR); From dff4ef45760fc23e814c9aeb443796011f92d835 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 10:10:06 -0300 Subject: [PATCH 376/549] test --- src/komodo.h | 2 +- src/komodo_gateway.h | 4 ++-- src/komodo_pax.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index d9c45fa9c..75e682c8b 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -164,7 +164,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char int32_t i; for (i=0; i ratio.%d\n",(long long)value,(long long)checkvalue,ratio); + printf("ignore mismatched value %lld vs checkvalue %lld -> ratio.%d\n",(long long)value,(long long)checkvalue,ratio); return(-1); } } @@ -733,7 +733,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - } else printf("komodo_issued_opreturn returned %d\n",n); + } //else printf("komodo_issued_opreturn returned %d\n",n); } return(typestr); } diff --git a/src/komodo_pax.h b/src/komodo_pax.h index a8a8727de..d50583470 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -96,11 +96,11 @@ uint64_t peggy_smooth_coeffs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)] = // numpri uint64_t komodo_maxallowed(int32_t baseid) { - uint64_t mult,val = COIN; // * (uint64_t)10000; + uint64_t mult,val = COIN * (uint64_t)10000; if ( baseid < 0 || baseid >= 32 ) return(0); if ( baseid < 10 ) - val *= 10; + val *= 4; mult = MINDENOMS[baseid] / MIND; return(mult * val); } From 73585700ff081923ccb5aa29d05310aaf890faa5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 10:14:18 -0300 Subject: [PATCH 377/549] test --- src/komodo_bitcoind.h | 2 +- src/komodo_gateway.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index db1ea8319..5e3e228ea 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -366,7 +366,7 @@ uint256 komodo_getblockhash(int32_t height) } free_json(result); } - printf("KMD hash.%d (%s) %x\n",height,jsonstr,*(uint32_t *)&hash); + //printf("KMD hash.%d (%s) %x\n",height,jsonstr,*(uint32_t *)&hash); free(jsonstr); } return(hash); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 854dec9d9..c539b63ce 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -475,9 +475,10 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( ((opcode == 'I' && (pax->fiatoshis == 0 || pax->fiatoshis == block.vtx[0].vout[i].nValue)) || (opcode == 'X' && (pax->komodoshis == 0 || pax->komodoshis == block.vtx[0].vout[i].nValue))) ) { if ( pax->marked != 0 && height >= 80820 ) + { + printf("%c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); errs++; - else matched++; - printf("%c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); + } else matched++; } else { From 83b0138266d82147bf2192f8528edab136444abd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 10:18:00 -0300 Subject: [PATCH 378/549] test --- src/komodo_notary.h | 2 +- src/miner.cpp | 4 ++-- src/wallet/db.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index cbfca6563..6cf292ccc 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -108,7 +108,7 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) memcpy(kp->pubkey,pubkeys[k],33); kp->notaryid = k; HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); - if ( height > 10000 ) + if ( 0 && height > 10000 ) { for (i=0; i<33; i++) printf("%02x",pubkeys[k][i]); diff --git a/src/miner.cpp b/src/miner.cpp index 6201e21dd..2567539f3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -534,7 +534,7 @@ void static BitcoinMiner(CWallet *pwallet) else solver = "default"; assert(solver == "tromp" || solver == "default"); LogPrint("pow", "Using Equihash solver \"%s\" with n = %u, k = %u\n", solver, n, k); - fprintf(stderr,"Mining with %s\n",solver.c_str()); + //fprintf(stderr,"Mining with %s\n",solver.c_str()); std::mutex m_cs; bool cancelSolver = false; boost::signals2::connection c = uiInterface.NotifyBlockTip.connect( @@ -584,7 +584,7 @@ void static BitcoinMiner(CWallet *pwallet) Mining_height = pindexPrev->nHeight+1; Mining_start = (uint32_t)time(NULL); } - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height); unique_ptr pblocktemplate(CreateNewBlockWithKey(reservekey)); diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index b103f0ce7..766e2afda 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -83,7 +83,7 @@ bool CDBEnv::Open(const boost::filesystem::path& pathIn) TryCreateDirectory(pathLogDir); boost::filesystem::path pathErrorFile = pathIn / "db.log"; LogPrintf("CDBEnv::Open: LogDir=%s ErrorFile=%s pathIn.(%s)\n", pathLogDir.string(), pathErrorFile.string(),pathIn.string()); - fprintf(stderr,"strPath.(%s)\n",strPath.c_str()); + //fprintf(stderr,"strPath.(%s)\n",strPath.c_str()); unsigned int nEnvFlags = 0; if (GetBoolArg("-privdb", true)) From 3f8696e5768a12edf54b6dbb69359fa094e4dc0f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 10:25:02 -0300 Subject: [PATCH 379/549] test --- src/komodo_events.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index e38708918..0d77b0148 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -52,7 +52,7 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig void komodo_eventadd_pubkeys(struct komodo_state *sp,char *symbol,int32_t height,uint8_t num,uint8_t pubkeys[64][33]) { struct komodo_event_pubkeys P; - printf("eventadd pubkeys ht.%d\n",height); + //printf("eventadd pubkeys ht.%d\n",height); memset(&P,0,sizeof(P)); P.num = num; memcpy(P.pubkeys,pubkeys,33 * num); From 295e677f203d3a3f64d9fc8a9a5c9f6dc355745c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:10:13 -0300 Subject: [PATCH 380/549] test --- src/komodo_pax.h | 155 +++++++++++++++++++++++++++-------------------- 1 file changed, 89 insertions(+), 66 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index d50583470..eb84f0231 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -308,9 +308,67 @@ void komodo_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals) } } -uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t basevolume) +uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed,uint64_t basevolume) { - uint32_t pvalb,pvalr,kmdbtc,btcusd; uint64_t usdvol,baseusd,usdkmd,baserel,ranked[32]; + int32_t i,j,k,ind,zeroes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0; + for (sum=i=zeroes=nonz=0; i (numvotes >> 1) ) + break; + } + } + } + } + if ( wt > (numvotes >> 1) ) + { + ind = i; + for (densum=sum=j=0; j 10000*COIN ) { printf("paxcalc overflow %.8f\n",dstr(basevolume)); @@ -320,16 +378,19 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba { if ( relid == MAX_CURRENCIES ) { - if ( (kmdbtc= pvals[MAX_CURRENCIES]) < 25000 ) + if ( kmdbtc == 0 ) + kmdbtc = pvals[MAX_CURRENCIES]; + if ( btcusd == 0 ) + btcusd = pvals[MAX_CURRENCIES + 1]; + if ( kmdbtc < 25000 ) kmdbtc = 25000; - btcusd = pvals[MAX_CURRENCIES + 1]; if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; usdvol = komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - //printf("base -> USD %llu, BTC %llu KMDUSD %llu\n",(long long)baseusd,(long long)btcusd,(long long)kmdusd); - //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); + printf("base -> USD %llu, BTC %llu KMDUSD %llu\n",(long long)baseusd,(long long)btcusd,(long long)kmdusd); + printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } @@ -357,7 +418,7 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba return(0); } -uint64_t _komodo_paxprice(int32_t height,char *base,char *rel,uint64_t basevolume) +uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,char *base,char *rel,uint64_t basevolume,uint64_t kmdbtc,uint64_t btcusd) { int32_t baseid=-1,relid=-1,i; uint32_t *ptr; if ( height > 10 ) @@ -368,7 +429,13 @@ uint64_t _komodo_paxprice(int32_t height,char *base,char *rel,uint64_t basevolum { ptr = &PVALS[36 * i]; if ( *ptr < height ) - return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume)); + { + *kmdbtcp = pvals[MAX_CURRENCIES + 1]; + *btcusdp = pvals[MAX_CURRENCIES + 2]; + if ( kmdbtc != 0 && btcusd != 0 ) + return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume,kmdbtc,btcusd)); + else return(0); + } } } else printf("paxprice invalid base.%s %d, rel.%s %d\n",base,baseid,rel,relid); return(0); @@ -376,7 +443,7 @@ uint64_t _komodo_paxprice(int32_t height,char *base,char *rel,uint64_t basevolum uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { - int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,seed,tolerance,den,densum,sum=0,votes[539]; + int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,seed,tolerance,den,densum,sum=0,votes[539],btcusds[539],kmdbtcs[539],kmdbtc,btcusd; if ( basevolume > 10000*COIN ) { printf("komodo_paxprice overflow %.8f\n",dstr(basevolume)); @@ -384,67 +451,23 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin } numvotes = (int32_t)(sizeof(Peggy_inds)/sizeof(*Peggy_inds)); memset(votes,0,sizeof(votes)); - for (sum=i=zeroes=nonz=0; i> 1) ) return(0); - sum /= nonz; - lastprice = sum; - for (i=0; i (numvotes >> 1) ) - break; - } - } - } - } - if ( wt > (numvotes >> 1) ) - { - ind = i; - for (densum=sum=j=0; j= max ) return(num); From 9e838b49de0347c3419d00ebc9bef9f58402aef6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:12:15 -0300 Subject: [PATCH 381/549] test --- src/komodo_pax.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index eb84f0231..f4b0843ba 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -430,8 +430,11 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha ptr = &PVALS[36 * i]; if ( *ptr < height ) { - *kmdbtcp = pvals[MAX_CURRENCIES + 1]; - *btcusdp = pvals[MAX_CURRENCIES + 2]; + if ( kmdbtcp != 0 && btcusdp != 0 ) + { + *kmdbtcp = pvals[MAX_CURRENCIES + 1]; + *btcusdp = pvals[MAX_CURRENCIES + 2]; + } if ( kmdbtc != 0 && btcusd != 0 ) return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume,kmdbtc,btcusd)); else return(0); @@ -461,7 +464,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); for (i=nonz=0; i Date: Sun, 27 Nov 2016 11:14:36 -0300 Subject: [PATCH 382/549] test --- src/komodo_pax.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index f4b0843ba..e6787c0cd 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -389,7 +389,7 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; usdvol = komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - printf("base -> USD %llu, BTC %llu KMDUSD %llu\n",(long long)baseusd,(long long)btcusd,(long long)kmdusd); + printf("base -> USD %llu, BTC %llu ",(long long)baseusd,(long long)btcusd); printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); @@ -432,8 +432,8 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha { if ( kmdbtcp != 0 && btcusdp != 0 ) { - *kmdbtcp = pvals[MAX_CURRENCIES + 1]; - *btcusdp = pvals[MAX_CURRENCIES + 2]; + *kmdbtcp = ptr[MAX_CURRENCIES + 1]; + *btcusdp = ptr[MAX_CURRENCIES + 2]; } if ( kmdbtc != 0 && btcusd != 0 ) return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume,kmdbtc,btcusd)); From a6cd9b2813c40e1be8852527299b033016c0f20b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:31:30 -0300 Subject: [PATCH 383/549] test --- src/komodo_gateway.h | 2 +- src/komodo_pax.h | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c539b63ce..51dcbcbb3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -515,7 +515,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) { int32_t ratio; - if ( seed == 0 ) + if ( seed == 0 && checkvalue != 0 ) { ratio = ((value << 6) / checkvalue); if ( ratio >= 63 && ratio <= 65 ) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index e6787c0cd..e95c95149 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -308,7 +308,7 @@ void komodo_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals) } } -uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed,uint64_t basevolume) +uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) { int32_t i,j,k,ind,zeroes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0; for (sum=i=zeroes=nonz=0; i 10000*COIN ) { printf("komodo_paxprice overflow %.8f\n",dstr(basevolume)); @@ -457,10 +457,13 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin memset(btcusds,0,sizeof(btcusds)); memset(kmdbtcs,0,sizeof(kmdbtcs)); for (i=0; i Date: Sun, 27 Nov 2016 11:32:36 -0300 Subject: [PATCH 384/549] test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index e95c95149..4209f4422 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -473,7 +473,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin } if ( nonz <= (numvotes >> 1) ) return(0); - return(komodo_paxcorrelation(votes,numvotes,seed,basevolume) / 100000); + return(komodo_paxcorrelation(votes,numvotes,seed)); } int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel) From 8e4f2263708125a7e198dcb8a09cc7b9bcd398db Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:38:40 -0300 Subject: [PATCH 385/549] test --- src/komodo_pax.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 4209f4422..343d281f9 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -356,10 +356,11 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) den = peggy_smooth_coeffs[j]; densum += den; sum += (den * votes[(ind + j) % numvotes]); + printf("%.8f ",(double)sum/densum); } sum /= densum; //sum = (sum * basevolume); - //printf("paxprice seed.%llx sum %.8f densum %.8f basevol %.8f height.%d\n",(long long)seed,dstr(sum),dstr(densum),dstr(basevolume),height); + printf("paxprice seed.%llx sum %.8f densum %.8f basevol %.8f height.%d\n",(long long)seed,dstr(sum),dstr(densum),dstr(basevolume),height); break; } } From 96a5ff2ef95ba8d9abe32d7ab49ba5b52abdf98c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:39:37 -0300 Subject: [PATCH 386/549] test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 343d281f9..9bc2efc54 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -360,7 +360,7 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) } sum /= densum; //sum = (sum * basevolume); - printf("paxprice seed.%llx sum %.8f densum %.8f basevol %.8f height.%d\n",(long long)seed,dstr(sum),dstr(densum),dstr(basevolume),height); + printf("paxprice seed.%llx sum %.8f densum %.8f height.%d\n",(long long)seed,dstr(sum),dstr(densum),height); break; } } From 39681154892ebccada51404a3bab76f9e34920b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:40:45 -0300 Subject: [PATCH 387/549] test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 9bc2efc54..d6e780a9f 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -360,7 +360,7 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) } sum /= densum; //sum = (sum * basevolume); - printf("paxprice seed.%llx sum %.8f densum %.8f height.%d\n",(long long)seed,dstr(sum),dstr(densum),height); + printf("paxprice seed.%llx sum %.8f densum %.8f\n",(long long)seed,dstr(sum),dstr(densum)); break; } } From f56ade04edd6e72fc91e51dd2ca3e325a1870ef1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:46:01 -0300 Subject: [PATCH 388/549] test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index d6e780a9f..6ee3f1c80 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -356,7 +356,7 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) den = peggy_smooth_coeffs[j]; densum += den; sum += (den * votes[(ind + j) % numvotes]); - printf("%.8f ",(double)sum/densum); + printf("(%llu/%llu %.8f) ",(long long)sum,(long long)densum,(double)sum/densum); } sum /= densum; //sum = (sum * basevolume); From 406d463f0bdbc5566d3bfc2baa02fc5d8af455bc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:51:02 -0300 Subject: [PATCH 389/549] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 6ee3f1c80..44b9ed5bd 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -433,8 +433,8 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha { if ( kmdbtcp != 0 && btcusdp != 0 ) { - *kmdbtcp = ptr[MAX_CURRENCIES + 1]; - *btcusdp = ptr[MAX_CURRENCIES + 2]; + *kmdbtcp = ptr[MAX_CURRENCIES + 1] / 10; + *btcusdp = ptr[MAX_CURRENCIES + 2] / 10; } if ( kmdbtc != 0 && btcusd != 0 ) return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume,kmdbtc,btcusd)); From 48dbd80fbd9cf361b455f71b96405f6428727566 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:58:53 -0300 Subject: [PATCH 390/549] test --- src/komodo_pax.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 44b9ed5bd..b914c71a7 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -390,8 +390,8 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; usdvol = komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - printf("base -> USD %llu, BTC %llu ",(long long)baseusd,(long long)btcusd); - printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); + //printf("base -> USD %llu, BTC %llu ",(long long)baseusd,(long long)btcusd); + //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } @@ -433,8 +433,8 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha { if ( kmdbtcp != 0 && btcusdp != 0 ) { - *kmdbtcp = ptr[MAX_CURRENCIES + 1] / 10; - *btcusdp = ptr[MAX_CURRENCIES + 2] / 10; + *kmdbtcp = ptr[MAX_CURRENCIES + 1] / 128; + *btcusdp = ptr[MAX_CURRENCIES + 2] / 128; } if ( kmdbtc != 0 && btcusd != 0 ) return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume,kmdbtc,btcusd)); @@ -460,11 +460,11 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin for (i=0; i Date: Sun, 27 Nov 2016 11:59:16 -0300 Subject: [PATCH 391/549] test --- src/komodo_pax.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index b914c71a7..0a96adc95 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -433,8 +433,8 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha { if ( kmdbtcp != 0 && btcusdp != 0 ) { - *kmdbtcp = ptr[MAX_CURRENCIES + 1] / 128; - *btcusdp = ptr[MAX_CURRENCIES + 2] / 128; + *kmdbtcp = ptr[MAX_CURRENCIES + 1] / 539; + *btcusdp = ptr[MAX_CURRENCIES + 2] / 539; } if ( kmdbtc != 0 && btcusd != 0 ) return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume,kmdbtc,btcusd)); @@ -463,8 +463,8 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin //printf("(%llu %llu) ",(long long)kmdbtcs[numvotes-1-i],(long long)btcusds[numvotes-1-i]); } *seedp = seed = komodo_seed(height); - kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,seed) * 128; - btcusd = komodo_paxcorrelation(btcusds,numvotes,seed) * 128; + kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,seed) * 539; + btcusd = komodo_paxcorrelation(btcusds,numvotes,seed) * 539; printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); for (i=nonz=0; i Date: Sun, 27 Nov 2016 12:07:58 -0300 Subject: [PATCH 392/549] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 0a96adc95..91044f3bb 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -356,7 +356,7 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) den = peggy_smooth_coeffs[j]; densum += den; sum += (den * votes[(ind + j) % numvotes]); - printf("(%llu/%llu %.8f) ",(long long)sum,(long long)densum,(double)sum/densum); + //printf("(%llu/%llu %.8f) ",(long long)sum,(long long)densum,(double)sum/densum); } sum /= densum; //sum = (sum * basevolume); @@ -468,7 +468,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); for (i=nonz=0; i Date: Sun, 27 Nov 2016 12:10:58 -0300 Subject: [PATCH 393/549] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 91044f3bb..34c791a80 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -468,13 +468,13 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); for (i=nonz=0; i> 1) ) return(0); - return(komodo_paxcorrelation(votes,numvotes,seed)); + return(komodo_paxcorrelation(votes,numvotes,seed) * 1000); } int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel) From a5fcacd775f40ee91359ef2ca3a04f2c2e96d989 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 12:17:13 -0300 Subject: [PATCH 394/549] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 34c791a80..d7741a226 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -360,7 +360,7 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) } sum /= densum; //sum = (sum * basevolume); - printf("paxprice seed.%llx sum %.8f densum %.8f\n",(long long)seed,dstr(sum),dstr(densum)); + //printf("paxprice seed.%llx sum %.8f densum %.8f\n",(long long)seed,dstr(sum),dstr(densum)); break; } } @@ -474,7 +474,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin } if ( nonz <= (numvotes >> 1) ) return(0); - return(komodo_paxcorrelation(votes,numvotes,seed) * 1000); + return(komodo_paxcorrelation(votes,numvotes,seed) * basevolume); } int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel) From c753065bb0e465bd733c1c0e8e187ef34f5351d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 12:19:48 -0300 Subject: [PATCH 395/549] test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index d7741a226..77c9e97d6 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -474,7 +474,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin } if ( nonz <= (numvotes >> 1) ) return(0); - return(komodo_paxcorrelation(votes,numvotes,seed) * basevolume); + return(komodo_paxcorrelation(votes,numvotes,seed) * basevolume / 100000); } int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel) From 61230ce13c4d0244b06af91eb1d5ac2608aa2aa4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 13:58:18 -0300 Subject: [PATCH 396/549] test --- src/komodo_gateway.h | 2 +- src/komodo_pax.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 51dcbcbb3..358ae20d1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -368,7 +368,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to //printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); if ( strcmp(symbol,"KMD") == 0 && pax->approved == 0 ) continue; - else if ( strcmp(symbol,"KMD") != 0 ) + //else if ( strcmp(symbol,"KMD") != 0 ) { #ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE struct komodo_state *kmdsp = komodo_stateptrget((char *)"KMD"); diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 77c9e97d6..f83170ff2 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -465,7 +465,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin *seedp = seed = komodo_seed(height); kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,seed) * 539; btcusd = komodo_paxcorrelation(btcusds,numvotes,seed) * 539; - printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); + //printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); for (i=nonz=0; i Date: Sun, 27 Nov 2016 14:23:40 -0300 Subject: [PATCH 397/549] test --- src/komodo.h | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 75e682c8b..0b1199c09 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -85,7 +85,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char errs++; else { - printf("updated %d pubkeys at %s ht.%d\n",num,symbol,ht); + //printf("updated %d pubkeys at %s ht.%d\n",num,symbol,ht); if ( (KOMODO_EXTERNAL_NOTARIES != 0 && matched != 0) || (strcmp(symbol,"KMD") == 0 && KOMODO_EXTERNAL_NOTARIES == 0) ) komodo_eventadd_pubkeys(sp,symbol,ht,num,pubkeys); } diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 6cf292ccc..6415b9d94 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -99,7 +99,7 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) height /= KOMODO_ELECTION_GAP; height = ((height + 1) * KOMODO_ELECTION_GAP); htind = (height / KOMODO_ELECTION_GAP); - printf("htind.%d activation %d from %d vs %d | hwmheight.%d\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight); + printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,ASSETCHAINS_SYMBOL); } else htind = 0; pthread_mutex_lock(&komodo_mutex); for (k=0; k Date: Sun, 27 Nov 2016 14:26:53 -0300 Subject: [PATCH 398/549] test --- src/chainparams.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 34b042749..b0a0f28a0 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -95,6 +95,7 @@ public: assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b")); vFixedSeeds.clear(); vSeeds.clear(); + vSeeds.push_back(CDNSSeedData("komodoplatform.com", "seeds.komodoplatform.com")); // @kolo vSeeds.push_back(CDNSSeedData("komodo.mewhub.com", "seeds.komodo.mewhub.com")); // @kolo // TODO: set up bootstrapping for mainnet base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,60); From 061bbda40508c2f97f09f029be8e3e9b8a55ebfc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 14:51:13 -0300 Subject: [PATCH 399/549] test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index f83170ff2..6f65f95e2 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -448,7 +448,7 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,seed,tolerance,den,densum,sum=0,votes[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],btcusds[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtcs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtc,btcusd; - if ( basevolume > 10000*COIN ) + if ( basevolume > 100000*COIN ) { printf("komodo_paxprice overflow %.8f\n",dstr(basevolume)); return(0); From ac606ad4d518a42a710c21f0cea0fa2ccce6a22c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 14:57:04 -0300 Subject: [PATCH 400/549] test --- src/komodo.h | 1 + src/komodo_pax.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0b1199c09..aea264253 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -24,6 +24,7 @@ // b. automated distribution of test REVS snapshot #define KOMODO_ASSETCHAINS_WAITNOTARIZE +#define KOMODO_PAXMAX (100000 * COIN) #include #include diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 6f65f95e2..2e5ae40db 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -370,7 +370,7 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t basevolume,uint64_t kmdbtc,uint64_t btcusd) { uint32_t pvalb,pvalr; uint64_t usdvol,baseusd,usdkmd,baserel,ranked[32]; - if ( basevolume > 10000*COIN ) + if ( basevolume > KOMODO_PAXMAX ) { printf("paxcalc overflow %.8f\n",dstr(basevolume)); return(0); @@ -448,7 +448,7 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,seed,tolerance,den,densum,sum=0,votes[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],btcusds[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtcs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtc,btcusd; - if ( basevolume > 100000*COIN ) + if ( basevolume > KOMODO_PAXMAX ) { printf("komodo_paxprice overflow %.8f\n",dstr(basevolume)); return(0); From fa8d44fc9cbea077096eda8ac8c15a48dce402b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:06:47 -0300 Subject: [PATCH 401/549] test --- src/komodo.h | 2 +- src/komodo_pax.h | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index aea264253..a7c38399a 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -24,7 +24,7 @@ // b. automated distribution of test REVS snapshot #define KOMODO_ASSETCHAINS_WAITNOTARIZE -#define KOMODO_PAXMAX (100000 * COIN) +#define KOMODO_PAXMAX (10000 * COIN) #include #include diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 2e5ae40db..105a55743 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -388,11 +388,15 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; - usdvol = komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; + usdvol = komodo_paxvol(basevolume,baseusd); + if ( MINDENOMS[baseid] > MINDENOMS[USD] ) + usdvol /= (MINDENOMS[baseid] / MINDENOMS[USD]); usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - //printf("base -> USD %llu, BTC %llu ",(long long)baseusd,(long long)btcusd); + printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu ",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); - return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); + if ( MINDENOMS[baseid] < MINDENOMS[USD] ) + return((MINDENOMS[USD]/MINDENOMS[baseid]) * komodo_paxvol(usdvol,usdkmd)); + else return(komodo_paxvol(usdvol,usdkmd)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } else if ( baseid == relid ) From 5fe8a65f7fd1a9243eda52f994ad63aa526c1eaf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:12:49 -0300 Subject: [PATCH 402/549] test --- src/komodo_pax.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 105a55743..2cd0ee377 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -383,20 +383,16 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba kmdbtc = pvals[MAX_CURRENCIES]; if ( btcusd == 0 ) btcusd = pvals[MAX_CURRENCIES + 1]; - if ( kmdbtc < 25000 ) - kmdbtc = 25000; + if ( kmdbtc < 25000000 ) + kmdbtc = 25000000; if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { - baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; + baseusd = ((uint64_t)pvalb * (1000000000*MINDENOMS[USD]/MINDENOMS[baseid])) / pvals[USD]; usdvol = komodo_paxvol(basevolume,baseusd); - if ( MINDENOMS[baseid] > MINDENOMS[USD] ) - usdvol /= (MINDENOMS[baseid] / MINDENOMS[USD]); usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu ",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); + printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); - if ( MINDENOMS[baseid] < MINDENOMS[USD] ) - return((MINDENOMS[USD]/MINDENOMS[baseid]) * komodo_paxvol(usdvol,usdkmd)); - else return(komodo_paxvol(usdvol,usdkmd)); + return(komodo_paxvol(usdvol,usdkmd)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } else if ( baseid == relid ) From 1aefb8595926d2bdcd788129c1cf63ffa1870809 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:19:06 -0300 Subject: [PATCH 403/549] test --- src/komodo_pax.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 2cd0ee377..edf2568aa 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -387,12 +387,13 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba kmdbtc = 25000000; if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { - baseusd = ((uint64_t)pvalb * (1000000000*MINDENOMS[USD]/MINDENOMS[baseid])) / pvals[USD]; - usdvol = komodo_paxvol(basevolume,baseusd); + baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; + usdvol = MINDENOMS[USD] * komodo_paxvol(basevolume,baseusd); + //usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); + printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); - return(komodo_paxvol(usdvol,usdkmd)); + return(komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } else if ( baseid == relid ) From ec2ad5bb0e8334c3be243c4039419bb54dcde9ea Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:20:50 -0300 Subject: [PATCH 404/549] test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index edf2568aa..13f60aad6 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -391,7 +391,7 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba usdvol = MINDENOMS[USD] * komodo_paxvol(basevolume,baseusd); //usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); + printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid])); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); return(komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); From 9703af06df45a42747758f9b6ec8ffd0ab6f7ed5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:25:32 -0300 Subject: [PATCH 405/549] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 13f60aad6..41da46a05 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -388,12 +388,12 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; - usdvol = MINDENOMS[USD] * komodo_paxvol(basevolume,baseusd); + usdvol = MINDENOMS[USD] * komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; //usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid])); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); - return(komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); + return(komodo_paxvol(usdvol,usdkmd)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } else if ( baseid == relid ) From 3309b67c281074f017c30c639106c92068a7d185 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:32:13 -0300 Subject: [PATCH 406/549] test --- src/komodo_pax.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 41da46a05..cfed4085f 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -388,12 +388,12 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; - usdvol = MINDENOMS[USD] * komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; + usdvol = komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; //usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid])); + printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); - return(komodo_paxvol(usdvol,usdkmd)); + return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } else if ( baseid == relid ) From 445e9606fb6d14cfad54e2c3f10980f4c4fd51c3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:37:07 -0300 Subject: [PATCH 407/549] test --- src/komodo_pax.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index cfed4085f..af761e54e 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -388,12 +388,12 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; - usdvol = komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; + usdvol = komodo_paxvol(basevolume,baseusd); //usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); + printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid])); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); - return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); + return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } else if ( baseid == relid ) From 5929269abd59fddab22258fc77af100aa0a7ca0a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:39:36 -0300 Subject: [PATCH 408/549] test --- src/komodo_pax.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index af761e54e..f90b3da0f 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -387,9 +387,8 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba kmdbtc = 25000000; if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { - baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; + baseusd = 1000 * (((uint64_t)pvalb * 1000000) / pvals[USD]); usdvol = komodo_paxvol(basevolume,baseusd); - //usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid])); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); From ca6d4ab7df50ef801035657d2bb31bdc39c7c311 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:03:16 -0300 Subject: [PATCH 409/549] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index f90b3da0f..48e0b5a2c 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -389,7 +389,7 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba { baseusd = 1000 * (((uint64_t)pvalb * 1000000) / pvals[USD]); usdvol = komodo_paxvol(basevolume,baseusd); - usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; + usdkmd = ((uint64_t)kmdbtc * 1000000000) / btcusd; printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid])); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); @@ -407,7 +407,7 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba else if ( (pvalr= pvals[relid]) != 0 ) { baserel = ((uint64_t)pvalb * 1000000000) / pvalr; - //printf("baserel.%lld %lld %lld %.8f %.8f\n",(long long)baserel,(long long)MINDENOMS[baseid],(long long)MINDENOMS[relid],dstr(MINDENOMS[baseid]/MINDENOMS[relid]),dstr(MINDENOMS[relid]/MINDENOMS[baseid])); + printf("baserel.%lld %lld %lld %.8f %.8f\n",(long long)baserel,(long long)MINDENOMS[baseid],(long long)MINDENOMS[relid],dstr(MINDENOMS[baseid]/MINDENOMS[relid]),dstr(MINDENOMS[relid]/MINDENOMS[baseid])); if ( MINDENOMS[baseid] > MINDENOMS[relid] ) basevolume /= (MINDENOMS[baseid] / MINDENOMS[relid]); else if ( MINDENOMS[baseid] < MINDENOMS[relid] ) From b0c7fb04559be1beb36d4a5683c58e67bc439637 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:10:17 -0300 Subject: [PATCH 410/549] test --- src/komodo_pax.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 48e0b5a2c..8ba2b0076 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -387,12 +387,12 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba kmdbtc = 25000000; if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { - baseusd = 1000 * (((uint64_t)pvalb * 1000000) / pvals[USD]); + baseusd = (((uint64_t)pvalb * 1000000000) / pvals[USD]); usdvol = komodo_paxvol(basevolume,baseusd); usdkmd = ((uint64_t)kmdbtc * 1000000000) / btcusd; - printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid])); + printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100))); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); - return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); + return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } else if ( baseid == relid ) @@ -453,6 +453,11 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin printf("komodo_paxprice overflow %.8f\n",dstr(basevolume)); return(0); } + if ( strcmp(base,"KMD") == 0 || strcmp(base,"kmd") == 0 ) + { + printf("kmd cannot be base currency\n"); + return(0); + } numvotes = (int32_t)(sizeof(Peggy_inds)/sizeof(*Peggy_inds)); memset(votes,0,sizeof(votes)); memset(btcusds,0,sizeof(btcusds)); From 4077bfb068e35a6faca5d87d3ebb42b8a4157f1f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:14:13 -0300 Subject: [PATCH 411/549] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 8ba2b0076..7ee964f23 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -390,7 +390,7 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba baseusd = (((uint64_t)pvalb * 1000000000) / pvals[USD]); usdvol = komodo_paxvol(basevolume,baseusd); usdkmd = ((uint64_t)kmdbtc * 1000000000) / btcusd; - printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100))); + //printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100))); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); @@ -407,7 +407,7 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba else if ( (pvalr= pvals[relid]) != 0 ) { baserel = ((uint64_t)pvalb * 1000000000) / pvalr; - printf("baserel.%lld %lld %lld %.8f %.8f\n",(long long)baserel,(long long)MINDENOMS[baseid],(long long)MINDENOMS[relid],dstr(MINDENOMS[baseid]/MINDENOMS[relid]),dstr(MINDENOMS[relid]/MINDENOMS[baseid])); + //printf("baserel.%lld %lld %lld %.8f %.8f\n",(long long)baserel,(long long)MINDENOMS[baseid],(long long)MINDENOMS[relid],dstr(MINDENOMS[baseid]/MINDENOMS[relid]),dstr(MINDENOMS[relid]/MINDENOMS[baseid])); if ( MINDENOMS[baseid] > MINDENOMS[relid] ) basevolume /= (MINDENOMS[baseid] / MINDENOMS[relid]); else if ( MINDENOMS[baseid] < MINDENOMS[relid] ) From ccdd88f40f8c02baab5cfa485ded099e2da83d79 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:22:24 -0300 Subject: [PATCH 412/549] test --- src/komodo_gateway.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 358ae20d1..2f1e64c07 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -512,7 +512,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above return(0); } -int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) +int32_t komodo_paxcmp(int32_t height,uint64_t value,uint64_t checkvalue,uint64_t seed) { int32_t ratio; if ( seed == 0 && checkvalue != 0 ) @@ -522,7 +522,8 @@ int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) return(0); else { - printf("ignore mismatched value %lld vs checkvalue %lld -> ratio.%d\n",(long long)value,(long long)checkvalue,ratio); + if ( height >= 85000 ) + printf("ignore mismatched value %lld vs checkvalue %lld -> ratio.%d\n",(long long)value,(long long)checkvalue,ratio); return(-1); } } @@ -560,7 +561,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height);*/ didstats = 0; - if ( komodo_paxcmp(value,checktoshis,seed) == 0 ) + if ( komodo_paxcmp(kmdheight,value,checktoshis,seed) == 0 ) { if ( (pax= komodo_paxfind(txid,vout,'D')) == 0 ) { @@ -602,7 +603,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 typestr = "withdraw"; //printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); didstats = 0; - if ( komodo_paxcmp(komodoshis,checktoshis,seed) == 0 ) + if ( komodo_paxcmp(kmdheight,komodoshis,checktoshis,seed) == 0 ) { if ( value != 0 && ((pax= komodo_paxfind(txid,vout,'W')) == 0 || pax->didstats == 0) ) { From dd23e17ff75a4667ab95f70c592dc8a092eb6e99 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:26:49 -0300 Subject: [PATCH 413/549] test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2f1e64c07..21439fca9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -512,7 +512,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above return(0); } -int32_t komodo_paxcmp(int32_t height,uint64_t value,uint64_t checkvalue,uint64_t seed) +int32_t komodo_paxcmp(int32_t kmdheight,uint64_t value,uint64_t checkvalue,uint64_t seed) { int32_t ratio; if ( seed == 0 && checkvalue != 0 ) @@ -522,8 +522,8 @@ int32_t komodo_paxcmp(int32_t height,uint64_t value,uint64_t checkvalue,uint64_t return(0); else { - if ( height >= 85000 ) - printf("ignore mismatched value %lld vs checkvalue %lld -> ratio.%d\n",(long long)value,(long long)checkvalue,ratio); + if ( kmdheight >= 85000 ) + printf("ht.%d ignore mismatched value %lld vs checkvalue %lld -> ratio.%d\n",kmdheight,(long long)value,(long long)checkvalue,ratio); return(-1); } } From c88bda8b76b36b9eee456419e019764d1cfa1877 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:28:50 -0300 Subject: [PATCH 414/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 21439fca9..6dbf3b26a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -522,7 +522,7 @@ int32_t komodo_paxcmp(int32_t kmdheight,uint64_t value,uint64_t checkvalue,uint6 return(0); else { - if ( kmdheight >= 85000 ) + if ( kmdheight >= 86050 ) printf("ht.%d ignore mismatched value %lld vs checkvalue %lld -> ratio.%d\n",kmdheight,(long long)value,(long long)checkvalue,ratio); return(-1); } From ce1cfd1687fba16abe5cb57c54e3a64a08e1ee3b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:35:05 -0300 Subject: [PATCH 415/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6dbf3b26a..9da4a96ac 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -522,7 +522,7 @@ int32_t komodo_paxcmp(int32_t kmdheight,uint64_t value,uint64_t checkvalue,uint6 return(0); else { - if ( kmdheight >= 86050 ) + if ( kmdheight >= 86150 ) printf("ht.%d ignore mismatched value %lld vs checkvalue %lld -> ratio.%d\n",kmdheight,(long long)value,(long long)checkvalue,ratio); return(-1); } From 8ea67f059595b803e39be4337563fb42ab9dead1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:52:09 -0300 Subject: [PATCH 416/549] test --- src/komodo_pax.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 7ee964f23..d8cfc4f0b 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -317,6 +317,8 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) zeroes++; else sum += votes[i], nonz++; } + if ( nonz < (numvotes >> 2) ) + return(0) sum /= nonz; lastprice = sum; for (i=0; i Date: Sun, 27 Nov 2016 16:52:56 -0300 Subject: [PATCH 417/549] test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index d8cfc4f0b..3fe5304cc 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -318,7 +318,7 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) else sum += votes[i], nonz++; } if ( nonz < (numvotes >> 2) ) - return(0) + return(0); sum /= nonz; lastprice = sum; for (i=0; i Date: Sun, 27 Nov 2016 17:26:02 -0300 Subject: [PATCH 418/549] test --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index a7c38399a..84cb87c93 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -512,8 +512,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } numvalid = bitweight(signedmask); - if ( height == 79633 ) - notarized = 1; + //if ( height == 79633 ) + // notarized = 1; if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries/3)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); From 93204984f645b9a4d96f5305ab1ac60bdc6d56e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 28 Nov 2016 09:29:56 -0300 Subject: [PATCH 419/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 84cb87c93..1645f9516 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -23,7 +23,7 @@ // a. automate notarization fee payouts // b. automated distribution of test REVS snapshot -#define KOMODO_ASSETCHAINS_WAITNOTARIZE +//#define KOMODO_ASSETCHAINS_WAITNOTARIZE #define KOMODO_PAXMAX (10000 * COIN) #include From 1855a4edc745aa4ca8a6c220bf4945c707ade477 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 10:18:53 -0300 Subject: [PATCH 420/549] test --- src/assetchains | 1 + src/assetfunds | 1 + src/fiat-cli | 1 + src/komodo_bitcoind.h | 1 - src/miner.cpp | 3 ++- src/rpcblockchain.cpp | 10 +++++++++- 6 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/assetchains b/src/assetchains index 8f5febcff..241c77c34 100755 --- a/src/assetchains +++ b/src/assetchains @@ -1,4 +1,5 @@ #!/bin/bash +set -x source pubkey.txt echo $pubkey diff --git a/src/assetfunds b/src/assetfunds index df5f715a6..6aede587c 100755 --- a/src/assetfunds +++ b/src/assetfunds @@ -1,4 +1,5 @@ #!/bin/bash +set -x ./komodo-cli paxdeposit $1 0.01 aud ./komodo-cli paxdeposit $1 0.01 bgn ./komodo-cli paxdeposit $1 0.01 cad diff --git a/src/fiat-cli b/src/fiat-cli index 1a4004be7..f8aa190c4 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -1,4 +1,5 @@ #!/bin/bash +set -x echo aud; fiat/aud $1 $2 $3 $4 echo bgn; fiat/bgn $1 $2 $3 $4 echo cad; fiat/cad $1 $2 $3 $4 diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 5e3e228ea..ab2ef56e4 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -527,7 +527,6 @@ int8_t komodo_minerid(int32_t height) return(i); } } - //printf("minderid not notary ht.%d\n",height); return(-1); } diff --git a/src/miner.cpp b/src/miner.cpp index 2567539f3..98207727c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -99,7 +99,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, } #define ASSETCHAINS_MINHEIGHT 100 -#define ROUNDROBIN_DELAY 59 +#define ROUNDROBIN_DELAY 58 extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; @@ -717,6 +717,7 @@ void static BitcoinMiner(CWallet *pwallet) for (i=0; i<32; i++) fprintf(stderr,"%02x",((uint8_t *)&hash)[i]); fprintf(stderr," <- %s Block found %d\n",ASSETCHAINS_SYMBOL,Mining_height); + sleep(60); // avoid mining forks break; } } catch (EhSolverCancelledException&) { diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index b87eaf942..70644aad7 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -412,12 +412,20 @@ Value minerids(const Array& params, bool fHelp) } for (i=0; i<64; i++) { - Object item; std::string hex; char *hexstr; + Object item; std::string hex,kmdaddress; char *hexstr,kmdaddr[64],*ptr; int32_t m; hex.resize(66); hexstr = (char *)hex.data(); for (j=0; j<33; j++) sprintf(&hexstr[j*2],"%02x",pubkeys[i][j]); item.push_back(Pair("notaryid", i)); + + bitcoin_address(kmdaddr,60,pubkeys[i],33); + m = (int32_t)strlen(kmdaddr); + kmdaddress.resize(m); + ptr = (char *)kmdaddress.data(); + memcpy(ptr,kmdaddr,m); + item.push_back(Pair("KMDaddress", kmdaddress)); + item.push_back(Pair("pubkey", hex)); item.push_back(Pair("blocks", tally[i])); a.push_back(item); From 9b701b901e9ccd6716f3de50b01965d5d2b8ad67 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 12:42:52 -0300 Subject: [PATCH 421/549] test --- src/miner.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 98207727c..32b9f9f5b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -392,7 +392,11 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) } else if ( komodo_is_issuer() != 0 ) { - komodo_gateway_deposits(&txNew,ASSETCHAINS_SYMBOL,0); + do + { + komodo_gateway_deposits(&txNew,ASSETCHAINS_SYMBOL,0); + sleep(10); + } while ( txNew.vout.size() == 1 ); fprintf(stderr,"%s txNew numvouts.%d\n",ASSETCHAINS_SYMBOL,(int32_t)txNew.vout.size()); } pblock->vtx[0] = txNew; From 9bd14f97d73a000c1387a802283b762006153b80 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 13:15:41 -0300 Subject: [PATCH 422/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9da4a96ac..c2b42bc65 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -498,7 +498,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } if ( matched != num ) { - printf("WOULD REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); + printf("WOULD REJECT %s: ht.%d (%c) matched.%d vs num.%d\n",symbol,height,opcode,matched,num); // can easily happen depending on order of loading if ( height > 100000 ) //&& opcode == 'X' ) { From 13d34e32dcfabaf3849aa8062af7726834e36b07 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 13:38:41 -0300 Subject: [PATCH 423/549] test --- src/assetchains | 87 +++++++++++++++++++++++++++++------------------ src/fiat-cli | 7 ++++ src/fiat/_usd | 3 -- src/fiat/bet | 2 ++ src/fiat/bots | 2 ++ src/fiat/crypto | 2 ++ src/fiat/dex | 2 ++ src/fiat/hodl | 2 ++ src/fiat/jumblr | 2 ++ src/fiat/pangea | 2 ++ src/fiat/shark | 2 ++ src/fiat/supernet | 2 ++ 12 files changed, 78 insertions(+), 37 deletions(-) delete mode 100755 src/fiat/_usd create mode 100755 src/fiat/bet create mode 100755 src/fiat/bots create mode 100755 src/fiat/crypto create mode 100755 src/fiat/dex create mode 100755 src/fiat/hodl create mode 100755 src/fiat/jumblr create mode 100755 src/fiat/pangea create mode 100755 src/fiat/shark create mode 100755 src/fiat/supernet diff --git a/src/assetchains b/src/assetchains index 241c77c34..8f18315a4 100755 --- a/src/assetchains +++ b/src/assetchains @@ -3,8 +3,61 @@ set -x source pubkey.txt echo $pubkey +./komodod -pubkey=$pubkey -ac_name=REVS -ac_supply=1300000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=SUPERNET -ac_supply=816061 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=DEX -ac_supply=1000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=PANGEA -ac_supply=1000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=JUMBLR -ac_supply=1000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=BET -ac_supply=1000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=CRYPTO -ac_supply=1000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=HODL -ac_supply=10000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=SHARK -ac_supply=10000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=BOTS -ac_supply=10000000 -addnode=78.47.196.146 $1 & + +./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=EUR -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=JPY -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=GBP -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=AUD -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=CAD -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=CHF -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=NZD -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=CNY -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=RUB -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=MXN -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=BRL -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=INR -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=HKD -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=TRY -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=ZAR -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=PLN -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=NOK -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=SEK -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=DKK -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=CZK -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=HUF -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=ILS -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=KRW -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=MYR -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=PHP -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=RON -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=SGD -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=THB -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=BGN -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=IDR -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=HRK -addnode=78.47.196.146 $1 & + curl --url "http://127.0.0.1:7776" --data "{\"timeout\":60000,\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"REVS\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SUPERNET\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DEX\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PANGEA\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"JUMBLR\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BET\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CRYPTO\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HODL\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SHARK\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BOTS\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"USD\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EUR\",\"pubkey\":\"$pubkey\"}" @@ -39,37 +92,3 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"IDR\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HRK\",\"pubkey\":\"$pubkey\"}" -./komodod -pubkey=$pubkey -ac_name=REVS -ac_supply=1300000 -addnode=78.47.196.146 $1 & - -./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=EUR -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=JPY -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=GBP -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=AUD -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=CAD -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=CHF -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=NZD -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=CNY -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=RUB -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=MXN -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=BRL -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=INR -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=HKD -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=TRY -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=ZAR -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=PLN -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=NOK -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=SEK -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=DKK -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=CZK -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=HUF -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=ILS -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=KRW -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=MYR -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=PHP -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=RON -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=SGD -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=THB -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=BGN -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=IDR -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=HRK -addnode=78.47.196.146 $1 & diff --git a/src/fiat-cli b/src/fiat-cli index f8aa190c4..f9d13cf8b 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -33,3 +33,10 @@ echo try; fiat/try $1 $2 $3 $4 echo usd; fiat/usd $1 $2 $3 $4 echo zar; fiat/zar $1 $2 $3 $4 echo revs; fiat/revs $1 $2 $3 $4 +echo revs; fiat/supernet $1 $2 $3 $4 +echo revs; fiat/dex $1 $2 $3 $4 +echo revs; fiat/pangea $1 $2 $3 $4 +echo revs; fiat/jumblr $1 $2 $3 $4 +echo revs; fiat/bet $1 $2 $3 $4 +echo revs; fiat/crypto $1 $2 $3 $4 +echo revs; fiat/hodl $1 $2 $3 $4 diff --git a/src/fiat/_usd b/src/fiat/_usd deleted file mode 100755 index bdba4ea52..000000000 --- a/src/fiat/_usd +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./komodo-cli -ac_name=-USD $1 $2 $3 $4 diff --git a/src/fiat/bet b/src/fiat/bet new file mode 100755 index 000000000..73208cab5 --- /dev/null +++ b/src/fiat/bet @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=BET $1 $2 $3 $4 diff --git a/src/fiat/bots b/src/fiat/bots new file mode 100755 index 000000000..4fc22f5eb --- /dev/null +++ b/src/fiat/bots @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=BOTS $1 $2 $3 $4 diff --git a/src/fiat/crypto b/src/fiat/crypto new file mode 100755 index 000000000..cb35025fa --- /dev/null +++ b/src/fiat/crypto @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=CRYPTO $1 $2 $3 $4 diff --git a/src/fiat/dex b/src/fiat/dex new file mode 100755 index 000000000..b1ad72e09 --- /dev/null +++ b/src/fiat/dex @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=DEX $1 $2 $3 $4 diff --git a/src/fiat/hodl b/src/fiat/hodl new file mode 100755 index 000000000..192326ada --- /dev/null +++ b/src/fiat/hodl @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=HODL $1 $2 $3 $4 diff --git a/src/fiat/jumblr b/src/fiat/jumblr new file mode 100755 index 000000000..24d332184 --- /dev/null +++ b/src/fiat/jumblr @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=JUMBLR $1 $2 $3 $4 diff --git a/src/fiat/pangea b/src/fiat/pangea new file mode 100755 index 000000000..de19a2d6d --- /dev/null +++ b/src/fiat/pangea @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=PANGEA $1 $2 $3 $4 diff --git a/src/fiat/shark b/src/fiat/shark new file mode 100755 index 000000000..4c25f6a7e --- /dev/null +++ b/src/fiat/shark @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=SHARK $1 $2 $3 $4 diff --git a/src/fiat/supernet b/src/fiat/supernet new file mode 100755 index 000000000..8afb833ca --- /dev/null +++ b/src/fiat/supernet @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=SUPERNET $1 $2 $3 $4 From 1cfd79524b11626ac7631f3edd4be99955ec2d14 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 13:41:44 -0300 Subject: [PATCH 424/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 32b9f9f5b..ef561e0ad 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -552,7 +552,7 @@ void static BitcoinMiner(CWallet *pwallet) //fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (chainparams.MiningRequiresPeers()) + if (0 &&chainparams.MiningRequiresPeers()) { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; From b7fef0c9d632676a3048bc34cbd1cd59d54e747d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 13:42:04 -0300 Subject: [PATCH 425/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index ef561e0ad..32b9f9f5b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -552,7 +552,7 @@ void static BitcoinMiner(CWallet *pwallet) //fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (0 &&chainparams.MiningRequiresPeers()) + if (chainparams.MiningRequiresPeers()) { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; From c1ea37d50ae847a019263a82a80f3aff0154d526 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 13:52:41 -0300 Subject: [PATCH 426/549] test --- src/assetchains | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assetchains b/src/assetchains index 8f18315a4..12a9497a9 100755 --- a/src/assetchains +++ b/src/assetchains @@ -11,7 +11,7 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=BET -ac_supply=1000000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=CRYPTO -ac_supply=1000000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=HODL -ac_supply=10000000 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=SHARK -ac_supply=10000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=SHARK -ac_supply=1400 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=BOTS -ac_supply=10000000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 & From 4055185cebdc949be3af8cc67c8dedd5f48900a2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 14:05:43 -0300 Subject: [PATCH 427/549] test --- src/fiat-cli | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fiat-cli b/src/fiat-cli index f9d13cf8b..58f8050cf 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -40,3 +40,5 @@ echo revs; fiat/jumblr $1 $2 $3 $4 echo revs; fiat/bet $1 $2 $3 $4 echo revs; fiat/crypto $1 $2 $3 $4 echo revs; fiat/hodl $1 $2 $3 $4 +echo revs; fiat/shark $1 $2 $3 $4 +echo revs; fiat/bots $1 $2 $3 $4 From 289c3e6bd87975e2f0d41e37b3c7cc592e050133 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 14:19:24 -0300 Subject: [PATCH 428/549] test --- src/assetchains | 2 ++ src/fiat-cli | 1 + 2 files changed, 3 insertions(+) diff --git a/src/assetchains b/src/assetchains index 12a9497a9..344d4e07a 100755 --- a/src/assetchains +++ b/src/assetchains @@ -13,6 +13,7 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=HODL -ac_supply=10000000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=SHARK -ac_supply=1400 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=BOTS -ac_supply=10000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=MGW -ac_supply=10000000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=EUR -addnode=78.47.196.146 $1 & @@ -58,6 +59,7 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HODL\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SHARK\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BOTS\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MGW\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"USD\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EUR\",\"pubkey\":\"$pubkey\"}" diff --git a/src/fiat-cli b/src/fiat-cli index 58f8050cf..85f49646f 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -42,3 +42,4 @@ echo revs; fiat/crypto $1 $2 $3 $4 echo revs; fiat/hodl $1 $2 $3 $4 echo revs; fiat/shark $1 $2 $3 $4 echo revs; fiat/bots $1 $2 $3 $4 +echo revs; fiat/mgw $1 $2 $3 $4 From b6718eaf4f50bdb0e2ea10f5de6788790f36f8a8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 14:21:40 -0300 Subject: [PATCH 429/549] test --- src/fiat/mgw | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 src/fiat/mgw diff --git a/src/fiat/mgw b/src/fiat/mgw new file mode 100755 index 000000000..d498ed85a --- /dev/null +++ b/src/fiat/mgw @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=MGW $1 $2 $3 $4 From 331a618801b5e4cd56bd916177f12856a0df2265 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 14:32:51 -0300 Subject: [PATCH 430/549] test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c2b42bc65..9db7e4b23 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -512,7 +512,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above return(0); } -int32_t komodo_paxcmp(int32_t kmdheight,uint64_t value,uint64_t checkvalue,uint64_t seed) +int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t checkvalue,uint64_t seed) { int32_t ratio; if ( seed == 0 && checkvalue != 0 ) @@ -523,7 +523,7 @@ int32_t komodo_paxcmp(int32_t kmdheight,uint64_t value,uint64_t checkvalue,uint6 else { if ( kmdheight >= 86150 ) - printf("ht.%d ignore mismatched value %lld vs checkvalue %lld -> ratio.%d\n",kmdheight,(long long)value,(long long)checkvalue,ratio); + printf("ht.%d ignore mismatched %s value %lld vs checkvalue %lld -> ratio.%d\n",kmdheight,symbol,(long long)value,(long long)checkvalue,ratio); return(-1); } } @@ -561,7 +561,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height);*/ didstats = 0; - if ( komodo_paxcmp(kmdheight,value,checktoshis,seed) == 0 ) + if ( komodo_paxcmp(base,kmdheight,value,checktoshis,seed) == 0 ) { if ( (pax= komodo_paxfind(txid,vout,'D')) == 0 ) { @@ -603,7 +603,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 typestr = "withdraw"; //printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); didstats = 0; - if ( komodo_paxcmp(kmdheight,komodoshis,checktoshis,seed) == 0 ) + if ( komodo_paxcmp(base,kmdheight,komodoshis,checktoshis,seed) == 0 ) { if ( value != 0 && ((pax= komodo_paxfind(txid,vout,'W')) == 0 || pax->didstats == 0) ) { From bc2f79c958fbf16fe6044479124b17985ce45668 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 14:49:36 -0300 Subject: [PATCH 431/549] test --- src/miner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/miner.cpp b/src/miner.cpp index 32b9f9f5b..5a2aec940 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -395,6 +395,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) do { komodo_gateway_deposits(&txNew,ASSETCHAINS_SYMBOL,0); + fprintf(stderr,"%s txNew numvouts.%d\n",ASSETCHAINS_SYMBOL,(int32_t)txNew.vout.size()); sleep(10); } while ( txNew.vout.size() == 1 ); fprintf(stderr,"%s txNew numvouts.%d\n",ASSETCHAINS_SYMBOL,(int32_t)txNew.vout.size()); From 7322eaa0e2f055f5e4551a9da38a5b96d09fd05d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 14:58:49 -0300 Subject: [PATCH 432/549] test --- src/miner.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5a2aec940..6d328b901 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -392,12 +392,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) } else if ( komodo_is_issuer() != 0 ) { - do - { - komodo_gateway_deposits(&txNew,ASSETCHAINS_SYMBOL,0); - fprintf(stderr,"%s txNew numvouts.%d\n",ASSETCHAINS_SYMBOL,(int32_t)txNew.vout.size()); - sleep(10); - } while ( txNew.vout.size() == 1 ); + komodo_gateway_deposits(&txNew,ASSETCHAINS_SYMBOL,0); fprintf(stderr,"%s txNew numvouts.%d\n",ASSETCHAINS_SYMBOL,(int32_t)txNew.vout.size()); } pblock->vtx[0] = txNew; @@ -614,8 +609,11 @@ void static BitcoinMiner(CWallet *pwallet) } else Mining_start = 0; while (true) { - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"%s start mining loop\n",ASSETCHAINS_SYMBOL); + if ( ASSETCHAINS_SYMBOL[0] != 0 && txNew.vout.size() == 1 && Mining_height >= 100 ) + { + fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); + break; + } // Hash state KOMODO_CHOSEN_ONE = 0; crypto_generichash_blake2b_state state; From 352e76d3e16f1d4fc5a43fb85a7e39e2ec8a3982 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 15:00:07 -0300 Subject: [PATCH 433/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 6d328b901..e7d107f9e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -609,7 +609,7 @@ void static BitcoinMiner(CWallet *pwallet) } else Mining_start = 0; while (true) { - if ( ASSETCHAINS_SYMBOL[0] != 0 && txNew.vout.size() == 1 && Mining_height >= 100 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height >= 100 ) { fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); break; From 4a21ccd29d456fa7aa4be1bbeff6c7bb502c2224 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 15:03:57 -0300 Subject: [PATCH 434/549] test --- src/miner.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index e7d107f9e..3ddefa0c9 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -124,7 +124,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= 100 ) { isrealtime = komodo_isrealtime(&kmdheight); - fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),isrealtime,KOMODO_ON_DEMAND); while ( KOMODO_ON_DEMAND == 0 ) { deposits = komodo_paxtotal(); @@ -133,7 +132,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f ht.%d\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN,kmdheight); } else if ( deposits != 0 ) + { + fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),isrealtime,KOMODO_ON_DEMAND); break; + } sleep(10); } KOMODO_ON_DEMAND = 0; @@ -393,7 +395,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) else if ( komodo_is_issuer() != 0 ) { komodo_gateway_deposits(&txNew,ASSETCHAINS_SYMBOL,0); - fprintf(stderr,"%s txNew numvouts.%d\n",ASSETCHAINS_SYMBOL,(int32_t)txNew.vout.size()); + if ( txNew.vout.size() > 1 ) + fprintf(stderr,"%s txNew numvouts.%d\n",ASSETCHAINS_SYMBOL,(int32_t)txNew.vout.size()); } pblock->vtx[0] = txNew; pblocktemplate->vTxFees[0] = -nFees; @@ -612,6 +615,7 @@ void static BitcoinMiner(CWallet *pwallet) if ( ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height >= 100 ) { fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); + sleep(10); break; } // Hash state From 62e49ad92a38a98dab1b5c5f7dc71c27daa97d90 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 15:07:00 -0300 Subject: [PATCH 435/549] test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 3ddefa0c9..c0d3420e6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -133,7 +133,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) } else if ( deposits != 0 ) { - fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),isrealtime,KOMODO_ON_DEMAND); + //fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),isrealtime,KOMODO_ON_DEMAND); break; } sleep(10); @@ -614,7 +614,7 @@ void static BitcoinMiner(CWallet *pwallet) { if ( ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height >= 100 ) { - fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); + //fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); sleep(10); break; } From b6191882b2ac0e31172db1263f7bf1d236ec4b47 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 15:25:01 -0300 Subject: [PATCH 436/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 1645f9516..586d9f3db 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -501,7 +501,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvouts = block.vtx[i].vout.size(); notaryid = -1; voutmask = specialtx = notarizedheight = isratification = notarized = 0; - signedmask = 0; + signedmask = 1; numvins = block.vtx[i].vin.size(); for (j=0; j Date: Tue, 29 Nov 2016 17:35:36 -0300 Subject: [PATCH 437/549] test --- src/fiat-cli | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/fiat-cli b/src/fiat-cli index 85f49646f..78eadea07 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -1,5 +1,5 @@ #!/bin/bash -set -x +#set -x echo aud; fiat/aud $1 $2 $3 $4 echo bgn; fiat/bgn $1 $2 $3 $4 echo cad; fiat/cad $1 $2 $3 $4 @@ -33,13 +33,13 @@ echo try; fiat/try $1 $2 $3 $4 echo usd; fiat/usd $1 $2 $3 $4 echo zar; fiat/zar $1 $2 $3 $4 echo revs; fiat/revs $1 $2 $3 $4 -echo revs; fiat/supernet $1 $2 $3 $4 -echo revs; fiat/dex $1 $2 $3 $4 -echo revs; fiat/pangea $1 $2 $3 $4 -echo revs; fiat/jumblr $1 $2 $3 $4 -echo revs; fiat/bet $1 $2 $3 $4 -echo revs; fiat/crypto $1 $2 $3 $4 -echo revs; fiat/hodl $1 $2 $3 $4 -echo revs; fiat/shark $1 $2 $3 $4 -echo revs; fiat/bots $1 $2 $3 $4 -echo revs; fiat/mgw $1 $2 $3 $4 +echo supernet; fiat/supernet $1 $2 $3 $4 +echo dex; fiat/dex $1 $2 $3 $4 +echo pangea; fiat/pangea $1 $2 $3 $4 +echo jumblr; fiat/jumblr $1 $2 $3 $4 +echo bet; fiat/bet $1 $2 $3 $4 +echo crypto; fiat/crypto $1 $2 $3 $4 +echo hodl; fiat/hodl $1 $2 $3 $4 +echo shark; fiat/shark $1 $2 $3 $4 +echo bots; fiat/bots $1 $2 $3 $4 +echo mgw; fiat/mgw $1 $2 $3 $4 From fa96ccc110a85d05dccba94065acb04bb354488b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 17:40:44 -0300 Subject: [PATCH 438/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index c0d3420e6..4db265393 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -551,7 +551,7 @@ void static BitcoinMiner(CWallet *pwallet) //fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (chainparams.MiningRequiresPeers()) + if (0 && chainparams.MiningRequiresPeers()) { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; From ac8822389e1030f339f2bb2d46f08ab8b33f36d9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 17:41:07 -0300 Subject: [PATCH 439/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 4db265393..c0d3420e6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -551,7 +551,7 @@ void static BitcoinMiner(CWallet *pwallet) //fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (0 && chainparams.MiningRequiresPeers()) + if (chainparams.MiningRequiresPeers()) { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; From 71e8e95fb6b5dcf95fb395aa3a7c286fe0716bc2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 18:00:26 -0300 Subject: [PATCH 440/549] test --- src/assetchains | 4 ++-- src/miner.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/assetchains b/src/assetchains index 344d4e07a..1be204106 100755 --- a/src/assetchains +++ b/src/assetchains @@ -12,8 +12,8 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=CRYPTO -ac_supply=1000000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=HODL -ac_supply=10000000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=SHARK -ac_supply=1400 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=BOTS -ac_supply=10000000 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=MGW -ac_supply=10000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=BOTS -ac_supply=1000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=MGW -ac_supply=1000000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=EUR -addnode=78.47.196.146 $1 & diff --git a/src/miner.cpp b/src/miner.cpp index c0d3420e6..4db265393 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -551,7 +551,7 @@ void static BitcoinMiner(CWallet *pwallet) //fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (chainparams.MiningRequiresPeers()) + if (0 && chainparams.MiningRequiresPeers()) { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; From 5aab0392622178e655a28ec7220b53b43a61ebdd Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 18:16:56 -0300 Subject: [PATCH 441/549] test --- src/komodo.h | 2 +- src/miner.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 586d9f3db..30fca14a8 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -486,7 +486,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) hwmheight = pindex->nHeight; else { - printf("hwmheight.%d vs pindex->nHeight.%d t.%u reorg.%d\n",hwmheight,pindex->nHeight,(uint32_t)pindex->nTime,hwmheight-pindex->nHeight); + printf("%s hwmheight.%d vs pindex->nHeight.%d t.%u reorg.%d\n",ASSETCHAINS_SYMBOL,hwmheight,pindex->nHeight,(uint32_t)pindex->nTime,hwmheight-pindex->nHeight); komodo_event_rewind(sp,symbol,pindex->nHeight); komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0); } diff --git a/src/miner.cpp b/src/miner.cpp index 4db265393..22008131b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -450,6 +450,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& // // Internal miner // +int8_t komodo_minerid(int32_t height); CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) { @@ -472,6 +473,12 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) script[34] = OP_CHECKSIG; //scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; } + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + { + for (i=0; i<65; i++) + fprintf(stderr,"%d ",komodo_minerid(activeChain.Tip()->nHeight-i)); + fprintf(stderr," minerids from ht.%d\n",activeChain.Tip()->nHeight); + } return CreateNewBlock(scriptPubKey); } @@ -739,7 +746,7 @@ void static BitcoinMiner(CWallet *pwallet) // Regtest mode doesn't require peers if (vNodes.empty() && chainparams.MiningRequiresPeers()) { - if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height >= 100 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height > 100 ) { //fprintf(stderr,"no nodes, break\n"); break; From aa99979a09ee6a5a361cc96561addc47de43fb75 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 18:19:10 -0300 Subject: [PATCH 442/549] test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 22008131b..50ed68524 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -476,8 +476,8 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) if ( ASSETCHAINS_SYMBOL[0] == 0 ) { for (i=0; i<65; i++) - fprintf(stderr,"%d ",komodo_minerid(activeChain.Tip()->nHeight-i)); - fprintf(stderr," minerids from ht.%d\n",activeChain.Tip()->nHeight); + fprintf(stderr,"%d ",komodo_minerid(chainActive.Tip()->nHeight-i)); + fprintf(stderr," minerids from ht.%d\n",chainActive.Tip()->nHeight); } return CreateNewBlock(scriptPubKey); } From 568bfd3d31b3a48caab56b5b7a6cf2e42ade6143 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 18:49:48 -0300 Subject: [PATCH 443/549] tests --- src/assetchains | 4 ++-- src/miner.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/assetchains b/src/assetchains index 1be204106..57f39eaa2 100755 --- a/src/assetchains +++ b/src/assetchains @@ -8,9 +8,9 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=DEX -ac_supply=1000000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=PANGEA -ac_supply=1000000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=JUMBLR -ac_supply=1000000 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=BET -ac_supply=1000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=BET -ac_supply=999999 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=CRYPTO -ac_supply=1000000 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=HODL -ac_supply=10000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=HODL -ac_supply=9999999 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=SHARK -ac_supply=1400 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=BOTS -ac_supply=1000000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=MGW -ac_supply=1000000 -addnode=78.47.196.146 $1 & diff --git a/src/miner.cpp b/src/miner.cpp index 50ed68524..c22ae2ccd 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -558,7 +558,7 @@ void static BitcoinMiner(CWallet *pwallet) //fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (0 && chainparams.MiningRequiresPeers()) + if (chainparams.MiningRequiresPeers()) { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; From 91b997664c1163d4e76151094a19b0f6ffea47dc Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 18:59:54 -0300 Subject: [PATCH 444/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index c22ae2ccd..7815cd859 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -477,7 +477,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) { for (i=0; i<65; i++) fprintf(stderr,"%d ",komodo_minerid(chainActive.Tip()->nHeight-i)); - fprintf(stderr," minerids from ht.%d\n",chainActive.Tip()->nHeight); + fprintf(stderr," minerids.special %d from ht.%d\n",komodo_is_special(chainActive.Tip()->nHeight+1,NOTARY_PUBKEY33),chainActive.Tip()->nHeight); } return CreateNewBlock(scriptPubKey); } From cdff73943b2c12875faa50836db490a4c0afb93c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 19:03:06 -0300 Subject: [PATCH 445/549] test --- src/komodo_bitcoind.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ab2ef56e4..83409f0a2 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -561,6 +561,7 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) return(-1); } } + fprintf(stderr,"special notaryid.%d ht.%d limit.%d\n",notaryid,height,limit); return(1); } return(0); From ee8c89a8552165da2815f41644ec481ba8e57387 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 19:20:37 -0300 Subject: [PATCH 446/549] test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 7815cd859..cbb4e56b4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -473,7 +473,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) script[34] = OP_CHECKSIG; //scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; } - if ( ASSETCHAINS_SYMBOL[0] == 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] == 0 ) { for (i=0; i<65; i++) fprintf(stderr,"%d ",komodo_minerid(chainActive.Tip()->nHeight-i)); @@ -558,7 +558,7 @@ void static BitcoinMiner(CWallet *pwallet) //fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (chainparams.MiningRequiresPeers()) + if (0 && chainparams.MiningRequiresPeers()) { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; From c3706d4064c4934a6a4a572670893cff64b0e295 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 19:25:03 -0300 Subject: [PATCH 447/549] test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index cbb4e56b4..5912213e2 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -558,7 +558,7 @@ void static BitcoinMiner(CWallet *pwallet) //fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (0 && chainparams.MiningRequiresPeers()) + if (chainparams.MiningRequiresPeers()) { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; @@ -746,7 +746,7 @@ void static BitcoinMiner(CWallet *pwallet) // Regtest mode doesn't require peers if (vNodes.empty() && chainparams.MiningRequiresPeers()) { - if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height > 100 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height >= 100 ) { //fprintf(stderr,"no nodes, break\n"); break; From 36d3c16c4f2c78c5b7b93049890b3dfeb0df88a5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 19:32:50 -0300 Subject: [PATCH 448/549] test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 83409f0a2..a754f24ea 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -561,7 +561,7 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) return(-1); } } - fprintf(stderr,"special notaryid.%d ht.%d limit.%d\n",notaryid,height,limit); + //fprintf(stderr,"special notaryid.%d ht.%d limit.%d\n",notaryid,height,limit); return(1); } return(0); From 6bc551dd34ce5bc45de47196399170cab7e56762 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 19:41:42 -0300 Subject: [PATCH 449/549] test --- src/assetchains | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/assetchains b/src/assetchains index 57f39eaa2..adb4b59d1 100755 --- a/src/assetchains +++ b/src/assetchains @@ -5,15 +5,15 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=REVS -ac_supply=1300000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=SUPERNET -ac_supply=816061 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=DEX -ac_supply=1000000 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=PANGEA -ac_supply=1000000 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=JUMBLR -ac_supply=1000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=DEX -ac_supply=999999 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=PANGEA -ac_supply=999999 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=JUMBLR -ac_supply=999999 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=BET -ac_supply=999999 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=CRYPTO -ac_supply=1000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=CRYPTO -ac_supply=999999 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=HODL -ac_supply=9999999 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=SHARK -ac_supply=1400 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=BOTS -ac_supply=1000000 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=MGW -ac_supply=1000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=SHARK -ac_supply=1401 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=BOTS -ac_supply=999999 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=MGW -ac_supply=999999 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=EUR -addnode=78.47.196.146 $1 & From 1e6ae72bc143f5e0617b9d49abecc6f2fc84aad8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 20:20:37 -0300 Subject: [PATCH 450/549] test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5912213e2..cbb4e56b4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -558,7 +558,7 @@ void static BitcoinMiner(CWallet *pwallet) //fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (chainparams.MiningRequiresPeers()) + if (0 && chainparams.MiningRequiresPeers()) { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; @@ -746,7 +746,7 @@ void static BitcoinMiner(CWallet *pwallet) // Regtest mode doesn't require peers if (vNodes.empty() && chainparams.MiningRequiresPeers()) { - if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height >= 100 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height > 100 ) { //fprintf(stderr,"no nodes, break\n"); break; From 99ce21a72975cd95728f5bc282a7f683f4ea7c1f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 20:33:49 -0300 Subject: [PATCH 451/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index cbb4e56b4..c4eb6507a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -558,7 +558,7 @@ void static BitcoinMiner(CWallet *pwallet) //fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (0 && chainparams.MiningRequiresPeers()) + if (chainparams.MiningRequiresPeers()) { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; From f70ced6ac25597328c560d83fc3581c7da3eff05 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 20:45:53 -0300 Subject: [PATCH 452/549] test --- src/miner.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index c4eb6507a..5c15c37ea 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -121,7 +121,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if(!pblocktemplate.get()) return NULL; CBlock *pblock = &pblocktemplate->block; // pointer for convenience - if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= 100 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight > ASSETCHAINS_MINHEIGHT ) { isrealtime = komodo_isrealtime(&kmdheight); while ( KOMODO_ON_DEMAND == 0 ) @@ -579,7 +579,7 @@ void static BitcoinMiner(CWallet *pwallet) } while (true); //fprintf(stderr,"%s Found peers\n",ASSETCHAINS_SYMBOL); } - /*while ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight < 100 ) + /*while ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight < ASSETCHAINS_MINHEIGHT ) { fprintf(stderr,"%s waiting for block 100, ht.%d\n",ASSETCHAINS_SYMBOL,chainActive.Tip()->nHeight); sleep(3); @@ -619,7 +619,7 @@ void static BitcoinMiner(CWallet *pwallet) } else Mining_start = 0; while (true) { - if ( ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height >= 100 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) { //fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); sleep(10); @@ -746,7 +746,7 @@ void static BitcoinMiner(CWallet *pwallet) // Regtest mode doesn't require peers if (vNodes.empty() && chainparams.MiningRequiresPeers()) { - if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height > 100 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height > ASSETCHAINS_MINHEIGHT ) { //fprintf(stderr,"no nodes, break\n"); break; From eae9df94495c2f1cf8fee95f01bfec49d75b4c49 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 20:46:56 -0300 Subject: [PATCH 453/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5c15c37ea..0410930f1 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -558,7 +558,7 @@ void static BitcoinMiner(CWallet *pwallet) //fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (chainparams.MiningRequiresPeers()) + if (0 && chainparams.MiningRequiresPeers()) { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; From 9bbd16c57dee25d7b9a2aa04f55a3017d983e417 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 29 Nov 2016 21:37:39 -0300 Subject: [PATCH 454/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0410930f1..5c15c37ea 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -558,7 +558,7 @@ void static BitcoinMiner(CWallet *pwallet) //fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (0 && chainparams.MiningRequiresPeers()) + if (chainparams.MiningRequiresPeers()) { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; From 8339b0869137e2349c923a3b1471aaaecf2ba3ef Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Nov 2016 07:55:33 -0300 Subject: [PATCH 455/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5c15c37ea..24db401bb 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -99,7 +99,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, } #define ASSETCHAINS_MINHEIGHT 100 -#define ROUNDROBIN_DELAY 58 +#define ROUNDROBIN_DELAY 59 extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; From e024608617b2a4954c8a9728a786adf290177be8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Nov 2016 07:56:44 -0300 Subject: [PATCH 456/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 24db401bb..3f4a8975a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -661,7 +661,7 @@ void static BitcoinMiner(CWallet *pwallet) int32_t nseconds = Mining_start+ROUNDROBIN_DELAY-time(NULL); if ( nseconds > 0 ) sleep(nseconds); - MilliSleep((rand() % 5000) + 1); + MilliSleep((rand() % 3700) + 1); } KOMODO_CHOSEN_ONE = 1; // Found a solution From 41bdbde1345de8c64320a54dc368b44fa2d8a83c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Nov 2016 08:11:20 -0300 Subject: [PATCH 457/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 30fca14a8..45a32c63b 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -514,7 +514,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvalid = bitweight(signedmask); //if ( height == 79633 ) // notarized = 1; - if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries/3)) ) + if ( (((height < 95000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries/3)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); notarized = 1; From 6c0b4a8c8b744ef1d7db86244f75fe2531d59aea Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Nov 2016 08:32:01 -0300 Subject: [PATCH 458/549] test --- src/komodo.h | 2 +- src/komodo_bitcoind.h | 4 ++-- src/komodo_notary.h | 2 +- src/miner.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 45a32c63b..30fca14a8 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -514,7 +514,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvalid = bitweight(signedmask); //if ( height == 79633 ) // notarized = 1; - if ( (((height < 95000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries/3)) ) + if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries/3)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); notarized = 1; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a754f24ea..6678abaf2 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -557,11 +557,11 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) { if ( komodo_minerid(height-i) == notaryid ) { - //fprintf(stderr,"ht.%d notaryid.%d already mined -i.%d\n",height,notaryid,i); + fprintf(stderr,"ht.%d notaryid.%d already mined -i.%d\n",height,notaryid,i); return(-1); } } - //fprintf(stderr,"special notaryid.%d ht.%d limit.%d\n",notaryid,height,limit); + fprintf(stderr,"special notaryid.%d ht.%d limit.%d\n",notaryid,height,limit); return(1); } return(0); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 6415b9d94..67cc6d8dc 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -108,7 +108,7 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) memcpy(kp->pubkey,pubkeys[k],33); kp->notaryid = k; HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); - if ( 0 && height > 10000 ) + if ( 1 && height > 10000 ) { for (i=0; i<33; i++) printf("%02x",pubkeys[k][i]); diff --git a/src/miner.cpp b/src/miner.cpp index 3f4a8975a..a0588bcba 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -473,7 +473,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) script[34] = OP_CHECKSIG; //scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; } - if ( 0 && ASSETCHAINS_SYMBOL[0] == 0 ) + if ( 1 && ASSETCHAINS_SYMBOL[0] == 0 ) { for (i=0; i<65; i++) fprintf(stderr,"%d ",komodo_minerid(chainActive.Tip()->nHeight-i)); From 6c96293f9355f70a81fb93aa74b7d6a0f407083b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Nov 2016 08:37:22 -0300 Subject: [PATCH 459/549] test --- src/pow.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index a5d75e7ba..644a3f59d 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -108,7 +108,7 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33) int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]); int32_t komodo_currentheight(); extern int32_t KOMODO_CHOSEN_ONE; -//extern int8_t Minerids[1024 * 1024 * 5]; // 5 million blocks +#define KOMODO_ELECTION_GAP 2000 bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params) { @@ -128,12 +128,12 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in } if ( nonz == 0 ) return(true); // will come back via different path with pubkey set - if ( notaryid >= 0 ) + if ( notaryid >= 0 && ((height % KOMODO_ELECTION_GAP) == 0 || (height % KOMODO_ELECTION_GAP) > 64) ) { special2 = komodo_is_special(height,pubkey33); - if ( special2 == -2 ) - printf("height.%d special2.%d special.%d\n",height,special2,special); - if ( special2 == -2 || (height < 80000 && (special != 0 || special2 > 0)) || + //if ( special2 == -2 ) + // printf("height.%d special2.%d special.%d\n",height,special2,special); + if ( (height % KOMODO_ELECTION_GAP) == 0 || (height < 80000 && (special != 0 || special2 > 0)) || (height >= 80000 && special2 > 0) ) { bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); From ce6f853d4f942f88ec7d7e48c44f95f4d25f3f19 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Nov 2016 08:39:12 -0300 Subject: [PATCH 460/549] test --- src/pow.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index 644a3f59d..0a9e5ee28 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -128,13 +128,12 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in } if ( nonz == 0 ) return(true); // will come back via different path with pubkey set - if ( notaryid >= 0 && ((height % KOMODO_ELECTION_GAP) == 0 || (height % KOMODO_ELECTION_GAP) > 64) ) + if ( notaryid >= 0 && (height <= 90000 || (height % KOMODO_ELECTION_GAP) > 64) ) { special2 = komodo_is_special(height,pubkey33); //if ( special2 == -2 ) // printf("height.%d special2.%d special.%d\n",height,special2,special); - if ( (height % KOMODO_ELECTION_GAP) == 0 || (height < 80000 && (special != 0 || special2 > 0)) || - (height >= 80000 && special2 > 0) ) + if ( height < 90000 || (height % KOMODO_ELECTION_GAP) == 0 || (height < 80000 && (special != 0 || special2 > 0)) || (height >= 80000 && special2 > 0) ) { bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); flag = 1; From c0225afd134a0ef6ed60ac14064ca3b83f7bc137 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Nov 2016 08:42:33 -0300 Subject: [PATCH 461/549] test --- src/komodo_notary.h | 2 +- src/miner.cpp | 2 +- src/pow.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 67cc6d8dc..6415b9d94 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -108,7 +108,7 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) memcpy(kp->pubkey,pubkeys[k],33); kp->notaryid = k; HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); - if ( 1 && height > 10000 ) + if ( 0 && height > 10000 ) { for (i=0; i<33; i++) printf("%02x",pubkeys[k][i]); diff --git a/src/miner.cpp b/src/miner.cpp index a0588bcba..3f4a8975a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -473,7 +473,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) script[34] = OP_CHECKSIG; //scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; } - if ( 1 && ASSETCHAINS_SYMBOL[0] == 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] == 0 ) { for (i=0; i<65; i++) fprintf(stderr,"%d ",komodo_minerid(chainActive.Tip()->nHeight-i)); diff --git a/src/pow.cpp b/src/pow.cpp index 0a9e5ee28..e9d0e7eef 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -128,9 +128,9 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in } if ( nonz == 0 ) return(true); // will come back via different path with pubkey set + special2 = komodo_is_special(height,pubkey33); if ( notaryid >= 0 && (height <= 90000 || (height % KOMODO_ELECTION_GAP) > 64) ) { - special2 = komodo_is_special(height,pubkey33); //if ( special2 == -2 ) // printf("height.%d special2.%d special.%d\n",height,special2,special); if ( height < 90000 || (height % KOMODO_ELECTION_GAP) == 0 || (height < 80000 && (special != 0 || special2 > 0)) || (height >= 80000 && special2 > 0) ) From 6a645f7bcf5a07fa364113993100b58f61f23420 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Nov 2016 08:51:36 -0300 Subject: [PATCH 462/549] test --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 6678abaf2..a754f24ea 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -557,11 +557,11 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) { if ( komodo_minerid(height-i) == notaryid ) { - fprintf(stderr,"ht.%d notaryid.%d already mined -i.%d\n",height,notaryid,i); + //fprintf(stderr,"ht.%d notaryid.%d already mined -i.%d\n",height,notaryid,i); return(-1); } } - fprintf(stderr,"special notaryid.%d ht.%d limit.%d\n",notaryid,height,limit); + //fprintf(stderr,"special notaryid.%d ht.%d limit.%d\n",notaryid,height,limit); return(1); } return(0); From fba66dcc014c5a463d89144a96213f9314cc0459 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Nov 2016 08:57:10 -0300 Subject: [PATCH 463/549] test --- src/pow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index e9d0e7eef..c60c4b8a5 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -129,11 +129,11 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in if ( nonz == 0 ) return(true); // will come back via different path with pubkey set special2 = komodo_is_special(height,pubkey33); - if ( notaryid >= 0 && (height <= 90000 || (height % KOMODO_ELECTION_GAP) > 64) ) + if ( notaryid >= 0 && (height < 90065 || (height % KOMODO_ELECTION_GAP) > 64) ) { //if ( special2 == -2 ) // printf("height.%d special2.%d special.%d\n",height,special2,special); - if ( height < 90000 || (height % KOMODO_ELECTION_GAP) == 0 || (height < 80000 && (special != 0 || special2 > 0)) || (height >= 80000 && special2 > 0) ) + if ( height < 90065 || (height % KOMODO_ELECTION_GAP) == 0 || (height < 80000 && (special != 0 || special2 > 0)) || (height >= 80000 && special2 > 0) ) { bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); flag = 1; From b34468da0730b3fe8f373e6728dd3ebb10d6527c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Nov 2016 08:58:04 -0300 Subject: [PATCH 464/549] test --- src/pow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index c60c4b8a5..486aa83cc 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -129,11 +129,11 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in if ( nonz == 0 ) return(true); // will come back via different path with pubkey set special2 = komodo_is_special(height,pubkey33); - if ( notaryid >= 0 && (height < 90065 || (height % KOMODO_ELECTION_GAP) > 64) ) + if ( notaryid >= 0 && (height <= 90065 || (height % KOMODO_ELECTION_GAP) > 64) ) { //if ( special2 == -2 ) // printf("height.%d special2.%d special.%d\n",height,special2,special); - if ( height < 90065 || (height % KOMODO_ELECTION_GAP) == 0 || (height < 80000 && (special != 0 || special2 > 0)) || (height >= 80000 && special2 > 0) ) + if ( height <= 90065 || (height % KOMODO_ELECTION_GAP) == 0 || (height < 80000 && (special != 0 || special2 > 0)) || (height >= 80000 && special2 > 0) ) { bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); flag = 1; From b02d69be9ae4bf89fb1f97a464fc8b767bb5512a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Nov 2016 12:57:46 -0300 Subject: [PATCH 465/549] test --- src/pow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index 486aa83cc..b7077814b 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -129,11 +129,11 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in if ( nonz == 0 ) return(true); // will come back via different path with pubkey set special2 = komodo_is_special(height,pubkey33); - if ( notaryid >= 0 && (height <= 90065 || (height % KOMODO_ELECTION_GAP) > 64) ) + if ( notaryid >= 0 && ((height >= 90000 && height <= 90065) || (height % KOMODO_ELECTION_GAP) > 64) ) { //if ( special2 == -2 ) // printf("height.%d special2.%d special.%d\n",height,special2,special); - if ( height <= 90065 || (height % KOMODO_ELECTION_GAP) == 0 || (height < 80000 && (special != 0 || special2 > 0)) || (height >= 80000 && special2 > 0) ) + if ( (height >= 90000 && height <= 90065) || (height % KOMODO_ELECTION_GAP) == 0 || (height < 80000 && (special != 0 || special2 > 0)) || (height >= 80000 && special2 > 0) ) { bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); flag = 1; From 0a7c6500c8c46dd9f029245b30ea502edb68decc Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 Nov 2016 14:28:02 -0300 Subject: [PATCH 466/549] test --- src/pow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index b7077814b..7aaa9ec55 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -129,11 +129,11 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in if ( nonz == 0 ) return(true); // will come back via different path with pubkey set special2 = komodo_is_special(height,pubkey33); - if ( notaryid >= 0 && ((height >= 90000 && height <= 90065) || (height % KOMODO_ELECTION_GAP) > 64) ) + if ( notaryid >= 0 && ((height >= 64000 && height <= 90065) || (height % KOMODO_ELECTION_GAP) > 64) ) { //if ( special2 == -2 ) // printf("height.%d special2.%d special.%d\n",height,special2,special); - if ( (height >= 90000 && height <= 90065) || (height % KOMODO_ELECTION_GAP) == 0 || (height < 80000 && (special != 0 || special2 > 0)) || (height >= 80000 && special2 > 0) ) + if ( (height >= 64000 && height <= 90065) || (height % KOMODO_ELECTION_GAP) == 0 || (height < 80000 && (special != 0 || special2 > 0)) || (height >= 80000 && special2 > 0) ) { bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); flag = 1; From 5caefd225bc0421dd79ce2eac4d18ba1aa42782f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 09:59:31 -0300 Subject: [PATCH 467/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 3f4a8975a..20a5cd51a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -661,7 +661,7 @@ void static BitcoinMiner(CWallet *pwallet) int32_t nseconds = Mining_start+ROUNDROBIN_DELAY-time(NULL); if ( nseconds > 0 ) sleep(nseconds); - MilliSleep((rand() % 3700) + 1); + MilliSleep((rand() % 4700) + 1); } KOMODO_CHOSEN_ONE = 1; // Found a solution From b338ea90fa4c33d69aec31fc0abc26f25c4806cb Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 10:25:05 -0300 Subject: [PATCH 468/549] test --- src/komodo.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 30fca14a8..aceaf1267 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -512,8 +512,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } numvalid = bitweight(signedmask); - //if ( height == 79633 ) - // notarized = 1; + printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries/3)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); @@ -540,8 +539,11 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } if ( notarized != 0 && (notarizedheight != 0 || specialtx != 0) ) { - //printf("%s NOTARY SIGNED.%llx numvins.%d ht.%d txi.%d notaryht.%d specialtx.%d\n",ASSETCHAINS_SYMBOL,(long long)signedmask,numvins,height,i,notarizedheight,specialtx); - //printf("ht.%d specialtx.%d isratification.%d numvouts.%d signed.%llx numnotaries.%d\n",height,specialtx,isratification,numvouts,(long long)signedmask,numnotaries); + if ( isratification != 0 ) + { + printf("%s NOTARY SIGNED.%llx numvins.%d ht.%d txi.%d notaryht.%d specialtx.%d\n",ASSETCHAINS_SYMBOL,(long long)signedmask,numvins,height,i,notarizedheight,specialtx); + printf("ht.%d specialtx.%d isratification.%d numvouts.%d signed.%llx numnotaries.%d\n",height,specialtx,isratification,numvouts,(long long)signedmask,numnotaries); + } if ( specialtx != 0 && isratification != 0 && numvouts > 2 ) { numvalid = 0; From 8985164dece9715b55b9544efd65a3be47588e2c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 10:36:13 -0300 Subject: [PATCH 469/549] test --- src/komodo.h | 4 ++-- src/main.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index aceaf1267..d37ff0fc5 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -501,7 +501,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvouts = block.vtx[i].vout.size(); notaryid = -1; voutmask = specialtx = notarizedheight = isratification = notarized = 0; - signedmask = 1; + signedmask = (height < 100000) ? 1 : 0; numvins = block.vtx[i].vin.size(); for (j=0; j= KOMODO_MINRATIFY) || numvalid > (numnotaries/3)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); @@ -537,6 +536,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } } + printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d notarized.%d special.%d isratification.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts,notarized,specialtx,isratification); if ( notarized != 0 && (notarizedheight != 0 || specialtx != 0) ) { if ( isratification != 0 ) diff --git a/src/main.cpp b/src/main.cpp index e2da7de1b..9bc05a18c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2703,7 +2703,15 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo if (!DisconnectTip(state)) return false; } - +if ( 1 ) +{ + while (chainActive.Tip()->nHeight > 91419 ) + { + fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); + if (!DisconnectTip(state)) + return false; + } +} // Build list of new blocks to connect. std::vector vpindexToConnect; bool fContinue = true; From 763747109f4daddab4fe7decc7bb21e6b06f00ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 10:43:35 -0300 Subject: [PATCH 470/549] test --- src/main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9bc05a18c..f2c3ae6f1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2555,6 +2555,7 @@ static int64_t nTimePostConnect = 0; * corresponding to pindexNew, to bypass loading it again from disk. */ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *pblock) { + assert(pindexNew->pprev == chainActive.Tip()); mempool.check(pcoinsTip); // Read block from disk. @@ -2705,12 +2706,14 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo } if ( 1 ) { - while (chainActive.Tip()->nHeight > 91419 ) + while (chainActive.Tip()->nHeight > 91418 ) { fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); - if (!DisconnectTip(state)) + if ( !DisconnectTip(state) ) return false; } + pindexOldTip = chainActive.Tip(); + pindexFork = chainActive.FindFork(pindexMostWork); } // Build list of new blocks to connect. std::vector vpindexToConnect; From 756271276c882e97b0a2933225bffe3839461286 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 10:45:56 -0300 Subject: [PATCH 471/549] test --- src/main.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f2c3ae6f1..bfbb6cc42 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2706,14 +2706,18 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo } if ( 1 ) { - while (chainActive.Tip()->nHeight > 91418 ) + static int32_t didinit; + if ( didinit++ == 0 ) { - fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); - if ( !DisconnectTip(state) ) - return false; + while (chainActive.Tip()->nHeight > 91418 ) + { + fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); + if ( !DisconnectTip(state) ) + return false; + } + pindexOldTip = chainActive.Tip(); + pindexFork = chainActive.FindFork(pindexMostWork); } - pindexOldTip = chainActive.Tip(); - pindexFork = chainActive.FindFork(pindexMostWork); } // Build list of new blocks to connect. std::vector vpindexToConnect; From bb1963caaabb7d088e7a8b6ab32836bffa9c1de8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 10:52:50 -0300 Subject: [PATCH 472/549] test --- src/komodo.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index d37ff0fc5..c6c2148f5 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -509,7 +509,14 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { if ( (k= komodo_notarycmp(scriptPubKey,scriptlen,pubkeys,numnotaries,rmd160)) >= 0 ) signedmask |= (1LL << k); - } + else if ( numvins >= 17 ) + { + int32_t k; + for (k=0; k= KOMODO_MINRATIFY) || numvalid > (numnotaries/3)) ) From fb5b4d5e139622372e9c5be36ca0c084910e6886 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 10:57:33 -0300 Subject: [PATCH 473/549] test --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 70644aad7..a8a2dc7ce 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -682,7 +682,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid int32_t i,m; uint8_t *ptr; LOCK(cs_main); CCoins coins; - if ( 1 ) + if ( 0 ) { LOCK(mempool.cs); CCoinsViewMemPool view(pcoinsTip,mempool); From 517b16911ace4885d90971a0bf8a365148814f1c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 11:08:18 -0300 Subject: [PATCH 474/549] test --- src/komodo.h | 2 +- src/rpcblockchain.cpp | 46 ++++++++++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index c6c2148f5..7896b14cc 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -501,7 +501,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvouts = block.vtx[i].vout.size(); notaryid = -1; voutmask = specialtx = notarizedheight = isratification = notarized = 0; - signedmask = (height < 100000) ? 1 : 0; + signedmask = (height < 91400) ? 1 : 0; numvins = block.vtx[i].vin.size(); for (j=0; jGetCoins(txid,coins) == 0 ) - return(-1); - if ( n < 0 || (unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() ) - return(-1); - ptr = (uint8_t *)coins.vout[n].scriptPubKey.data(); - m = coins.vout[n].scriptPubKey.size(); - for (i=0; iGetCoins(txid,coins) == 0 ) + { + fprintf(stderr,"cant get pcoinsTip->GetCoins\n"); + continue; + } + if ( n < 0 || (unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() ) + { + fprintf(stderr,"iter.%d n.%d vs voutsize.%d\n",iter,n,(int32_t)coins.vout.size()); + continue; + } + ptr = (uint8_t *)coins.vout[n].scriptPubKey.data(); + m = coins.vout[n].scriptPubKey.size(); + for (i=0; i Date: Thu, 1 Dec 2016 11:16:33 -0300 Subject: [PATCH 475/549] test --- src/rpcblockchain.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f78c27cdd..b3e3a8912 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -711,6 +711,18 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid scriptPubKey[i] = ptr[i]; return(i); } + CTransaction tx; + uint256 hashBlock; + if ( GetTransaction(hash,tx,hashBlock,true) == 0 ) + return(-1); + else + { + ptr = (uint8_t *)tx.vout[n].scriptPubKey.data(); + m = tx.vout[n].scriptPubKey.size(); + for (i=0; i Date: Thu, 1 Dec 2016 11:16:59 -0300 Subject: [PATCH 476/549] test --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index b3e3a8912..903d651a6 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -690,14 +690,14 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid CCoinsViewMemPool view(pcoinsTip,mempool); if ( view.GetCoins(txid,coins) == 0 ) { - fprintf(stderr,"cant get view\n"); + //fprintf(stderr,"cant get view\n"); continue; } mempool.pruneSpent(txid, coins); // TODO: this should be done by the CCoinsViewMemPool } else if ( pcoinsTip->GetCoins(txid,coins) == 0 ) { - fprintf(stderr,"cant get pcoinsTip->GetCoins\n"); + //fprintf(stderr,"cant get pcoinsTip->GetCoins\n"); continue; } if ( n < 0 || (unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() ) From bdfffb78dea3e4b4aa89ebcbd5af92c28b6a6e97 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 11:17:20 -0300 Subject: [PATCH 477/549] test --- src/rpcblockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 903d651a6..8e093e997 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -721,6 +721,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid m = tx.vout[n].scriptPubKey.size(); for (i=0; i Date: Thu, 1 Dec 2016 11:19:28 -0300 Subject: [PATCH 478/549] test --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 8e093e997..f7e1c4fe3 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -713,9 +713,9 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid } CTransaction tx; uint256 hashBlock; - if ( GetTransaction(hash,tx,hashBlock,true) == 0 ) + if ( GetTransaction(txid,tx,hashBlock,true) == 0 ) return(-1); - else + else if ( n < tx.vout.size() ) { ptr = (uint8_t *)tx.vout[n].scriptPubKey.data(); m = tx.vout[n].scriptPubKey.size(); From 8b44f6c46b921dcd70e195d36497dee16dd9509c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 11:24:19 -0300 Subject: [PATCH 479/549] test --- src/miner.cpp | 2 +- src/rpcblockchain.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 20a5cd51a..ffa9e43c2 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -661,7 +661,7 @@ void static BitcoinMiner(CWallet *pwallet) int32_t nseconds = Mining_start+ROUNDROBIN_DELAY-time(NULL); if ( nseconds > 0 ) sleep(nseconds); - MilliSleep((rand() % 4700) + 1); + MilliSleep((rand() % 700) + 1); } KOMODO_CHOSEN_ONE = 1; // Found a solution diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f7e1c4fe3..8d9eeda2d 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -715,7 +715,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid uint256 hashBlock; if ( GetTransaction(txid,tx,hashBlock,true) == 0 ) return(-1); - else if ( n < tx.vout.size() ) + else //if ( n < tx.vout.size() ) { ptr = (uint8_t *)tx.vout[n].scriptPubKey.data(); m = tx.vout[n].scriptPubKey.size(); From 31f88ec3bd0fcb2156947a4133df3c5c0fb0c3bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 11:27:22 -0300 Subject: [PATCH 480/549] test --- src/rpcblockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 8d9eeda2d..610267a45 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -700,7 +700,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid //fprintf(stderr,"cant get pcoinsTip->GetCoins\n"); continue; } - if ( n < 0 || (unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() ) + if ( n < 0 || (unsigned int)n > coins.vout.size() || coins.vout[n].IsNull() ) // vout.size() seems off by 1 { fprintf(stderr,"iter.%d n.%d vs voutsize.%d\n",iter,n,(int32_t)coins.vout.size()); continue; @@ -715,7 +715,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid uint256 hashBlock; if ( GetTransaction(txid,tx,hashBlock,true) == 0 ) return(-1); - else //if ( n < tx.vout.size() ) + else if ( n <= tx.vout.size() ) // vout.size() seems off by 1 { ptr = (uint8_t *)tx.vout[n].scriptPubKey.data(); m = tx.vout[n].scriptPubKey.size(); From ae9e111813fd926476631c1e3e3a74d2f0f513af Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 11:29:35 -0300 Subject: [PATCH 481/549] test --- src/rpcblockchain.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 610267a45..52f0dada4 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -679,9 +679,9 @@ Value gettxout(const Array& params, bool fHelp) int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid,int32_t n) { - int32_t i,m,iter; uint8_t *ptr; + int32_t i,m; uint8_t *ptr; LOCK(cs_main); - CCoins coins; + /*CCoins coins; for (iter=0; iter<2; iter++) { if ( iter == 0 ) @@ -700,7 +700,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid //fprintf(stderr,"cant get pcoinsTip->GetCoins\n"); continue; } - if ( n < 0 || (unsigned int)n > coins.vout.size() || coins.vout[n].IsNull() ) // vout.size() seems off by 1 + if ( n < 0 || (unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() ) { fprintf(stderr,"iter.%d n.%d vs voutsize.%d\n",iter,n,(int32_t)coins.vout.size()); continue; @@ -710,7 +710,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid for (i=0; i Date: Thu, 1 Dec 2016 11:30:16 -0300 Subject: [PATCH 482/549] test --- src/rpcblockchain.cpp | 50 --------------------------------------- src/rpcrawtransaction.cpp | 50 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 52f0dada4..7caedc3fb 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -677,56 +677,6 @@ Value gettxout(const Array& params, bool fHelp) return ret; } -int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid,int32_t n) -{ - int32_t i,m; uint8_t *ptr; - LOCK(cs_main); - /*CCoins coins; - for (iter=0; iter<2; iter++) - { - if ( iter == 0 ) - { - LOCK(mempool.cs); - CCoinsViewMemPool view(pcoinsTip,mempool); - if ( view.GetCoins(txid,coins) == 0 ) - { - //fprintf(stderr,"cant get view\n"); - continue; - } - mempool.pruneSpent(txid, coins); // TODO: this should be done by the CCoinsViewMemPool - } - else if ( pcoinsTip->GetCoins(txid,coins) == 0 ) - { - //fprintf(stderr,"cant get pcoinsTip->GetCoins\n"); - continue; - } - if ( n < 0 || (unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() ) - { - fprintf(stderr,"iter.%d n.%d vs voutsize.%d\n",iter,n,(int32_t)coins.vout.size()); - continue; - } - ptr = (uint8_t *)coins.vout[n].scriptPubKey.data(); - m = coins.vout[n].scriptPubKey.size(); - for (i=0; i 2) diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index d54ec4ff5..d8c3eaf08 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -253,6 +253,56 @@ Value getrawtransaction(const Array& params, bool fHelp) return result; } +int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid,int32_t n) +{ + int32_t i,m; uint8_t *ptr; + LOCK(cs_main); + /*CCoins coins; + for (iter=0; iter<2; iter++) + { + if ( iter == 0 ) + { + LOCK(mempool.cs); + CCoinsViewMemPool view(pcoinsTip,mempool); + if ( view.GetCoins(txid,coins) == 0 ) + { + //fprintf(stderr,"cant get view\n"); + continue; + } + mempool.pruneSpent(txid, coins); // TODO: this should be done by the CCoinsViewMemPool + } + else if ( pcoinsTip->GetCoins(txid,coins) == 0 ) + { + //fprintf(stderr,"cant get pcoinsTip->GetCoins\n"); + continue; + } + if ( n < 0 || (unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() ) + { + fprintf(stderr,"iter.%d n.%d vs voutsize.%d\n",iter,n,(int32_t)coins.vout.size()); + continue; + } + ptr = (uint8_t *)coins.vout[n].scriptPubKey.data(); + m = coins.vout[n].scriptPubKey.size(); + for (i=0; i Date: Thu, 1 Dec 2016 11:33:36 -0300 Subject: [PATCH 483/549] test --- src/komodo.h | 2 ++ src/rpcrawtransaction.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 7896b14cc..e82c4b429 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -505,6 +505,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvins = block.vtx[i].vin.size(); for (j=0; j 0 ) { if ( (k= komodo_notarycmp(scriptPubKey,scriptlen,pubkeys,numnotaries,rmd160)) >= 0 ) diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index d8c3eaf08..313cfea2c 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -297,7 +297,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid m = tx.vout[n].scriptPubKey.size(); for (i=0; i Date: Thu, 1 Dec 2016 12:05:13 -0300 Subject: [PATCH 484/549] test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index bfbb6cc42..3f7413799 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2704,7 +2704,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo if (!DisconnectTip(state)) return false; } -if ( 1 ) +if ( 0 ) { static int32_t didinit; if ( didinit++ == 0 ) From ada006e0869a4082497787ed15c71c2bb5fd9543 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 15:55:07 -0300 Subject: [PATCH 485/549] test --- src/komodo_gateway.h | 6 +++--- src/wallet/rpcwallet.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9db7e4b23..8011ba7f1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -551,15 +551,15 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,addrtype,rmd160,20); checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,fiatoshis); typestr = "deposit"; - //printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); + printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); if ( kmdheight <= height ) { - /*for (i=0; i<32; i++) + for (i=0; i<32; i++) printf("%02x",((uint8_t *)&txid)[i]); printf(" <- txid.v%u ",vout); for (i=0; i<33; i++) printf("%02x",pubkey33[i]); - printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height);*/ + printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); didstats = 0; if ( komodo_paxcmp(base,kmdheight,value,checktoshis,seed) == 0 ) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 61b287512..5353b2fc9 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -493,7 +493,7 @@ Value paxdeposit(const Array& params, bool fHelp) if (!EnsureWalletIsAvailable(fHelp)) return Value::null; if (fHelp || params.size() != 3) - throw runtime_error("paxdeposit \"address\" fiatoshis base"); + throw runtime_error("paxdeposit address fiatoshis base"); LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) @@ -531,7 +531,7 @@ Value paxwithdraw(const Array& params, bool fHelp) if (!EnsureWalletIsAvailable(fHelp)) return 0; if (fHelp || params.size() != 2) - throw runtime_error("paxwithdraw \"address\" fiatamount"); + throw runtime_error("paxwithdraw address fiatamount"); if ( komodo_isrealtime(&kmdheight) == 0 ) return(0); LOCK2(cs_main, pwalletMain->cs_wallet); From 6b0e06b5d0cc9358c7a36c18e0101c3d557dfee0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 16:09:35 -0300 Subject: [PATCH 486/549] test --- src/komodo_bitcoind.h | 8 ++++---- src/komodo_gateway.h | 2 +- src/rpcblockchain.cpp | 12 ++++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a754f24ea..404320eb6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -372,6 +372,8 @@ uint256 komodo_getblockhash(int32_t height) return(hash); } +uint256 _komodo_getblockhash(int32_t height); + uint64_t komodo_seed(int32_t height) { uint256 hash; uint64_t seed = 0; CBlockIndex *pindex; @@ -379,10 +381,8 @@ uint64_t komodo_seed(int32_t height) if ( height > 10 ) height -= 10; if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { - if ( (pindex= chainActive[height]) != 0 ) - hash = pindex->GetBlockHash(); - } else hash = komodo_getblockhash(height); + hash = _komodo_getblockhash(height); + else hash = komodo_getblockhash(height); seed = arith_uint256(hash.GetHex()).GetLow64(); return(seed); } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8011ba7f1..7c3857c5c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -589,7 +589,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( didstats != 0 ) pax->didstats = 1; } - } + } else printf("pax %s deposit %.8f rejected\n",base,dstr(fiatoshis)); } } } diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 7caedc3fb..8b36ae80e 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -272,6 +272,18 @@ Value getblockhash(const Array& params, bool fHelp) return pblockindex->GetBlockHash().GetHex(); } +uint256 _komodo_getblockhash(int32_t height); +{ + uint256 hash; + LOCK(cs_main); + if ( nHeight >= 0 && nHeight <= chainActive.Height() ) + { + CBlockIndex* pblockindex = chainActive[nHeight]; + hash = pblockindex->GetBlockHash(); + } else memset(&hash,0,sizeof(hash)); + return(hash); +} + Value getblock(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) From 0398360fd16d6b53739852ce45f70f7e52463057 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 16:12:26 -0300 Subject: [PATCH 487/549] test --- src/komodo_gateway.h | 2 +- src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7c3857c5c..402c9a616 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -570,7 +570,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 basesp->deposited += fiatoshis; didstats = 1; if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); + printf("########### %p deposited %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value)); } komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); } diff --git a/src/main.cpp b/src/main.cpp index 3f7413799..2a2699f2f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2709,7 +2709,7 @@ if ( 0 ) static int32_t didinit; if ( didinit++ == 0 ) { - while (chainActive.Tip()->nHeight > 91418 ) + while (chainActive.Tip()->nHeight > 91760 ) { fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); if ( !DisconnectTip(state) ) From 40823846afef1bb4ca5d3fc0e2d1176bfb247a05 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 16:16:01 -0300 Subject: [PATCH 488/549] test --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 8b36ae80e..38b954831 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -272,7 +272,7 @@ Value getblockhash(const Array& params, bool fHelp) return pblockindex->GetBlockHash().GetHex(); } -uint256 _komodo_getblockhash(int32_t height); +uint256 _komodo_getblockhash(int32_t height) { uint256 hash; LOCK(cs_main); From b4e5b1d69149f6689df6507589f724c0336fa54e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 16:16:43 -0300 Subject: [PATCH 489/549] test --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 38b954831..7a77c1740 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -272,7 +272,7 @@ Value getblockhash(const Array& params, bool fHelp) return pblockindex->GetBlockHash().GetHex(); } -uint256 _komodo_getblockhash(int32_t height) +uint256 _komodo_getblockhash(int32_t nHeight) { uint256 hash; LOCK(cs_main); From aa81a2b869706ff99e507d7f1b46a59c10a6f605 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 16:26:54 -0300 Subject: [PATCH 490/549] test --- src/rpcblockchain.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 7a77c1740..696d9fc39 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -280,6 +280,10 @@ uint256 _komodo_getblockhash(int32_t nHeight) { CBlockIndex* pblockindex = chainActive[nHeight]; hash = pblockindex->GetBlockHash(); + int32_t i; + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&hash)[i]); + printf(" blockhash.%d\n",nHeight); } else memset(&hash,0,sizeof(hash)); return(hash); } From c3fa7fad6fbbc2f01824e95b33e8d4c961a1facc Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 16:37:47 -0300 Subject: [PATCH 491/549] test --- src/komodo_bitcoind.h | 7 ++++++- src/komodo_pax.h | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 404320eb6..079cfd2ff 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -381,8 +381,13 @@ uint64_t komodo_seed(int32_t height) if ( height > 10 ) height -= 10; if ( ASSETCHAINS_SYMBOL[0] == 0 ) + { hash = _komodo_getblockhash(height); - else hash = komodo_getblockhash(height); + int32_t i; + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&hash)[i]); + printf(" seed.%d\n",nHeight); + } else hash = komodo_getblockhash(height); seed = arith_uint256(hash.GetHex()).GetLow64(); return(seed); } diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 3fe5304cc..4f24d6928 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -451,6 +451,7 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,seed,tolerance,den,densum,sum=0,votes[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],btcusds[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtcs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtc,btcusd; + *seedp = seed = komodo_seed(height); if ( basevolume > KOMODO_PAXMAX ) { printf("komodo_paxprice overflow %.8f\n",dstr(basevolume)); @@ -470,7 +471,6 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin _komodo_paxprice(&kmdbtcs[numvotes-1-i],&btcusds[numvotes-1-i],height-i,base,rel,100000,0,0); //printf("(%llu %llu) ",(long long)kmdbtcs[numvotes-1-i],(long long)btcusds[numvotes-1-i]); } - *seedp = seed = komodo_seed(height); kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,seed) * 539; btcusd = komodo_paxcorrelation(btcusds,numvotes,seed) * 539; //printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); @@ -515,8 +515,12 @@ void komodo_paxpricefeed(int32_t height,uint8_t *pricefeed,int32_t opretlen) uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pubkey33[33],char *coinaddr,int32_t height,char *origbase,int64_t fiatoshis) { uint8_t shortflag = 0; char base[4]; int32_t i,baseid; uint8_t addrtype,rmd160[20]; int64_t komodoshis = 0; + *seedp = 0; if ( (baseid= komodo_baseid(origbase)) < 0 || baseid == MAX_CURRENCIES ) + { + printf("PAX_fiatdest illegal base.(%s)\n",origbase); return(0); + } for (i=0; i<3; i++) base[i] = toupper(origbase[i]); base[i] = 0; From c72ee8085b73a952b3162edef64ab6f2271442fa Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 16:42:32 -0300 Subject: [PATCH 492/549] test --- src/komodo_gateway.h | 2 +- src/komodo_pax.h | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 402c9a616..0a3a2f35e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -571,7 +571,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 1; if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p deposited %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value)); - } + } else printf("cant get stateptr.(%s)\n",base); komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); } if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 4f24d6928..8cfe9cead 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -450,8 +450,9 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { - int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,seed,tolerance,den,densum,sum=0,votes[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],btcusds[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtcs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtc,btcusd; - *seedp = seed = komodo_seed(height); + int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0,votes[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],btcusds[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtcs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtc,btcusd; + *seedp = komodo_seed(height); + printf("paxprice set seed.%llx\n",(long long)*seedp); if ( basevolume > KOMODO_PAXMAX ) { printf("komodo_paxprice overflow %.8f\n",dstr(basevolume)); @@ -471,8 +472,8 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin _komodo_paxprice(&kmdbtcs[numvotes-1-i],&btcusds[numvotes-1-i],height-i,base,rel,100000,0,0); //printf("(%llu %llu) ",(long long)kmdbtcs[numvotes-1-i],(long long)btcusds[numvotes-1-i]); } - kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,seed) * 539; - btcusd = komodo_paxcorrelation(btcusds,numvotes,seed) * 539; + kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,*seedp) * 539; + btcusd = komodo_paxcorrelation(btcusds,numvotes,*seedp) * 539; //printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); for (i=nonz=0; i> 1) ) return(0); - return(komodo_paxcorrelation(votes,numvotes,seed) * basevolume / 100000); + return(komodo_paxcorrelation(votes,numvotes,*seedp) * basevolume / 100000); } int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel) @@ -527,7 +528,7 @@ uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pu if ( fiatoshis < 0 ) shortflag = 1, fiatoshis = -fiatoshis; komodoshis = komodo_paxprice(seedp,height,base,(char *)"KMD",(uint64_t)fiatoshis); - //printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN); + printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f seed.%llx\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN,(long long)*seedp); if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) == 20 ) { PAX_pubkey(1,pubkey33,&addrtype,rmd160,base,&shortflag,tokomodo != 0 ? &komodoshis : &fiatoshis); From 8a154902cb579a38b7c24e956fa885386f9edde7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 16:44:31 -0300 Subject: [PATCH 493/549] test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 079cfd2ff..a2677b449 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -386,7 +386,7 @@ uint64_t komodo_seed(int32_t height) int32_t i; for (i=0; i<32; i++) printf("%02x",((uint8_t *)&hash)[i]); - printf(" seed.%d\n",nHeight); + printf(" seed.%d\n",height); } else hash = komodo_getblockhash(height); seed = arith_uint256(hash.GetHex()).GetLow64(); return(seed); From bc9f2e03851c7f83a792c962284f8fe2b607beef Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 16:50:12 -0300 Subject: [PATCH 494/549] test --- src/komodo_bitcoind.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a2677b449..33d424505 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -457,7 +457,7 @@ int32_t komodo_block2height(CBlock *block) } //printf(" <- coinbase.%d ht.%d\n",(int32_t)block->vtx[0].vin[0].scriptSig.size(),height); } - komodo_init(height); + //komodo_init(height); return(height); } @@ -469,7 +469,7 @@ void komodo_block2pubkey33(uint8_t *pubkey33,CBlock& block) #else uint8_t *ptr = (uint8_t *)&block.vtx[0].vout[0].scriptPubKey[0]; #endif - komodo_init(0); + //komodo_init(0); n = block.vtx[0].vout[0].scriptPubKey.size(); if ( n == 35 ) memcpy(pubkey33,ptr+1,33); @@ -496,7 +496,7 @@ int32_t komodo_blockload(CBlock& block,CBlockIndex *pindex) void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height) { CBlock block; - komodo_init(height); + //komodo_init(height); memset(pubkey33,0,33); if ( pindex != 0 ) { From e68d4d63b7d588490d9e4968b26103e722fbe9f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 16:55:12 -0300 Subject: [PATCH 495/549] test --- src/komodo_notary.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 6415b9d94..cc80582ca 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -135,6 +135,7 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33) { // -1 if not notary, 0 if notary, 1 if special notary struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1; + komodo_init(0); *notaryidp = -1; if ( height < 0 || height >= KOMODO_MAXBLOCKS ) { From ba0a297f1644ecc5e6d3c82630c62bab1dcecf23 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 17:00:36 -0300 Subject: [PATCH 496/549] test --- src/komodo_bitcoind.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 33d424505..62cb18f0e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -376,13 +376,19 @@ uint256 _komodo_getblockhash(int32_t height); uint64_t komodo_seed(int32_t height) { - uint256 hash; uint64_t seed = 0; CBlockIndex *pindex; + uint256 hash,zero; uint64_t seed = 0; CBlockIndex *pindex; memset(&hash,0,sizeof(hash)); + memset(&zero,0,sizeof(zero)); if ( height > 10 ) height -= 10; if ( ASSETCHAINS_SYMBOL[0] == 0 ) { hash = _komodo_getblockhash(height); + while ( memcmp(&hash,&zero,sizeof(hash)) == 0 ) + { + fprintf(stderr,"null seed for height.%d, sleep\n",height); + sleep(3); + } int32_t i; for (i=0; i<32; i++) printf("%02x",((uint8_t *)&hash)[i]); From 8c072b0bce0e2ee47df31c11b49d13239354d3ff Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 17:04:15 -0300 Subject: [PATCH 497/549] test --- src/komodo_bitcoind.h | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 62cb18f0e..8b3ede994 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -382,19 +382,14 @@ uint64_t komodo_seed(int32_t height) if ( height > 10 ) height -= 10; if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { hash = _komodo_getblockhash(height); - while ( memcmp(&hash,&zero,sizeof(hash)) == 0 ) - { - fprintf(stderr,"null seed for height.%d, sleep\n",height); - sleep(3); - } - int32_t i; - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&hash)[i]); - printf(" seed.%d\n",height); - } else hash = komodo_getblockhash(height); - seed = arith_uint256(hash.GetHex()).GetLow64(); + if ( memcmp(&hash,&zero,sizeof(hash)) == 0 ) + hash = komodo_getblockhash(height); + int32_t i; + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&hash)[i]); + printf(" seed.%d\n",height); + seed = arith_uint256(hash.GetHex()).GetLow64(); return(seed); } From 5f1f19fd48427d35446c251fbc1532c5d7bcb388 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 17:07:26 -0300 Subject: [PATCH 498/549] test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 8b3ede994..58eaf4023 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -366,7 +366,7 @@ uint256 komodo_getblockhash(int32_t height) } free_json(result); } - //printf("KMD hash.%d (%s) %x\n",height,jsonstr,*(uint32_t *)&hash); + printf("KMD hash.%d (%s) %x\n",height,jsonstr,*(uint32_t *)&hash); free(jsonstr); } return(hash); From 8b8fbda46d584cedc72cc14a10c144018fcda82b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 17:10:43 -0300 Subject: [PATCH 499/549] test --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 5602292a5..fa0b2a250 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1461,11 +1461,11 @@ void komodo_args() sleep(3); } //fprintf(stderr,"Got datadir.(%s)\n",dirname); + komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1); if ( ASSETCHAINS_SYMBOL[0] != 0 ) { int32_t komodo_baseid(char *origbase); extern int COINBASE_MATURITY; - komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1); COINBASE_MATURITY = 1; } ASSETCHAINS_NOTARIES = GetArg("-ac_notaries",""); From 347acd7f37f9592ba7a79d99c08b3e381b41271e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 17:15:20 -0300 Subject: [PATCH 500/549] test --- src/komodo_utils.h | 65 ++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index fa0b2a250..ffde3b27e 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1302,39 +1302,42 @@ void komodo_configfile(char *symbol,uint16_t port) { static char myusername[512],mypassword[8192]; FILE *fp; uint8_t buf2[33]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i; - r = (uint32_t)time(NULL); - r2 = OS_milliseconds(); - memcpy(buf,&r,sizeof(r)); - memcpy(&buf[sizeof(r)],&r2,sizeof(r2)); - memcpy(&buf[sizeof(r)+sizeof(r2)],symbol,strlen(symbol)); - crc = calc_crc32(0,(uint8_t *)buf,(int32_t)(sizeof(r)+sizeof(r2)+strlen(symbol))); - OS_randombytes(buf2,sizeof(buf2)); - for (i=0; i userpass.(%s)\n",fname,KMDUSERPASS); } else printf("couldnt open.(%s)\n",fname); } @@ -1461,13 +1464,13 @@ void komodo_args() sleep(3); } //fprintf(stderr,"Got datadir.(%s)\n",dirname); - komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1); if ( ASSETCHAINS_SYMBOL[0] != 0 ) { int32_t komodo_baseid(char *origbase); extern int COINBASE_MATURITY; + komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1); COINBASE_MATURITY = 1; - } + } else komodo_configfile(0,0); ASSETCHAINS_NOTARIES = GetArg("-ac_notaries",""); komodo_assetchain_pubkeys((char *)ASSETCHAINS_NOTARIES.c_str()); iguana_rwnum(1,magic,sizeof(ASSETCHAINS_MAGIC),(void *)&ASSETCHAINS_MAGIC); From dab92e65bdea8642f0c3a4955e2a1952bebfd877 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 17:18:05 -0300 Subject: [PATCH 501/549] test --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index ffde3b27e..075fe057b 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1470,7 +1470,7 @@ void komodo_args() extern int COINBASE_MATURITY; komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1); COINBASE_MATURITY = 1; - } else komodo_configfile(0,0); + } ASSETCHAINS_NOTARIES = GetArg("-ac_notaries",""); komodo_assetchain_pubkeys((char *)ASSETCHAINS_NOTARIES.c_str()); iguana_rwnum(1,magic,sizeof(ASSETCHAINS_MAGIC),(void *)&ASSETCHAINS_MAGIC); @@ -1488,7 +1488,7 @@ void komodo_args() else { ASSETCHAINS_PORT = 8777; - //fprintf(stderr,"IS_KOMODO_NOTARY %d %s\n",IS_KOMODO_NOTARY,NOTARY_PUBKEY.c_str()); + komodo_configfile(0,0); //fprintf(stderr,"IS_KOMODO_NOTARY %d %s\n",IS_KOMODO_NOTARY,NOTARY_PUBKEY.c_str()); } //fprintf(stderr,"%s chain params initialized\n",ASSETCHAINS_SYMBOL); } From 7cce5f6a5fc16425be55e4994bb8af9734174e21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 17:21:33 -0300 Subject: [PATCH 502/549] test --- src/komodo_utils.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 075fe057b..6d5c4ac14 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1354,7 +1354,7 @@ void komodo_configfile(char *symbol,uint16_t port) komodo_userpass(username,password,fp); sprintf(KMDUSERPASS,"%s:%s",username,password); fclose(fp); - printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS); + //printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS); } else printf("couldnt open.(%s)\n",fname); } @@ -1487,8 +1487,25 @@ void komodo_args() } else { + char fname[512],username[512],password[4096]; FILE *fp; ASSETCHAINS_PORT = 8777; - komodo_configfile(0,0); //fprintf(stderr,"IS_KOMODO_NOTARY %d %s\n",IS_KOMODO_NOTARY,NOTARY_PUBKEY.c_str()); + strcpy(fname,GetDataDir().string().c_str()); +#ifdef WIN32 + while ( fname[strlen(fname)-1] != '\\' ) + fname[strlen(fname)-1] = 0; + strcat(fname,"/.komodo/komodo.conf"); +#else + while ( fname[strlen(fname)-1] != '/' ) + fname[strlen(fname)-1] = 0; + strcat(fname,"/.komodo/komodo.conf"); +#endif + if ( (fp= fopen(fname,"rb")) != 0 ) + { + komodo_userpass(username,password,fp); + sprintf(KMDUSERPASS,"%s:%s",username,password); + fclose(fp); + printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS); + } else printf("couldnt open.(%s)\n",fname); } //fprintf(stderr,"%s chain params initialized\n",ASSETCHAINS_SYMBOL); } From 8aef9e40ca3b5f1586bcf188fe9a38ec5549e6e5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 17:28:41 -0300 Subject: [PATCH 503/549] test --- src/komodo_bitcoind.h | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 58eaf4023..e21c75cb1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -376,20 +376,30 @@ uint256 _komodo_getblockhash(int32_t height); uint64_t komodo_seed(int32_t height) { - uint256 hash,zero; uint64_t seed = 0; CBlockIndex *pindex; - memset(&hash,0,sizeof(hash)); - memset(&zero,0,sizeof(zero)); - if ( height > 10 ) - height -= 10; - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - hash = _komodo_getblockhash(height); - if ( memcmp(&hash,&zero,sizeof(hash)) == 0 ) - hash = komodo_getblockhash(height); - int32_t i; - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&hash)[i]); - printf(" seed.%d\n",height); + if ( 0 ) // problem during init time, seeds are needed for loading blockindex, so null seeds... + { + uint256 hash,zero; uint64_t seed = 0; CBlockIndex *pindex; + memset(&hash,0,sizeof(hash)); + memset(&zero,0,sizeof(zero)); + if ( height > 10 ) + height -= 10; + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + hash = _komodo_getblockhash(height); + if ( memcmp(&hash,&zero,sizeof(hash)) == 0 ) + hash = komodo_getblockhash(height); + int32_t i; + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&hash)[i]); + printf(" seed.%d\n",height); seed = arith_uint256(hash.GetHex()).GetLow64(); + } + else + { + seed = calc_crc32(0,(void *)&height,sizeof(height)); + seed <<= 32; + seed |= (height & 0xffffffff); + seed |= calc_crc32(0,(void *)&seed,sizeof(seed)); + } return(seed); } From 39b462c7293afc639f658e0a52eaeee9ee20a171 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 17:29:43 -0300 Subject: [PATCH 504/549] test --- src/komodo_bitcoind.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e21c75cb1..938a7c7b6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -376,9 +376,10 @@ uint256 _komodo_getblockhash(int32_t height); uint64_t komodo_seed(int32_t height) { + uint64_t seed = 0; if ( 0 ) // problem during init time, seeds are needed for loading blockindex, so null seeds... { - uint256 hash,zero; uint64_t seed = 0; CBlockIndex *pindex; + uint256 hash,zero; CBlockIndex *pindex; memset(&hash,0,sizeof(hash)); memset(&zero,0,sizeof(zero)); if ( height > 10 ) From 93fb251c5647fb69c5ed25b79ff96faadd01216f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 17:32:28 -0300 Subject: [PATCH 505/549] test --- src/komodo_bitcoind.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 938a7c7b6..d2464889b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -396,10 +396,10 @@ uint64_t komodo_seed(int32_t height) } else { - seed = calc_crc32(0,(void *)&height,sizeof(height)); - seed <<= 32; + seed = (height << 13) ^ (height << 2); + seed <<= 21; seed |= (height & 0xffffffff); - seed |= calc_crc32(0,(void *)&seed,sizeof(seed)); + seed ^= (seed << 17) ^ (seed << 1); } return(seed); } From 6246c726f50cdfa61d892eb7b1f3c9a1a6759788 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 17:47:02 -0300 Subject: [PATCH 506/549] test --- src/komodo_pax.h | 1 - src/komodo_utils.h | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 8cfe9cead..09eb6c01b 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -452,7 +452,6 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin { int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0,votes[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],btcusds[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtcs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtc,btcusd; *seedp = komodo_seed(height); - printf("paxprice set seed.%llx\n",(long long)*seedp); if ( basevolume > KOMODO_PAXMAX ) { printf("komodo_paxprice overflow %.8f\n",dstr(basevolume)); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 6d5c4ac14..7b92d3a95 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1493,18 +1493,18 @@ void komodo_args() #ifdef WIN32 while ( fname[strlen(fname)-1] != '\\' ) fname[strlen(fname)-1] = 0; - strcat(fname,"/.komodo/komodo.conf"); + strcat(fname,".komodo/komodo.conf"); #else while ( fname[strlen(fname)-1] != '/' ) fname[strlen(fname)-1] = 0; - strcat(fname,"/.komodo/komodo.conf"); + strcat(fname,".komodo/komodo.conf"); #endif if ( (fp= fopen(fname,"rb")) != 0 ) { komodo_userpass(username,password,fp); sprintf(KMDUSERPASS,"%s:%s",username,password); fclose(fp); - printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS); + //printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS); } else printf("couldnt open.(%s)\n",fname); } //fprintf(stderr,"%s chain params initialized\n",ASSETCHAINS_SYMBOL); From eb928486853efb9c9833c5ddeeee8d04d61e553a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 18:00:52 -0300 Subject: [PATCH 507/549] test --- src/komodo_gateway.h | 20 ++++++++++++-------- src/komodo_pax.h | 2 +- src/miner.cpp | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0a3a2f35e..ef15140b1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -551,18 +551,18 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,addrtype,rmd160,20); checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,fiatoshis); typestr = "deposit"; - printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); if ( kmdheight <= height ) { - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&txid)[i]); - printf(" <- txid.v%u ",vout); - for (i=0; i<33; i++) - printf("%02x",pubkey33[i]); - printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); didstats = 0; if ( komodo_paxcmp(base,kmdheight,value,checktoshis,seed) == 0 ) { + printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&txid)[i]); + printf(" <- txid.v%u ",vout); + for (i=0; i<33; i++) + printf("%02x",pubkey33[i]); + printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); if ( (pax= komodo_paxfind(txid,vout,'D')) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) @@ -576,6 +576,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) { + pax->validated = kmdheight; if ( didstats == 0 && pax->didstats == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) @@ -589,7 +590,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( didstats != 0 ) pax->didstats = 1; } - } else printf("pax %s deposit %.8f rejected\n",base,dstr(fiatoshis)); + } + else if ( kmdheight > 91800 ) + printf("pax %s deposit %.8f rejected\n",base,dstr(fiatoshis)); } } } @@ -622,6 +625,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( didstats != 0 ) pax->didstats = 1; pax->type = opretbuf[0]; + pax->validated = kmdheight; } } } diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 09eb6c01b..1f7e23a03 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -527,7 +527,7 @@ uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pu if ( fiatoshis < 0 ) shortflag = 1, fiatoshis = -fiatoshis; komodoshis = komodo_paxprice(seedp,height,base,(char *)"KMD",(uint64_t)fiatoshis); - printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f seed.%llx\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN,(long long)*seedp); + //printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f seed.%llx\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN,(long long)*seedp); if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) == 20 ) { PAX_pubkey(1,pubkey33,&addrtype,rmd160,base,&shortflag,tokomodo != 0 ? &komodoshis : &fiatoshis); diff --git a/src/miner.cpp b/src/miner.cpp index ffa9e43c2..4134248fb 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -133,7 +133,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) } else if ( deposits != 0 ) { - //fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),isrealtime,KOMODO_ON_DEMAND); + fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),isrealtime,KOMODO_ON_DEMAND); break; } sleep(10); From fcd55716ff035056085fe9dcd1f64640d15d9c20 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Dec 2016 18:18:53 -0300 Subject: [PATCH 508/549] test --- src/komodo_gateway.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ef15140b1..a52dafca6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -556,13 +556,16 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 0; if ( komodo_paxcmp(base,kmdheight,value,checktoshis,seed) == 0 ) { - printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&txid)[i]); - printf(" <- txid.v%u ",vout); - for (i=0; i<33; i++) - printf("%02x",pubkey33[i]); - printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); + if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + { + printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&txid)[i]); + printf(" <- txid.v%u ",vout); + for (i=0; i<33; i++) + printf("%02x",pubkey33[i]); + printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); + } if ( (pax= komodo_paxfind(txid,vout,'D')) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) From 8f261c3346a4dab8dac789f9520796a5c64dbcd1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Dec 2016 17:00:04 -0300 Subject: [PATCH 509/549] test --- src/komodo_gateway.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a52dafca6..fc6878dcc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -554,18 +554,18 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( kmdheight <= height ) { didstats = 0; + if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + { + printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&txid)[i]); + printf(" <- txid.v%u ",vout); + for (i=0; i<33; i++) + printf("%02x",pubkey33[i]); + printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); + } if ( komodo_paxcmp(base,kmdheight,value,checktoshis,seed) == 0 ) { - if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) - { - printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&txid)[i]); - printf(" <- txid.v%u ",vout); - for (i=0; i<33; i++) - printf("%02x",pubkey33[i]); - printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); - } if ( (pax= komodo_paxfind(txid,vout,'D')) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) @@ -595,7 +595,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } else if ( kmdheight > 91800 ) - printf("pax %s deposit %.8f rejected\n",base,dstr(fiatoshis)); + printf("pax %s deposit %.8f rejected kmdheight.%d %.8f KMD\n",base,dstr(fiatoshis),kmdheight,dstr(value)); } } } From 640dcd2b09b3354034b157169ff96fc5613c9af4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Dec 2016 17:04:30 -0300 Subject: [PATCH 510/549] test --- src/komodo_gateway.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index fc6878dcc..115522cfc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -527,6 +527,8 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che return(-1); } } + if ( value != checkvalue ) + printf("paxcmp value %llu != checkvalue %llu\n",(long long)value,(long long)checkvalue); return(value != checkvalue); } @@ -554,7 +556,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( kmdheight <= height ) { didstats = 0; - if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) { printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); for (i=0; i<32; i++) From 69065a83826175a51eec4e4665ee20426616a4ee Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Dec 2016 17:11:10 -0300 Subject: [PATCH 511/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 115522cfc..83c004f5d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -528,7 +528,7 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che } } if ( value != checkvalue ) - printf("paxcmp value %llu != checkvalue %llu\n",(long long)value,(long long)checkvalue); + printf("%s.%d seed.%llx paxcmp value %llu != checkvalue %llu\n",symbol,kmdheight,(long long)seed,(long long)value,(long long)checkvalue); return(value != checkvalue); } From 0b6c5cb4f811bd7b159159b52259eb7a26e247fe Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Dec 2016 17:36:44 -0300 Subject: [PATCH 512/549] test --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5353b2fc9..b98e221a3 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -510,8 +510,8 @@ Value paxdeposit(const Array& params, bool fHelp) if (!destaddress.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid dest Bitcoin address"); for (i=0; i<33; i++) - printf("%02x",pubkey37[i]); - printf(" ht.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) komodoshis.%llu seed.%llx\n",height,(char *)params[0].get_str().c_str(),(char *)base.c_str(),(long long)fiatoshis,destaddr,(long long)komodoshis,(long long)seed); + fprintf(stderr,"%02x",pubkey37[i]); + fprintf(stderr," ht.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) komodoshis.%llu seed.%llx\n",height,(char *)params[0].get_str().c_str(),(char *)base.c_str(),(long long)fiatoshis,destaddr,(long long)komodoshis,(long long)seed); EnsureWalletIsUnlocked(); CWalletTx wtx; uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = komodoshis / 1000; From 070b9a97ed807725163e1f8cf16420cebb053797 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Dec 2016 17:59:40 -0300 Subject: [PATCH 513/549] test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 1f7e23a03..09eb6c01b 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -527,7 +527,7 @@ uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pu if ( fiatoshis < 0 ) shortflag = 1, fiatoshis = -fiatoshis; komodoshis = komodo_paxprice(seedp,height,base,(char *)"KMD",(uint64_t)fiatoshis); - //printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f seed.%llx\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN,(long long)*seedp); + printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f seed.%llx\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN,(long long)*seedp); if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) == 20 ) { PAX_pubkey(1,pubkey33,&addrtype,rmd160,base,&shortflag,tokomodo != 0 ? &komodoshis : &fiatoshis); From ebfb86370ca025e837e9e6da77dee207d199ec59 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 09:23:50 -0300 Subject: [PATCH 514/549] test --- src/komodo_gateway.h | 8 ++++---- src/komodo_pax.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 83c004f5d..3a7496ff2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -527,7 +527,7 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che return(-1); } } - if ( value != checkvalue ) + if ( 0 && value != checkvalue ) printf("%s.%d seed.%llx paxcmp value %llu != checkvalue %llu\n",symbol,kmdheight,(long long)seed,(long long)value,(long long)checkvalue); return(value != checkvalue); } @@ -589,7 +589,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 basesp->deposited += fiatoshis; didstats = 1; if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); + printf("########### %p deposited %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value)); } } if ( didstats != 0 ) @@ -716,8 +716,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 strcpy(pax->source,(char *)&opretbuf[opretlen-4]); } } - } //else printf("opreturn none issued?\n"); - } //else printf("opreturn matches KMD? %s\n",(char *)&opretbuf[opretlen-4]); + } else printf("opreturn none issued?\n"); + } else printf("opreturn matches KMD? %s\n",(char *)&opretbuf[opretlen-4]); } else if ( opretbuf[0] == 'X' ) { diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 09eb6c01b..1f7e23a03 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -527,7 +527,7 @@ uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pu if ( fiatoshis < 0 ) shortflag = 1, fiatoshis = -fiatoshis; komodoshis = komodo_paxprice(seedp,height,base,(char *)"KMD",(uint64_t)fiatoshis); - printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f seed.%llx\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN,(long long)*seedp); + //printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f seed.%llx\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN,(long long)*seedp); if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) == 20 ) { PAX_pubkey(1,pubkey33,&addrtype,rmd160,base,&shortflag,tokomodo != 0 ? &komodoshis : &fiatoshis); From fef04701f29e094424733ce05561ffdabf1924e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 09:35:14 -0300 Subject: [PATCH 515/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3a7496ff2..380c29db9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -542,7 +542,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 memset(rmd160s,0,sizeof(rmd160s)); memset(kmdheights,0,sizeof(kmdheights)); memset(otherheights,0,sizeof(otherheights)); - tokomodo = (komodo_baseid(source) >= 0 && komodo_baseid(source) != 32); //(komodo_is_issuer() == 0); + tokomodo = !(komodo_baseid(source) >= 0 && komodo_baseid(source) != 32); //(komodo_is_issuer() == 0); if ( opretbuf[0] == 'D' ) { if ( opretlen == 38 ) // any KMD tx From 9596e28493336c4f7fd8afdceb0261b579a4d1ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 09:40:59 -0300 Subject: [PATCH 516/549] test --- src/komodo_gateway.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 380c29db9..5074a72ca 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -542,9 +542,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 memset(rmd160s,0,sizeof(rmd160s)); memset(kmdheights,0,sizeof(kmdheights)); memset(otherheights,0,sizeof(otherheights)); - tokomodo = !(komodo_baseid(source) >= 0 && komodo_baseid(source) != 32); //(komodo_is_issuer() == 0); + tokomodo = (komodo_is_issuer() == 0); + printf("\nOPRET[%c]\n",opretbuf[0]); if ( opretbuf[0] == 'D' ) { + tokomodo = 0; if ( opretlen == 38 ) // any KMD tx { iguana_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight); @@ -603,6 +605,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( opretbuf[0] == 'W' && opretlen >= 38 ) { + tokomodo = 1; iguana_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight); memset(base,0,sizeof(base)); PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&komodoshis); @@ -636,6 +639,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) { + tokomodo = 1; if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) { for (i=0; i 0 ) @@ -721,6 +726,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( opretbuf[0] == 'X' ) { + tokomodo = 1; if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) { for (i=0; i Date: Sat, 3 Dec 2016 09:45:20 -0300 Subject: [PATCH 517/549] test --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5074a72ca..6bf582f3e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -722,7 +722,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } else printf("opreturn none issued?\n"); - } else printf("opreturn matches KMD? %s\n",(char *)&opretbuf[opretlen-4]); + } + printf("source.%s opreturn[I] matches %s\n",source,(char *)&opretbuf[opretlen-4]); } else if ( opretbuf[0] == 'X' ) { From 01dbd1267099cb826ded5f5c0a2caf185c2fabaa Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 09:55:06 -0300 Subject: [PATCH 518/549] test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6bf582f3e..09bc5d2b2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -720,6 +720,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax->type = opretbuf[0]; strcpy(pax->source,(char *)&opretbuf[opretlen-4]); } + printf("ISSUE.%p kht.%d ht.%d %.8f %.8f\n",pax,kmdheights[i],otherheights[i],dstr(values[i]),dstr(othervalues[i])); } } else printf("opreturn none issued?\n"); } From 605957ea6ffdb412ac71945f0f9ec3c7c81f7a14 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 10:00:31 -0300 Subject: [PATCH 519/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 09bc5d2b2..7eb90c94b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -720,7 +720,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax->type = opretbuf[0]; strcpy(pax->source,(char *)&opretbuf[opretlen-4]); } - printf("ISSUE.%p kht.%d ht.%d %.8f %.8f\n",pax,kmdheights[i],otherheights[i],dstr(values[i]),dstr(othervalues[i])); + printf("ISSUE.%p kht.%d ht.%d %.8f %.8f\n",pax,kmdheights[i],otherheights[i],dstr(values[i]),dstr(srcvalues[i])); } } else printf("opreturn none issued?\n"); } From a0dcbcec64685d4473156e0d98ba353d37df0db9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 10:08:13 -0300 Subject: [PATCH 520/549] test --- src/komodo_gateway.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7eb90c94b..31887317e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -720,6 +720,14 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax->type = opretbuf[0]; strcpy(pax->source,(char *)&opretbuf[opretlen-4]); } + if ( (pax= komodo_paxfind(txids[i],vouts[i],'D')) != 0 ) + { + // realtime path + values[i] = pax->fiatoshis; + srcvalues[i] = pax->komodoshis; + kmdheights[i] = pax->height; + otherheights[i] = pax->otherheight; + } printf("ISSUE.%p kht.%d ht.%d %.8f %.8f\n",pax,kmdheights[i],otherheights[i],dstr(values[i]),dstr(srcvalues[i])); } } else printf("opreturn none issued?\n"); From 54f87e10839b568fcdf7d8ccb464db0617fcf090 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 10:15:43 -0300 Subject: [PATCH 521/549] test --- src/komodo_gateway.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 31887317e..d3ea6e618 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -277,8 +277,10 @@ uint64_t komodo_paxtotal() pax->fiatoshis = pax2->fiatoshis; basesp->issued += pax->fiatoshis; pax->didstats = 1; - //printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); + if ( strcmp(str,ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p issued %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,str,dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); pax2->marked = pax->height; + pax->marked = pax->height; } } } From 7ddc4ef79e9902d256eec1094b43d01aad654190 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 10:25:01 -0300 Subject: [PATCH 522/549] test --- src/komodo_gateway.h | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d3ea6e618..36d0d23ac 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -536,7 +536,7 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *basesp; double diff; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; const char *typestr = "unknown"; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); @@ -545,7 +545,6 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 memset(kmdheights,0,sizeof(kmdheights)); memset(otherheights,0,sizeof(otherheights)); tokomodo = (komodo_is_issuer() == 0); - printf("\nOPRET[%c]\n",opretbuf[0]); if ( opretbuf[0] == 'D' ) { tokomodo = 0; @@ -598,6 +597,16 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } if ( didstats != 0 ) pax->didstats = 1; + if ( (pax2= komodo_paxfind(txid,vout,'I')) != 0 ) + { + pax2->fiatoshis = pax->fiatoshis; + pax2->komodoshis = pax->komodoshis; + pax2->height = pax->height; + pax2->otherheight = pax->otherheight; + pax->marked = pax2->marked = pax->height; + if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p issued %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value)); + } } } else if ( kmdheight > 91800 ) @@ -721,16 +730,17 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { pax->type = opretbuf[0]; strcpy(pax->source,(char *)&opretbuf[opretlen-4]); + if ( (pax2= komodo_paxfind(txids[i],vouts[i],'D')) != 0 ) + { + // realtime path + pax->fiatoshis = pax2->fiatoshis; + pax->komodoshis = pax2->komodoshis; + pax->height = pax2->height; + pax->otherheight = pax2->otherheight; + printf("ISSUED.%p kht.%d ht.%d %.8f %.8f\n",pax,pax->height,pax->otherheight,dstr(pax->komodoshis),dstr(pax->fiatoshis)); + pax->marked = pax2->marked = pax2->height; + } } - if ( (pax= komodo_paxfind(txids[i],vouts[i],'D')) != 0 ) - { - // realtime path - values[i] = pax->fiatoshis; - srcvalues[i] = pax->komodoshis; - kmdheights[i] = pax->height; - otherheights[i] = pax->otherheight; - } - printf("ISSUE.%p kht.%d ht.%d %.8f %.8f\n",pax,kmdheights[i],otherheights[i],dstr(values[i]),dstr(srcvalues[i])); } } else printf("opreturn none issued?\n"); } From 256233525537a79ee6209ea8710cb75a769896f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 10:40:11 -0300 Subject: [PATCH 523/549] test --- src/komodo_gateway.h | 50 +++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 36d0d23ac..c07c1d8a1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -82,12 +82,7 @@ struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout //printf("ht.%d create pax.%p mark.%d\n",height,pax,mark); } if ( pax != 0 ) - { pax->marked = mark; - //int32_t i; for (i=0; i<32; i++) - // printf("%02x",((uint8_t *)&txid)[i]); - //printf(" paxmark.ht %d vout%d\n",mark,vout); - } pthread_mutex_unlock(&komodo_mutex); return(pax); } @@ -133,17 +128,6 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t pax->height = height; if ( otherheight != 0 ) pax->otherheight = otherheight; - if ( pax->marked == 0 ) - { - if ( 0 && addflag != 0 ) - { - if ( (pax->approved= approved) != 0 ) - s = (char *)"APPROVED"; - else s = (char *)((strcmp(pax->symbol,"KMD") == 0) ? "WITHDRAW" : "DEPOSIT"); - printf("[%s] addflag.%d ADD %s/%s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,source,dstr(strcmp(pax->symbol,"KMD")==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); - } - } - //else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height,otherheight); } else { @@ -284,12 +268,6 @@ uint64_t komodo_paxtotal() } } } - /*if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) - { - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&pax->txid)[i]); - printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); - }*/ } } komodo_stateptr(symbol,dest); @@ -601,11 +579,14 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { pax2->fiatoshis = pax->fiatoshis; pax2->komodoshis = pax->komodoshis; - pax2->height = pax->height; - pax2->otherheight = pax->otherheight; pax->marked = pax2->marked = pax->height; - if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p issued %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value)); + if ( pax2->didstats == 0 ) + { + basesp->issued += pax2->fiatoshis; + pax2->didstats = 1; + if ( strcmp(str,ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p issued %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,str,dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); + } } } } @@ -724,7 +705,6 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'I',height,0,CURRENCIES[baseids[i]],0); - komodo_paxmark(height,txids[i],vouts[i],'D',height); komodo_paxmark(height,txids[i],vouts[i],'I',height); if ( (pax= komodo_paxfind(txids[i],vouts[i],'I')) != 0 ) { @@ -732,15 +712,23 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 strcpy(pax->source,(char *)&opretbuf[opretlen-4]); if ( (pax2= komodo_paxfind(txids[i],vouts[i],'D')) != 0 ) { - // realtime path + // realtime path? pax->fiatoshis = pax2->fiatoshis; pax->komodoshis = pax2->komodoshis; - pax->height = pax2->height; - pax->otherheight = pax2->otherheight; - printf("ISSUED.%p kht.%d ht.%d %.8f %.8f\n",pax,pax->height,pax->otherheight,dstr(pax->komodoshis),dstr(pax->fiatoshis)); pax->marked = pax2->marked = pax2->height; + if ( pax->didstats == 0 ) + { + if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + { + basesp->issued += pax->fiatoshis; + pax->didstats = 1; + if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p issued %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,CURRENCIES[baseids[i]],dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); + } + } } } + komodo_paxmark(height,txids[i],vouts[i],'D',height); } } else printf("opreturn none issued?\n"); } From bde7e5ef6216700fac79d24eaeb0bd9e4f32d3d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 10:43:30 -0300 Subject: [PATCH 524/549] test --- src/komodo_gateway.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c07c1d8a1..62357a332 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -582,10 +582,13 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax->marked = pax2->marked = pax->height; if ( pax2->didstats == 0 ) { - basesp->issued += pax2->fiatoshis; - pax2->didstats = 1; - if ( strcmp(str,ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p issued %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,str,dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); + if ( (basesp= komodo_stateptrget(base)) != 0 ) + { + basesp->issued += pax2->fiatoshis; + pax2->didstats = 1; + if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p issued %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,str,dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); + } } } } From 94772c3be9e48ad8d3a716cfc412c077d4b8a22d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 10:44:46 -0300 Subject: [PATCH 525/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 62357a332..f0b1b04a5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -587,7 +587,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 basesp->issued += pax2->fiatoshis; pax2->didstats = 1; if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p issued %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,str,dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); + printf("########### %p issued %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,base,dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); } } } From 36b8ed99c87537e06fef5b44e718c4de5a071734 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 10:50:37 -0300 Subject: [PATCH 526/549] test --- src/komodo_gateway.h | 95 ++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 47 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f0b1b04a5..3e24f5288 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -570,7 +570,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 basesp->deposited += fiatoshis; didstats = 1; if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p deposited %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value)); + printf("########### %p deposited %s += %.8f/%.8f kmdheight.%d/%d %.8f/%.8f\n",basesp,base,dstr(fiatoshis),dstr(pax->fiatoshis),kmdheight,pax->height,dstr(value),dstr(pax->komodoshis)); } } if ( didstats != 0 ) @@ -587,7 +587,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 basesp->issued += pax2->fiatoshis; pax2->didstats = 1; if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p issued %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,base,dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); + printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight); } } } @@ -598,6 +598,52 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } + else if ( opretbuf[0] == 'I' ) + { + tokomodo = 0; + if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) + { + if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 ) + { + for (i=0; itype = opretbuf[0]; + strcpy(pax->source,(char *)&opretbuf[opretlen-4]); + if ( (pax2= komodo_paxfind(txids[i],vouts[i],'D')) != 0 ) + { + // realtime path? + pax->fiatoshis = pax2->fiatoshis; + pax->komodoshis = pax2->komodoshis; + pax->marked = pax2->marked = pax2->height; + if ( pax->didstats == 0 ) + { + if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + { + basesp->issued += pax->fiatoshis; + pax->didstats = 1; + if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p issuedb %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,CURRENCIES[baseids[i]],dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); + } + } + } + } + komodo_paxmark(height,txids[i],vouts[i],'D',height); + } + } else printf("opreturn none issued?\n"); + } + if ( strcmp(source,ASSETCHAINS_SYMBOL) == 0 ) + printf("source.%s opreturn[I] matches %s\n",source,(char *)&opretbuf[opretlen-4]); + } else if ( opretbuf[0] == 'W' && opretlen >= 38 ) { tokomodo = 1; @@ -692,51 +738,6 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } //printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal())); } - else if ( opretbuf[0] == 'I' ) - { - tokomodo = 0; - if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) - { - if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 ) - { - for (i=0; itype = opretbuf[0]; - strcpy(pax->source,(char *)&opretbuf[opretlen-4]); - if ( (pax2= komodo_paxfind(txids[i],vouts[i],'D')) != 0 ) - { - // realtime path? - pax->fiatoshis = pax2->fiatoshis; - pax->komodoshis = pax2->komodoshis; - pax->marked = pax2->marked = pax2->height; - if ( pax->didstats == 0 ) - { - if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) - { - basesp->issued += pax->fiatoshis; - pax->didstats = 1; - if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p issued %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,CURRENCIES[baseids[i]],dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); - } - } - } - } - komodo_paxmark(height,txids[i],vouts[i],'D',height); - } - } else printf("opreturn none issued?\n"); - } - printf("source.%s opreturn[I] matches %s\n",source,(char *)&opretbuf[opretlen-4]); - } else if ( opretbuf[0] == 'X' ) { tokomodo = 1; From 88dff0d3e2d15a42139c6ee31e3fbf632f865b12 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 10:57:26 -0300 Subject: [PATCH 527/549] test --- src/komodo_gateway.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3e24f5288..e43e087d3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -562,7 +562,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) { - pax->validated = kmdheight; + pax->height = pax->validated = kmdheight; + pax->komodoshis = value; + pax->fiatoshis = fiatoshis; if ( didstats == 0 && pax->didstats == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) From 44caf46a60a0b1d2af1362c87d8c31194888646e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 11:15:29 -0300 Subject: [PATCH 528/549] test --- src/komodo_gateway.h | 1 + src/miner.cpp | 4 ++-- src/pow.cpp | 9 ++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e43e087d3..38bcbb5f3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -582,6 +582,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax2->fiatoshis = pax->fiatoshis; pax2->komodoshis = pax->komodoshis; pax->marked = pax2->marked = pax->height; + pax->otherheight = height; if ( pax2->didstats == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index 4134248fb..5ef1ecba8 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -378,9 +378,9 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( ASSETCHAINS_SYMBOL[0] == 0 ) { int32_t i,opretlen; uint8_t opret[256],*ptr; - if ( komodo_gateway_deposits(&txNew,(char *)"KMD",1) == 0 ) + if ( (nHeight % 60) == 0 || komodo_gateway_deposits(&txNew,(char *)"KMD",1) == 0 ) { - if ( (opretlen= komodo_pax_opreturn(opret,sizeof(opret))) > 0 ) + if ( (opretlen= komodo_pax_opreturn(opret,sizeof(opret))) > 0 ) // have pricefeed { txNew.vout.resize(2); txNew.vout[1].scriptPubKey.resize(opretlen); diff --git a/src/pow.cpp b/src/pow.cpp index 7aaa9ec55..6fb7a492a 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -145,9 +145,12 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in // Check proof of work matches claimed amount if ( UintToArith256(hash) > bnTarget ) { - //for (i=0; i<33; i++) - // printf("%02x",pubkey33[i]); - //printf(" special.%d notaryid.%d ht.%d mod.%d error\n",special,notaryid,height,(height % 35)); + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&hash)[i]); + printf(" hash vs ") + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&bnTarget)[i]); + printf(" special.%d notaryid.%d ht.%d mod.%d error\n",special,notaryid,height,(height % 35)); return error("CheckProofOfWork(): hash doesn't match nBits"); } return true; From 21e1c25f5320284429342e559c38ee630b3611db Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 11:18:38 -0300 Subject: [PATCH 529/549] test --- src/pow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pow.cpp b/src/pow.cpp index 6fb7a492a..24448c56d 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -145,6 +145,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in // Check proof of work matches claimed amount if ( UintToArith256(hash) > bnTarget ) { + int32_t i; for (i=0; i<32; i++) printf("%02x",((uint8_t *)&hash)[i]); printf(" hash vs ") From 890d91cabb4b07a9b43f5f50e228ed9e3e79aec8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 11:20:22 -0300 Subject: [PATCH 530/549] test --- src/pow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index 24448c56d..9a1303c06 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -148,7 +148,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in int32_t i; for (i=0; i<32; i++) printf("%02x",((uint8_t *)&hash)[i]); - printf(" hash vs ") + printf(" hash vs "); for (i=0; i<32; i++) printf("%02x",((uint8_t *)&bnTarget)[i]); printf(" special.%d notaryid.%d ht.%d mod.%d error\n",special,notaryid,height,(height % 35)); From 49c783e32d8b5f1d2dda1e50b2db629119cbf76c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 11:24:05 -0300 Subject: [PATCH 531/549] test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2a2699f2f..af9484a03 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2704,12 +2704,12 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo if (!DisconnectTip(state)) return false; } -if ( 0 ) +if ( 1 ) { static int32_t didinit; if ( didinit++ == 0 ) { - while (chainActive.Tip()->nHeight > 91760 ) + while (chainActive.Tip()->nHeight > 94000 ) { fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); if ( !DisconnectTip(state) ) From d3b5faf9a6e201a05c262d26dc5955b6a044d035 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 11:25:24 -0300 Subject: [PATCH 532/549] test --- src/init.cpp | 2 +- src/qt/bitcoinstrings.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index cfd4f56dc..f464df44d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1256,7 +1256,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // first suggest a reindex if (!fReset) { bool fRet = uiInterface.ThreadSafeMessageBox( - strLoadError + ".\n\n" + _("Do you want to rebuild the block database now?"), + strLoadError + ".\n\n" + _("error in HDD data, might just need to update to latest, if that doesnt work, then you need to resync"), "", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT); if (fRet) { fReindex = true; diff --git a/src/qt/bitcoinstrings.cpp b/src/qt/bitcoinstrings.cpp index a3c9ec968..756542c4d 100644 --- a/src/qt/bitcoinstrings.cpp +++ b/src/qt/bitcoinstrings.cpp @@ -199,7 +199,7 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Corrupted block database detected"), QT_TRANSLATE_NOOP("bitcoin-core", "Could not parse -rpcbind value %s as network address"), QT_TRANSLATE_NOOP("bitcoin-core", "Debugging/Testing options:"), QT_TRANSLATE_NOOP("bitcoin-core", "Do not load the wallet and disable wallet RPC calls"), -QT_TRANSLATE_NOOP("bitcoin-core", "Do you want to rebuild the block database now?"), +QT_TRANSLATE_NOOP("bitcoin-core", "error with HDD data, maybe just need to update to latest version"), QT_TRANSLATE_NOOP("bitcoin-core", "Done loading"), QT_TRANSLATE_NOOP("bitcoin-core", "Error initializing block database"), QT_TRANSLATE_NOOP("bitcoin-core", "Error initializing wallet database environment %s!"), From c023699ab502cff3cccd25d0ad52cd8f90906510 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 11:28:36 -0300 Subject: [PATCH 533/549] test --- src/komodo_globals.h | 2 +- src/komodo_utils.h | 2 ++ src/main.cpp | 23 ++++++++++++----------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index a17c29964..7c8b7126d 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -36,7 +36,7 @@ struct komodo_state KOMODO_STATES[34]; int COINBASE_MATURITY = 100; -int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE; +int32_t IS_KOMODO_NOTARY,KOMODO_REWIND,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES; uint8_t NOTARY_PUBKEY33[33]; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 7b92d3a95..74a2a73f3 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1450,6 +1450,8 @@ void komodo_args() if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) USE_EXTERNAL_PUBKEY = 1; name = GetArg("-ac_name",""); + if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 ) + printf("KOMODO REWIND.%d\n",KOMODO_REWIND); if ( name.c_str()[0] != 0 ) { ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); diff --git a/src/main.cpp b/src/main.cpp index af9484a03..fe832ac0f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2694,6 +2694,7 @@ static void PruneBlockIndexCandidates() { * pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork. */ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMostWork, CBlock *pblock) { + extern int32_t KOMODO_REWIND; AssertLockHeld(cs_main); bool fInvalidFound = false; const CBlockIndex *pindexOldTip = chainActive.Tip(); @@ -2704,21 +2705,21 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo if (!DisconnectTip(state)) return false; } -if ( 1 ) -{ - static int32_t didinit; - if ( didinit++ == 0 ) + if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight > KOMODO_REWIND ) { - while (chainActive.Tip()->nHeight > 94000 ) + static int32_t didinit; + if ( didinit++ == 0 ) { - fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); - if ( !DisconnectTip(state) ) - return false; + while (chainActive.Tip()->nHeight > KOMODO_REWIND ) + { + fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); + if ( !DisconnectTip(state) ) + return false; + } + pindexOldTip = chainActive.Tip(); + pindexFork = chainActive.FindFork(pindexMostWork); } - pindexOldTip = chainActive.Tip(); - pindexFork = chainActive.FindFork(pindexMostWork); } -} // Build list of new blocks to connect. std::vector vpindexToConnect; bool fContinue = true; From e900f3afa8f92645f716069276827c3495b77304 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 11:32:34 -0300 Subject: [PATCH 534/549] test --- src/komodo_utils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 74a2a73f3..81e9adc5e 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1451,7 +1451,8 @@ void komodo_args() USE_EXTERNAL_PUBKEY = 1; name = GetArg("-ac_name",""); if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 ) - printf("KOMODO REWIND.%d\n",KOMODO_REWIND); + ; + printf("KOMODO REWIND.%d\n",KOMODO_REWIND); if ( name.c_str()[0] != 0 ) { ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); From 60b85bee1ae80f8f6a33ae67cb6c5e87b2c1739f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 11:35:04 -0300 Subject: [PATCH 535/549] test --- src/pow.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index 9a1303c06..9fd437eac 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -112,6 +112,7 @@ extern int32_t KOMODO_CHOSEN_ONE; bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params) { + extern int32_t KOMODO_REWIND; bool fNegative,fOverflow; int32_t i,nonz=0,special,special2,notaryid,flag = 0; arith_uint256 bnTarget; @@ -146,13 +147,14 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in if ( UintToArith256(hash) > bnTarget ) { int32_t i; - for (i=0; i<32; i++) + for (i=31; i>=0; i--) printf("%02x",((uint8_t *)&hash)[i]); printf(" hash vs "); - for (i=0; i<32; i++) + for (i=31; i>=0; i--) printf("%02x",((uint8_t *)&bnTarget)[i]); - printf(" special.%d notaryid.%d ht.%d mod.%d error\n",special,notaryid,height,(height % 35)); - return error("CheckProofOfWork(): hash doesn't match nBits"); + printf(" REWIND.%d special.%d notaryid.%d ht.%d mod.%d error\n",KOMODO_REWIND,special,notaryid,height,(height % 35)); + if ( height <= KOMODO_REWIND ) + return error("CheckProofOfWork(): hash doesn't match nBits"); } return true; } From 8432a64f0ebd0e089f7811a85d7a025a62de5b08 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 11:41:16 -0300 Subject: [PATCH 536/549] test --- src/pow.cpp | 2 +- src/wallet/wallet.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index 9fd437eac..0cdfa066f 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -152,7 +152,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in printf(" hash vs "); for (i=31; i>=0; i--) printf("%02x",((uint8_t *)&bnTarget)[i]); - printf(" REWIND.%d special.%d notaryid.%d ht.%d mod.%d error\n",KOMODO_REWIND,special,notaryid,height,(height % 35)); + printf(" ht.%d REWIND.%d special.%d notaryid.%d ht.%d mod.%d error\n",height,KOMODO_REWIND,special,notaryid,height,(height % 35)); if ( height <= KOMODO_REWIND ) return error("CheckProofOfWork(): hash doesn't match nBits"); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0ef2bb723..9d9712166 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -748,6 +748,7 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex, void CWallet::DecrementNoteWitnesses() { + extern int32_t KOMODO_REWIND; { LOCK(cs_wallet); for (std::pair& wtxItem : mapWallet) { @@ -770,12 +771,13 @@ void CWallet::DecrementNoteWitnesses() } } // TODO: If nWitnessCache is zero, we need to regenerate the caches (#1302) - assert(nWitnessCacheSize > 0); if ( nWitnessCacheSize <= 0 ) { extern char ASSETCHAINS_SYMBOL[16]; fprintf(stderr,"%s nWitnessCacheSize.%d\n",ASSETCHAINS_SYMBOL,(int32_t)nWitnessCacheSize); } + if ( KOMODO_REWIND == 0 ) + assert(nWitnessCacheSize > 0); if (fFileBacked) { CWalletDB walletdb(strWalletFile); WriteWitnessCache(walletdb); From 57d9cfcc318d3d559d975303b47d75e3621a20af Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 12:01:28 -0300 Subject: [PATCH 537/549] test --- src/komodo.h | 2 +- src/komodo_utils.h | 1 - src/wallet/wallet.cpp | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e82c4b429..c1dc1b489 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -516,7 +516,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) int32_t k; for (k=0; knHeight >= KOMODO_REWIND ) assert(nWitnessCacheSize > 0); if (fFileBacked) { CWalletDB walletdb(strWalletFile); From 637e8c9536f5e64f2a35b466a0c72de0b8eaf0ce Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 12:14:46 -0300 Subject: [PATCH 538/549] test --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 39478b7ec..1a9af57fc 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -776,7 +776,7 @@ void CWallet::DecrementNoteWitnesses() extern char ASSETCHAINS_SYMBOL[16]; fprintf(stderr,"%s nWitnessCacheSize.%d\n",ASSETCHAINS_SYMBOL,(int32_t)nWitnessCacheSize); } - if ( KOMODO_REWIND == 0 || chainActive.Tip()->nHeight >= KOMODO_REWIND ) + if ( KOMODO_REWIND == 0 || chainActive.Tip()->nHeight <= KOMODO_REWIND ) assert(nWitnessCacheSize > 0); if (fFileBacked) { CWalletDB walletdb(strWalletFile); From 438eef939ef758a2b651bffbd05632076b3a1252 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 12:45:35 -0300 Subject: [PATCH 539/549] test --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 1a9af57fc..9d9712166 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -776,7 +776,7 @@ void CWallet::DecrementNoteWitnesses() extern char ASSETCHAINS_SYMBOL[16]; fprintf(stderr,"%s nWitnessCacheSize.%d\n",ASSETCHAINS_SYMBOL,(int32_t)nWitnessCacheSize); } - if ( KOMODO_REWIND == 0 || chainActive.Tip()->nHeight <= KOMODO_REWIND ) + if ( KOMODO_REWIND == 0 ) assert(nWitnessCacheSize > 0); if (fFileBacked) { CWalletDB walletdb(strWalletFile); From ec3d17c61ce8b52fc781d7f5d64d617725dd6eba Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 14:39:28 -0300 Subject: [PATCH 540/549] test --- src/komodo_gateway.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 38bcbb5f3..a204326df 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -507,8 +507,12 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che return(-1); } } - if ( 0 && value != checkvalue ) - printf("%s.%d seed.%llx paxcmp value %llu != checkvalue %llu\n",symbol,kmdheight,(long long)seed,(long long)value,(long long)checkvalue); + else + { + ratio = ((value << 10) / checkvalue); + if ( ratio >= 1023 && ratio <= 1025 ) + return(0); + } return(value != checkvalue); } From a5dd6dc166fc0977afb732f3ef990086513e7174 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 14:58:35 -0300 Subject: [PATCH 541/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a204326df..b6c2f7132 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -507,7 +507,7 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che return(-1); } } - else + else if ( checkvalue != 0 ) { ratio = ((value << 10) / checkvalue); if ( ratio >= 1023 && ratio <= 1025 ) From 39863e30f151bc77557cc96fc51f27f92c9f488b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 15:01:51 -0300 Subject: [PATCH 542/549] test --- src/komodo_gateway.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b6c2f7132..c20edc217 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -638,13 +638,15 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->issued += pax->fiatoshis; pax->didstats = 1; + pax->height = pax2->height; + pax->otherheight = height; if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p issuedb %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,CURRENCIES[baseids[i]],dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); } } } + komodo_paxmark(pax->height,txids[i],vouts[i],'D',height); } - komodo_paxmark(height,txids[i],vouts[i],'D',height); } } else printf("opreturn none issued?\n"); } From 13aadf010d497edc78839185f1c185b52afc18a9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 15:25:54 -0300 Subject: [PATCH 543/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index c1dc1b489..d506dd096 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -521,7 +521,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); } numvalid = bitweight(signedmask); - if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries/3)) ) + if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries/4)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); notarized = 1; From e8c962194106350a84fa3056074cd14c1d11fd8d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 15:30:00 -0300 Subject: [PATCH 544/549] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5ef1ecba8..1c7b477b0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -99,7 +99,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, } #define ASSETCHAINS_MINHEIGHT 100 -#define ROUNDROBIN_DELAY 59 +#define ROUNDROBIN_DELAY 58 extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; From c7918614fcf3e5377649bee606f74cceb549064f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 18:57:03 -0300 Subject: [PATCH 545/549] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index d506dd096..2d978d443 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -511,7 +511,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { if ( (k= komodo_notarycmp(scriptPubKey,scriptlen,pubkeys,numnotaries,rmd160)) >= 0 ) signedmask |= (1LL << k); - else if ( numvins >= 17 ) + else if ( 0 && numvins >= 17 ) { int32_t k; for (k=0; k Date: Sat, 3 Dec 2016 19:25:33 -0300 Subject: [PATCH 546/549] test --- src/pow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index 0cdfa066f..ac2544cb2 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -113,7 +113,7 @@ extern int32_t KOMODO_CHOSEN_ONE; bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params) { extern int32_t KOMODO_REWIND; - bool fNegative,fOverflow; int32_t i,nonz=0,special,special2,notaryid,flag = 0; + bool fNegative,fOverflow; int32_t i,nonz=0,special,special2,notaryid=-1,flag = 0; arith_uint256 bnTarget; bnTarget.SetCompact(nBits, &fNegative, &fOverflow); From 8bd946cea1aec9f484d4628ec7a01865f6797a0b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 20:03:28 -0300 Subject: [PATCH 547/549] test --- src/komodo_gateway.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c20edc217..c4084ae3b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -353,7 +353,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to #ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE struct komodo_state *kmdsp = komodo_stateptrget((char *)"KMD"); if ( kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height ) // assumes same chain as notarize - pax->validated = kmdsp->NOTARIZED_HEIGHT; + pax->validated = pax->komodoshis; //kmdsp->NOTARIZED_HEIGHT; #endif } if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis ) @@ -361,8 +361,13 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to printf("miner: skip %s %.8f when avail %.8f\n",symbol,dstr(pax->fiatoshis),dstr(available)); continue; } - if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 ) + if ( pax->marked != 0 ) continue; + if ( strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 ) + { + printf("pax->symbol.%s != %s or null pax->validated %.8f\n",pax->symbol,symbol,dstr(pax->validated)); + continue; + } if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); txNew->vout.resize(numvouts+1); @@ -566,7 +571,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) { - pax->height = pax->validated = kmdheight; + pax->height = kmdheight; + pax->validated = value; pax->komodoshis = value; pax->fiatoshis = fiatoshis; if ( didstats == 0 && pax->didstats == 0 ) @@ -683,7 +689,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( didstats != 0 ) pax->didstats = 1; pax->type = opretbuf[0]; - pax->validated = kmdheight; + pax->validated = komodoshis; } } } From b844ceb5e9c0d8fdab4de87f373e5613730640db Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 3 Dec 2016 20:13:20 -0300 Subject: [PATCH 548/549] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c4084ae3b..0fb8a74d7 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -365,7 +365,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to continue; if ( strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 ) { - printf("pax->symbol.%s != %s or null pax->validated %.8f\n",pax->symbol,symbol,dstr(pax->validated)); + //printf("pax->symbol.%s != %s or null pax->validated %.8f\n",pax->symbol,symbol,dstr(pax->validated)); continue; } if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) From 730a5006cbbfb0607ed93067db1a74d57584eb1f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 4 Dec 2016 06:59:32 -0300 Subject: [PATCH 549/549] test --- src/rpcmisc.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index ed65e69a4..a635782a8 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -123,11 +123,9 @@ Value getinfo(const Array& params, bool fHelp) obj.push_back(Pair("errors", GetWarnings("statusbar"))); { char pubkeystr[65]; int32_t notaryid; - if ( (notaryid= komodo_whoami(pubkeystr,longestchain)) >= 0 ) - { - obj.push_back(Pair("notaryid", notaryid)); - obj.push_back(Pair("pubkey", pubkeystr)); - } + notaryid = komodo_whoami(pubkeystr,longestchain); + obj.push_back(Pair("notaryid", notaryid)); + obj.push_back(Pair("pubkey", pubkeystr)); } return obj; }