From 0b1ccd45616cdc49cecd2f825953c9ca508aab61 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 13:35:36 -0300 Subject: [PATCH 01/23] test --- iguana/dPoW.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 175cfa559..3e495af86 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -19,10 +19,10 @@ #define DPOW_FIRSTRATIFY 1000 #define DPOW_CHECKPOINTFREQ 10 -#define DPOW_MINSIGS 7 +#define DPOW_MINSIGS 2 //#define DPOW_M(bp) ((bp)->minsigs) // (((bp)->numnotaries >> 1) + 1) #define DPOW_MODIND(bp,offset) (((((bp)->height / DPOW_CHECKPOINTFREQ) % (bp)->numnotaries) + (offset)) % (bp)->numnotaries) -#define DPOW_VERSION 0x0757 +#define DPOW_VERSION 0x0767 #define DPOW_UTXOSIZE 10000 #define DPOW_MINOUTPUT 6000 #define DPOW_DURATION 300 From 2d4022ce2d557d5727134406779fc35ebc362e74 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 16:32:23 -0300 Subject: [PATCH 02/23] test --- deprecated/iguana_instantdex.c | 2 +- iguana/dpow/dpow_rpc.c | 3 ++- iguana/iguana_notary.c | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/deprecated/iguana_instantdex.c b/deprecated/iguana_instantdex.c index 20de75225..85755175b 100755 --- a/deprecated/iguana_instantdex.c +++ b/deprecated/iguana_instantdex.c @@ -877,7 +877,7 @@ struct instantdex_accept *instantdex_quotefind(struct supernet_info *myinfo,stru struct iguana_bundlereq *instantdex_recvquotes(struct iguana_info *coin,struct iguana_bundlereq *req,bits256 *quotes,int32_t n) { - int32_t i,len,state,m = 0; uint8_t serialized[10000]; struct instantdex_accept *ap; struct exchange_info *exchange; + int32_t i,len,state,m = 0; uint8_t serialized[16384]; struct instantdex_accept *ap; struct exchange_info *exchange; exchange = exchanges777_find("bitcoin"); if ( req->addr == 0 ) return(0); diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 8cd4ab71b..f513b3923 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -101,6 +101,7 @@ int32_t dpow_paxpending(uint8_t *hex) decode_hex(hex,n,hexstr); free_json(retjson); } + printf("PAXPENDING.(%s)\n",retstr); free(retstr); } } @@ -780,7 +781,7 @@ void dpow_issuer_voutupdate(struct dpow_info *dp,char *symbol,int32_t isspecial, int32_t dpow_issuer_tx(struct dpow_info *dp,struct iguana_info *coin,int32_t height,int32_t txi,char *txidstr,uint32_t port) { - char *retstr,params[256],*hexstr; uint8_t script[10000]; cJSON *json,*oldpub,*newpub,*result,*vouts,*item,*sobj; int32_t vout,n,len,isspecial,retval = -1; uint64_t value; bits256 txid; + char *retstr,params[256],*hexstr; uint8_t script[16384]; cJSON *json,*oldpub,*newpub,*result,*vouts,*item,*sobj; int32_t vout,n,len,isspecial,retval = -1; uint64_t value; bits256 txid; sprintf(params,"[\"%s\", 1]",txidstr); if ( (retstr= dpow_issuemethod(coin->chain->userpass,(char *)"getrawtransaction",params,port)) != 0 ) { diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 03fbcd193..049b88709 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -275,6 +275,8 @@ TWO_STRINGS(iguana,dpow,symbol,pubkey) myinfo->numdpows++; PAX_init(); portable_mutex_init(&dp->mutex); + uint8_t buf[32768]; + dpow_paxpending(buf); return(clonestr("{\"result\":\"success\"}")); } From f89b33e106ed83283dff02ab18f0e6455bff857b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 16:36:30 -0300 Subject: [PATCH 03/23] test --- iguana/dpow/dpow_rpc.c | 6 +++--- iguana/iguana_notary.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index f513b3923..9841ebc29 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -103,9 +103,9 @@ int32_t dpow_paxpending(uint8_t *hex) } printf("PAXPENDING.(%s)\n",retstr); free(retstr); - } - } - } + } else printf("dpow_paxpending: paxwithdraw null return\n"); + } else printf("dpow_paxpending: KMD FULLNODE.%d\n",coin->FULLNODE); + } else printf("dpow_paxpending: cant find KMD\n"); return(n); } diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 049b88709..07c65417a 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -275,6 +275,7 @@ TWO_STRINGS(iguana,dpow,symbol,pubkey) myinfo->numdpows++; PAX_init(); portable_mutex_init(&dp->mutex); + printf(">>>>>>>>>>>>>>> call paxpending\n"); uint8_t buf[32768]; dpow_paxpending(buf); return(clonestr("{\"result\":\"success\"}")); From 2d37efb2fd4631c384eb6d31a1f952c4e96d3603 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 16:38:26 -0300 Subject: [PATCH 04/23] test --- iguana/dpow/dpow_rpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 9841ebc29..ee541efc3 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -93,7 +93,7 @@ int32_t dpow_paxpending(uint8_t *hex) { if ( coin->FULLNODE < 0 ) { - if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"paxwithdraw","")) != 0 ) + if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"paxpending","")) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { From 5e976248eee5b827b3829f94fdd1166addfd01d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 16:40:13 -0300 Subject: [PATCH 05/23] test --- iguana/dpow/dpow_rpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index ee541efc3..01a1d4ac4 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -98,10 +98,12 @@ int32_t dpow_paxpending(uint8_t *hex) if ( (retjson= cJSON_Parse(retstr)) != 0 ) { if ( (hexstr= jstr(retjson,"withdraws")) != 0 && (n= is_hexstr(hexstr,0)) > 0 ) + { + printf("PAXPENDING.(%s)\n",retstr); decode_hex(hex,n,hexstr); + } free_json(retjson); } - printf("PAXPENDING.(%s)\n",retstr); free(retstr); } else printf("dpow_paxpending: paxwithdraw null return\n"); } else printf("dpow_paxpending: KMD FULLNODE.%d\n",coin->FULLNODE); From fc04be111d3a0c73661ca2fbf55a37efb7d4a80a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 16:45:59 -0300 Subject: [PATCH 06/23] test --- iguana/dpow/dpow_fsm.c | 2 +- iguana/iguana_notary.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 10942c26b..6c6527d0a 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -270,7 +270,7 @@ void dpow_statemachinestart(void *ptr) if ( kmdheight >= 0 ) { ht = kmdheight;///strcmp("KMD",src->symbol) == 0 ? kmdheight : bp->height; - if ( ht == 0 ) + if ( ht == 0 || strcmp("KMD",dest->symbol) == 0 ) ht = strcmp("KMD",src->symbol) == 0 ? src->longestchain : dest->longestchain; bp->numnotaries = komodo_notaries(src->symbol,pubkeys,ht); for (i=0; inumnotaries; i++) diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 07c65417a..a5a21944e 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -275,9 +275,9 @@ TWO_STRINGS(iguana,dpow,symbol,pubkey) myinfo->numdpows++; PAX_init(); portable_mutex_init(&dp->mutex); - printf(">>>>>>>>>>>>>>> call paxpending\n"); - uint8_t buf[32768]; - dpow_paxpending(buf); + //printf(">>>>>>>>>>>>>>> call paxpending\n"); + //uint8_t buf[32768]; + //dpow_paxpending(buf); return(clonestr("{\"result\":\"success\"}")); } From 7c3ea2cd74a935df5c3f265290dba88b916f0517 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 17:08:19 -0300 Subject: [PATCH 07/23] test --- iguana/dpow/dpow_rpc.c | 3 ++- iguana/dpow/dpow_tx.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 01a1d4ac4..23d8800b9 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -97,8 +97,9 @@ int32_t dpow_paxpending(uint8_t *hex) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { - if ( (hexstr= jstr(retjson,"withdraws")) != 0 && (n= is_hexstr(hexstr,0)) > 0 ) + if ( (hexstr= jstr(retjson,"withdraws")) != 0 && (n= is_hexstr(hexstr,0)) > 1 ) { + n >>= 1; printf("PAXPENDING.(%s)\n",retstr); decode_hex(hex,n,hexstr); } diff --git a/iguana/dpow/dpow_tx.c b/iguana/dpow/dpow_tx.c index eab17b310..f92e89fb1 100755 --- a/iguana/dpow/dpow_tx.c +++ b/iguana/dpow/dpow_tx.c @@ -165,7 +165,7 @@ struct dpow_block *dpow_heightfind(struct supernet_info *myinfo,struct dpow_info int32_t dpow_voutstandard(struct dpow_block *bp,uint8_t *serialized,int32_t m,int32_t src_or_dest,uint8_t pubkeys[][33],int32_t numratified) { - uint32_t locktime=0,numvouts; uint64_t satoshis,satoshisB; int32_t i,n,opretlen,len=0; uint8_t opret[1024],data[4096]; + uint32_t locktime=0,numvouts; uint64_t satoshis,satoshisB; int32_t i,n=0,opretlen,len=0; uint8_t opret[1024],data[4096]; numvouts = 2; if ( pubkeys == 0 || numratified <= 0 ) { @@ -208,7 +208,7 @@ int32_t dpow_voutstandard(struct dpow_block *bp,uint8_t *serialized,int32_t m,in return(-1); } opretlen = dpow_opreturnscript(data,opret,opretlen); - if ( (n= dpow_paxpending(&opret[opretlen])) > 0 ) + if ( (src_or_dest == 0 || strcmp(bp->destcoin->symbol,"BTC") != 0) && (n= dpow_paxpending(&opret[opretlen])) > 0 ) { for (i=0; i Date: Mon, 21 Nov 2016 17:18:30 -0300 Subject: [PATCH 08/23] test --- iguana/dpow/dpow_fsm.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 6c6527d0a..411c40b8d 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -270,9 +270,16 @@ void dpow_statemachinestart(void *ptr) if ( kmdheight >= 0 ) { ht = kmdheight;///strcmp("KMD",src->symbol) == 0 ? kmdheight : bp->height; - if ( ht == 0 || strcmp("KMD",dest->symbol) == 0 ) - ht = strcmp("KMD",src->symbol) == 0 ? src->longestchain : dest->longestchain; - bp->numnotaries = komodo_notaries(src->symbol,pubkeys,ht); + if ( strcmp("KMD",dest->symbol) == 0 ) + { + bp->numnotaries = komodo_notaries(dest->symbol,pubkeys,ht); + } + else + { + if ( ht == 0 ) + ht = strcmp("KMD",src->symbol) == 0 ? src->longestchain : dest->longestchain; + bp->numnotaries = komodo_notaries(src->symbol,pubkeys,ht); + } for (i=0; inumnotaries; i++) { //int32_t j; for (j=0; j<33; j++) From 1de4b90e247381514b2b3f614917e9d9ccc84c5f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 18:31:44 -0300 Subject: [PATCH 09/23] test --- iguana/dpow/dpow_network.c | 7 ++++++- iguana/dpow/dpow_tx.c | 19 +++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index ae2c7e237..ad4aa26cd 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -617,7 +617,7 @@ int32_t dpow_opreturnscript(uint8_t *script,uint8_t *opret,int32_t opretlen) return(opretlen + offset); } -int32_t dpow_rwopret(int32_t rwflag,uint8_t *opret,bits256 *hashmsg,int32_t *heightmsgp,char *src,struct dpow_block *bp,int32_t src_or_dest) +int32_t dpow_rwopret(int32_t rwflag,uint8_t *opret,bits256 *hashmsg,int32_t *heightmsgp,char *src,uint8_t *extras,int32_t extralen,struct dpow_block *bp,int32_t src_or_dest) { int32_t i,opretlen = 0; //bits256 beacon,beacons[DPOW_MAXRELAYS]; opretlen += iguana_rwbignum(rwflag,&opret[opretlen],sizeof(*hashmsg),hashmsg->bytes); @@ -651,6 +651,11 @@ int32_t dpow_rwopret(int32_t rwflag,uint8_t *opret,bits256 *hashmsg,int32_t *hei opret[opretlen++] = src[i]; } opret[opretlen++] = 0; + if ( extras != 0 && extralen > 0 ) + { + memcpy(&opret[opretlen],extras,extralen); + opretlen += extralen; + } } else { diff --git a/iguana/dpow/dpow_tx.c b/iguana/dpow/dpow_tx.c index f92e89fb1..4c5fe3bf5 100755 --- a/iguana/dpow/dpow_tx.c +++ b/iguana/dpow/dpow_tx.c @@ -165,7 +165,7 @@ struct dpow_block *dpow_heightfind(struct supernet_info *myinfo,struct dpow_info int32_t dpow_voutstandard(struct dpow_block *bp,uint8_t *serialized,int32_t m,int32_t src_or_dest,uint8_t pubkeys[][33],int32_t numratified) { - uint32_t locktime=0,numvouts; uint64_t satoshis,satoshisB; int32_t i,n=0,opretlen,len=0; uint8_t opret[1024],data[4096]; + uint32_t locktime=0,numvouts; uint64_t satoshis,satoshisB; int32_t i,n=0,opretlen,len=0; uint8_t opret[16384],data[16384],extras[16384]; numvouts = 2; if ( pubkeys == 0 || numratified <= 0 ) { @@ -197,24 +197,23 @@ int32_t dpow_voutstandard(struct dpow_block *bp,uint8_t *serialized,int32_t m,in } printf("numvouts.%d len.%d RATIFY vouts\n",numvouts,len); } + if ( (src_or_dest == 0 || strcmp(bp->destcoin->symbol,"BTC") != 0) && (n= dpow_paxpending(extras)) > 0 ) + { + for (i=0; ihashmsg,&bp->height,bp->srccoin->symbol,bp,src_or_dest); - else opretlen = dpow_rwopret(1,opret,&bp->hashmsg,&bp->height,bp->srccoin->symbol,bp,src_or_dest); + opretlen = dpow_rwopret(1,opret,&bp->hashmsg,&bp->height,bp->srccoin->symbol,extras,n,bp,src_or_dest); + else opretlen = dpow_rwopret(1,opret,&bp->hashmsg,&bp->height,bp->srccoin->symbol,extras,n,bp,src_or_dest); if ( opretlen < 0 ) { printf("negative opretlen src_or_dest.%d\n",src_or_dest); return(-1); } opretlen = dpow_opreturnscript(data,opret,opretlen); - if ( (src_or_dest == 0 || strcmp(bp->destcoin->symbol,"BTC") != 0) && (n= dpow_paxpending(&opret[opretlen])) > 0 ) - { - for (i=0; i Date: Fri, 25 Nov 2016 10:10:56 -0300 Subject: [PATCH 10/23] test --- iguana/dPoW.h | 2 +- iguana/dpow/dpow_network.c | 2 +- iguana/iguana_notary.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 3e495af86..8ca6c5a5b 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -19,7 +19,7 @@ #define DPOW_FIRSTRATIFY 1000 #define DPOW_CHECKPOINTFREQ 10 -#define DPOW_MINSIGS 2 +#define DPOW_MINSIGS ((height < 90000) ? 7 : 13) //#define DPOW_M(bp) ((bp)->minsigs) // (((bp)->numnotaries >> 1) + 1) #define DPOW_MODIND(bp,offset) (((((bp)->height / DPOW_CHECKPOINTFREQ) % (bp)->numnotaries) + (offset)) % (bp)->numnotaries) #define DPOW_VERSION 0x0767 diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index ad4aa26cd..a5e7c29b0 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -560,7 +560,7 @@ void dpow_nanomsg_update(struct supernet_info *myinfo) dpow_ipbitsadd(myinfo,dp,np->ipbits,np->numipbits,np->senderind,np->myipbits); if ( (bp= dpow_heightfind(myinfo,dp,np->height)) != 0 && bp->state != 0xffffffff ) { - if ( np->senderind >= 0 && np->senderind < bp->numnotaries && memcmp(bp-> notaries[np->senderind].pubkey+1,np->srchash.bytes,32) == 0 ) + if ( np->senderind >= 0 && np->senderind < bp->numnotaries && memcmp(bp-> notaries[np->senderind].pubkey+1,np->srchash.bytes,32) == 0 && bits256_nonz(np->srchash) != 0 ) { if ( bp->isratify == 0 ) dpow_nanoutxoget(myinfo,dp,bp,&np->notarize,0,np->senderind); diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index a5a21944e..a7c7a6d93 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -72,7 +72,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he { freq = 1; minsigs = (komodo_notaries(dp->symbol,pubkeys,height) >> 1) + 1; - if ( minsigs > DPOW_MINSIGS ) + if ( minsigs < DPOW_MINSIGS ) minsigs = DPOW_MINSIGS; } printf("%s/%s src ht.%d dest.%u nonz.%d %s minsigs.%d\n",dp->symbol,dp->dest,checkpoint.blockhash.height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash),minsigs); From ec0168dc6c5dad3ea3a02bdb85c57b7c85218863 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 10:25:28 -0300 Subject: [PATCH 11/23] test --- iguana/dPoW.h | 4 +-- iguana/dpow/dpow_prices.c | 60 +++++++++++++++++++++++---------------- iguana/dpow/dpow_rpc.c | 2 +- 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 8ca6c5a5b..394ce1446 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -19,10 +19,10 @@ #define DPOW_FIRSTRATIFY 1000 #define DPOW_CHECKPOINTFREQ 10 -#define DPOW_MINSIGS ((height < 90000) ? 7 : 13) +#define DPOW_MINSIGS ((height < 90000) ? 7 : 11) //#define DPOW_M(bp) ((bp)->minsigs) // (((bp)->numnotaries >> 1) + 1) #define DPOW_MODIND(bp,offset) (((((bp)->height / DPOW_CHECKPOINTFREQ) % (bp)->numnotaries) + (offset)) % (bp)->numnotaries) -#define DPOW_VERSION 0x0767 +#define DPOW_VERSION 0x0768 #define DPOW_UTXOSIZE 10000 #define DPOW_MINOUTPUT 6000 #define DPOW_DURATION 300 diff --git a/iguana/dpow/dpow_prices.c b/iguana/dpow/dpow_prices.c index ed91750b7..bcad9c8b9 100755 --- a/iguana/dpow/dpow_prices.c +++ b/iguana/dpow/dpow_prices.c @@ -102,7 +102,7 @@ struct PAX_data char edate[128]; double ecbmatrix[MAX_CURRENCIES][MAX_CURRENCIES],dailyprices[MAX_CURRENCIES * MAX_CURRENCIES],metals[4]; uint32_t lastupdate; int32_t ecbdatenum,ecbyear,ecbmonth,ecbday; double RTmatrix[MAX_CURRENCIES][MAX_CURRENCIES],RTprices[128],RTmetals[4]; - double basevals[MAX_CURRENCIES],cryptovols[2][9][2],BTCUSD,KMDBTC,CNYUSD,btcusd,kmdbtc,cryptos[8]; + double basevals[MAX_CURRENCIES],cryptovols[2][9][2],BTCDBTC,BTCUSD,KMDBTC,CNYUSD,btcusd,kmdbtc,cryptos[8]; struct PAX_spline splines[128]; }; @@ -1182,12 +1182,13 @@ double PAX_yahoo(char *metal) void PAX_btcprices(struct PAX_data *dp,int32_t enddatenum,int32_t numdates) { - int32_t i,n,year,month,day,seconds,datenum; char url[1024],date[64],*dstr,*str; + int32_t i,n,year,month,day,seconds,datenum; char url[1024],url2[1024],date[64],*dstr,*str; uint32_t timestamp,utc32[MAX_SPLINES]; struct tai t; cJSON *coindesk,*quandl,*kmdhist,*bpi,*array,*item; double kmddaily[MAX_SPLINES],cdaily[MAX_SPLINES],qdaily[MAX_SPLINES],ask,high,low,bid,close,vol,quotevol,open,price = 0.; coindesk = url_json("http://api.coindesk.com/v1/bpi/historical/close.json"); sprintf(url,"https://poloniex.com/public?command=returnChartData¤cyPair=BTC_KMD&start=%ld&end=9999999999&period=86400",(long)(time(NULL)-numdates*3600*24)); + sprintf(url2,"https://poloniex.com/public?command=returnChartData¤cyPair=BTC_BTCD&start=%ld&end=9999999999&period=86400",(long)(time(NULL)-numdates*3600*24)); if ( (bpi= jobj(coindesk,"bpi")) != 0 ) { datenum = enddatenum; @@ -1415,7 +1416,7 @@ int32_t ecb_matrix(double basevals[MAX_CURRENCIES],double matrix[MAX_CURRENCIES] void PAX_update(struct PAX_data *dp,double *btcusdp,double *kmdbtcp) { - int32_t i,n,seconds,datenum; uint32_t timestamp; char url[1024],*dstr,*str; + int32_t i,n,iter,seconds,datenum; uint32_t timestamp; char url[1024],url2[1024],*dstr,*str; double kmddaily=0.,btcusd=0.,ask,high,low,bid,close,vol,quotevol,open,price = 0.; //cJSON *kmdtrades,*kmdtrades2,*,*bitcoincharts,; cJSON *quandl,*kmdhist,*array,*item,*bitcoinave,*blockchaininfo,*btctrades,*coindesk=0; @@ -1423,12 +1424,13 @@ void PAX_update(struct PAX_data *dp,double *btcusdp,double *kmdbtcp) btctrades = url_json(url); //kmdtrades = url_json("https://poloniex.com/public?command=returnTradeHistory¤cyPair=USDT_BTC"); //kmdtrades2 = url_json("https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-KMD&count=50"); - *kmdbtcp = 0.0001; + *kmdbtcp = 0; bitcoinave = 0;//url_json("https://api.bitcoinaverage.com/ticker/USD/"); //bitcoincharts = url_json("http://api.bitcoincharts.com/v1/weighted_prices.json"); blockchaininfo = 0;//url_json("https://blockchain.info/ticker"); coindesk = 0;//url_json("http://api.coindesk.com/v1/bpi/historical/close.json"); sprintf(url,"https://poloniex.com/public?command=returnChartData¤cyPair=BTC_KMD&start=%ld&end=9999999999&period=86400",(long)(time(NULL)-2*3600*24)); + sprintf(url2,"https://poloniex.com/public?command=returnChartData¤cyPair=BTC_BTCD&start=%ld&end=9999999999&period=86400",(long)(time(NULL)-2*3600*24)); quandl = 0;//url_json("https://www.quandl.com/api/v1/datasets/BAVERAGE/USD.json?rows=1"); if ( 0 && (str= jstr(quandl,"updated_at")) != 0 && (datenum= conv_date(&seconds,str)) > 0 && (array= jarray(&n,quandl,"data")) != 0 ) { @@ -1461,28 +1463,37 @@ void PAX_update(struct PAX_data *dp,double *btcusdp,double *kmdbtcp) } else { - kmdhist = url_json(url); - //{"date":1406160000,"high":0.01,"low":0.00125,"open":0.01,"close":0.001375,"volume":1.50179994,"quoteVolume":903.58818412,"weightedAverage":0.00166204}, - if ( kmdhist != 0 && (array= jarray(&n,kmdhist,0)) != 0 ) + for (iter=0; iter<2; iter++) { - //printf("GOT.(%s)\n",cJSON_Print(array)); - for (i=0; i<1; i++) + kmdhist = url_json(iter == 0 ? url : url2); + //{"date":1406160000,"high":0.01,"low":0.00125,"open":0.01,"close":0.001375,"volume":1.50179994,"quoteVolume":903.58818412,"weightedAverage":0.00166204}, + if ( kmdhist != 0 && (array= jarray(&n,kmdhist,0)) != 0 ) { - item = jitem(array,i); - timestamp = juint(item,"date"), high = jdouble(item,"high"), low = jdouble(item,"low"), open = jdouble(item,"open"); - close = jdouble(item,"close"), vol = jdouble(item,"volume"), quotevol = jdouble(item,"quoteVolume"), price = jdouble(item,"weightedAverage"); - //printf("[%u %f %f %f %f %f %f %f]",timestamp,high,low,open,close,vol,quotevol,price); - //printf("[%u %d %f]",timestamp,OS_conv_unixtime(&seconds,timestamp),price); - kmddaily = price; - if ( kmddaily != 0 ) - dp->KMDBTC = *kmdbtcp = kmddaily; + //printf("GOT.(%s)\n",cJSON_Print(array)); + for (i=0; i<1; i++) + { + item = jitem(array,i); + timestamp = juint(item,"date"), high = jdouble(item,"high"), low = jdouble(item,"low"), open = jdouble(item,"open"); + close = jdouble(item,"close"), vol = jdouble(item,"volume"), quotevol = jdouble(item,"quoteVolume"), price = jdouble(item,"weightedAverage"); + //printf("[%u %f %f %f %f %f %f %f]",timestamp,high,low,open,close,vol,quotevol,price); + //printf("[%u %d %f]",timestamp,OS_conv_unixtime(&seconds,timestamp),price); + if ( price != 0 ) + { + if ( iter == 0 ) + dp->KMDBTC = *kmdbtcp = kmddaily; + else dp->BTCDBTC = price; + } + } + //printf("poloniex.%d\n",n); } - //printf("poloniex.%d\n",n); + if ( kmdhist != 0 ) + free_json(kmdhist); } - if ( kmdhist != 0 ) - free_json(kmdhist); } } + if ( (*kmdbtcp= dp->KMDBTC) == 0. ) + *kmdbtcp = dp->BTCDBTC / 50.22; + printf("KMD/BTC %.8f\n",*kmdbtcp); if ( btctrades != 0 && (array= jarray(&n,btctrades,0)) != 0 ) { //printf("GOT.(%s)\n",cJSON_Print(array)); @@ -1565,8 +1576,9 @@ void _crypto_update(double cryptovols[2][9][2],struct PAX_data *dp,int32_t selec cnyusd = dp->CNYUSD; btcusd = dp->BTCUSD; if ( (kmdbtc= dp->KMDBTC) == 0. ) - kmdbtc = 0.0001; - //printf("update with btcusd %f kmd %f cnyusd %f cnybtc %f\n",btcusd,kmdbtc,cnyusd,cnyusd/btcusd); + ;//kmdbtc = dp->BTCDBTC / 50.22; + printf("DEPRECATED: update with btcusd %f kmd %f cnyusd %f cnybtc %f\n",btcusd,kmdbtc,cnyusd,cnyusd/btcusd); + return; if ( btcusd < SMALLVAL || kmdbtc < SMALLVAL ) { PAX_update(dp,&btcusd,&kmdbtc); @@ -1826,11 +1838,11 @@ int32_t PAX_idle(struct supernet_info *myinfo)//struct PAX_data *argdp,int32_t i } dp = myinfo->PAXDATA; - if ( 0 && time(NULL) > dp->lastupdate+10 ) + /*if ( 0 && time(NULL) > dp->lastupdate+10 ) { _crypto_update(dp->cryptovols,dp,1); dp->lastupdate = (uint32_t)time(NULL); - } + }*/ if ( OS_milliseconds() > lastupdate + (1000*idlegap) ) { lastupdate = OS_milliseconds(); diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 23d8800b9..5b768c75c 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -42,7 +42,7 @@ int32_t komodo_notaries(char *symbol,uint8_t pubkeys[64][33],int32_t height) decode_hex(pubkeys[i],33,pubkeystr); else printf("error i.%d of %d (%s)\n",i,num,pubkeystr!=0?pubkeystr:""); } - printf("notaries.[%d] <- ht.%d\n",num,height); + //printf("notaries.[%d] <- ht.%d\n",num,height); } free_json(retjson); } From 53e51a24a05e0dd67f513cbe940aeb528b6d1a84 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 10:28:19 -0300 Subject: [PATCH 12/23] test --- iguana/dpow/dpow_prices.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iguana/dpow/dpow_prices.c b/iguana/dpow/dpow_prices.c index bcad9c8b9..b8389a4db 100755 --- a/iguana/dpow/dpow_prices.c +++ b/iguana/dpow/dpow_prices.c @@ -1448,13 +1448,13 @@ void PAX_update(struct PAX_data *dp,double *btcusdp,double *kmdbtcp) } } } - if ( 0 ) + if ( 1 ) { double avebid,aveask,bidvol,askvol; struct exchange_quote sortbuf[512]; struct supernet_info *myinfo = SuperNET_MYINFO(0); cJSON *argjson = cJSON_Parse("{}"); - aveask = instantdex_aveprice(myinfo,sortbuf,(int32_t)(sizeof(sortbuf)/sizeof(*sortbuf)),&askvol,"KMD","BTC",1,argjson); - avebid = instantdex_aveprice(myinfo,sortbuf,(int32_t)(sizeof(sortbuf)/sizeof(*sortbuf)),&bidvol,"KMD","BTC",-1,argjson); - if ( avebid > SMALLVAL && aveask > SMALLVAL ) + //aveask = instantdex_aveprice(myinfo,sortbuf,(int32_t)(sizeof(sortbuf)/sizeof(*sortbuf)),&askvol,"KMD","BTC",1,argjson); + //avebid = instantdex_aveprice(myinfo,sortbuf,(int32_t)(sizeof(sortbuf)/sizeof(*sortbuf)),&bidvol,"KMD","BTC",-1,argjson); + if ( 0 && avebid > SMALLVAL && aveask > SMALLVAL ) { price = (avebid*bidvol + aveask*askvol) / (bidvol + askvol); *kmdbtcp = price; From aa25131a48079b176b71f130611ce5612636382c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:10:05 -0300 Subject: [PATCH 13/23] test --- iguana/dpow/dpow_prices.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/iguana/dpow/dpow_prices.c b/iguana/dpow/dpow_prices.c index b8389a4db..6ee1bdb6c 100755 --- a/iguana/dpow/dpow_prices.c +++ b/iguana/dpow/dpow_prices.c @@ -1450,8 +1450,7 @@ void PAX_update(struct PAX_data *dp,double *btcusdp,double *kmdbtcp) } if ( 1 ) { - double avebid,aveask,bidvol,askvol; struct exchange_quote sortbuf[512]; - struct supernet_info *myinfo = SuperNET_MYINFO(0); cJSON *argjson = cJSON_Parse("{}"); + double avebid,aveask,bidvol,askvol; //struct exchange_quote sortbuf[512]; struct supernet_info *myinfo = SuperNET_MYINFO(0); cJSON *argjson = cJSON_Parse("{}"); //aveask = instantdex_aveprice(myinfo,sortbuf,(int32_t)(sizeof(sortbuf)/sizeof(*sortbuf)),&askvol,"KMD","BTC",1,argjson); //avebid = instantdex_aveprice(myinfo,sortbuf,(int32_t)(sizeof(sortbuf)/sizeof(*sortbuf)),&bidvol,"KMD","BTC",-1,argjson); if ( 0 && avebid > SMALLVAL && aveask > SMALLVAL ) From 4653dfe841c2c68c61e4912f0289df7b022febe2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:14:59 -0300 Subject: [PATCH 14/23] test --- iguana/dpow/dpow_prices.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/dpow/dpow_prices.c b/iguana/dpow/dpow_prices.c index 6ee1bdb6c..7226bf83e 100755 --- a/iguana/dpow/dpow_prices.c +++ b/iguana/dpow/dpow_prices.c @@ -1474,7 +1474,7 @@ void PAX_update(struct PAX_data *dp,double *btcusdp,double *kmdbtcp) item = jitem(array,i); timestamp = juint(item,"date"), high = jdouble(item,"high"), low = jdouble(item,"low"), open = jdouble(item,"open"); close = jdouble(item,"close"), vol = jdouble(item,"volume"), quotevol = jdouble(item,"quoteVolume"), price = jdouble(item,"weightedAverage"); - //printf("[%u %f %f %f %f %f %f %f]",timestamp,high,low,open,close,vol,quotevol,price); + printf("[%u %f %f %f %f %f %f %f]",timestamp,high,low,open,close,vol,quotevol,price); //printf("[%u %d %f]",timestamp,OS_conv_unixtime(&seconds,timestamp),price); if ( price != 0 ) { @@ -1483,7 +1483,7 @@ void PAX_update(struct PAX_data *dp,double *btcusdp,double *kmdbtcp) else dp->BTCDBTC = price; } } - //printf("poloniex.%d\n",n); + printf("poloniex.%d\n",n); } if ( kmdhist != 0 ) free_json(kmdhist); From cb860bc1f3f9ed74cd19b20e983b9020cbd3918d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:22:15 -0300 Subject: [PATCH 15/23] test --- iguana/dpow/dpow_prices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_prices.c b/iguana/dpow/dpow_prices.c index 7226bf83e..34b87f309 100755 --- a/iguana/dpow/dpow_prices.c +++ b/iguana/dpow/dpow_prices.c @@ -1468,7 +1468,7 @@ void PAX_update(struct PAX_data *dp,double *btcusdp,double *kmdbtcp) //{"date":1406160000,"high":0.01,"low":0.00125,"open":0.01,"close":0.001375,"volume":1.50179994,"quoteVolume":903.58818412,"weightedAverage":0.00166204}, if ( kmdhist != 0 && (array= jarray(&n,kmdhist,0)) != 0 ) { - //printf("GOT.(%s)\n",cJSON_Print(array)); + printf("GOT.(%s)\n",cJSON_Print(array)); for (i=0; i<1; i++) { item = jitem(array,i); From bed0494a4cc50c505e2bbeda4738e52ed6796543 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:24:34 -0300 Subject: [PATCH 16/23] test --- iguana/dpow/dpow_prices.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/iguana/dpow/dpow_prices.c b/iguana/dpow/dpow_prices.c index 34b87f309..2f4319083 100755 --- a/iguana/dpow/dpow_prices.c +++ b/iguana/dpow/dpow_prices.c @@ -1429,8 +1429,8 @@ void PAX_update(struct PAX_data *dp,double *btcusdp,double *kmdbtcp) //bitcoincharts = url_json("http://api.bitcoincharts.com/v1/weighted_prices.json"); blockchaininfo = 0;//url_json("https://blockchain.info/ticker"); coindesk = 0;//url_json("http://api.coindesk.com/v1/bpi/historical/close.json"); - sprintf(url,"https://poloniex.com/public?command=returnChartData¤cyPair=BTC_KMD&start=%ld&end=9999999999&period=86400",(long)(time(NULL)-2*3600*24)); - sprintf(url2,"https://poloniex.com/public?command=returnChartData¤cyPair=BTC_BTCD&start=%ld&end=9999999999&period=86400",(long)(time(NULL)-2*3600*24)); + sprintf(url,"https://poloniex.com/public?command=returnChartData¤cyPair=BTC_KMD&start=%ld&end=9999999999&period=86400",(long)(time(NULL)-3600*24)); + sprintf(url2,"https://poloniex.com/public?command=returnChartData¤cyPair=BTC_BTCD&start=%ld&end=9999999999&period=86400",(long)(time(NULL)-3600*24)); quandl = 0;//url_json("https://www.quandl.com/api/v1/datasets/BAVERAGE/USD.json?rows=1"); if ( 0 && (str= jstr(quandl,"updated_at")) != 0 && (datenum= conv_date(&seconds,str)) > 0 && (array= jarray(&n,quandl,"data")) != 0 ) { @@ -1468,13 +1468,13 @@ void PAX_update(struct PAX_data *dp,double *btcusdp,double *kmdbtcp) //{"date":1406160000,"high":0.01,"low":0.00125,"open":0.01,"close":0.001375,"volume":1.50179994,"quoteVolume":903.58818412,"weightedAverage":0.00166204}, if ( kmdhist != 0 && (array= jarray(&n,kmdhist,0)) != 0 ) { - printf("GOT.(%s)\n",cJSON_Print(array)); + //printf("GOT.(%s)\n",cJSON_Print(array)); for (i=0; i<1; i++) { item = jitem(array,i); timestamp = juint(item,"date"), high = jdouble(item,"high"), low = jdouble(item,"low"), open = jdouble(item,"open"); close = jdouble(item,"close"), vol = jdouble(item,"volume"), quotevol = jdouble(item,"quoteVolume"), price = jdouble(item,"weightedAverage"); - printf("[%u %f %f %f %f %f %f %f]",timestamp,high,low,open,close,vol,quotevol,price); + //printf("[%u %f %f %f %f %f %f %f]",timestamp,high,low,open,close,vol,quotevol,price); //printf("[%u %d %f]",timestamp,OS_conv_unixtime(&seconds,timestamp),price); if ( price != 0 ) { @@ -1483,7 +1483,7 @@ void PAX_update(struct PAX_data *dp,double *btcusdp,double *kmdbtcp) else dp->BTCDBTC = price; } } - printf("poloniex.%d\n",n); + //printf("poloniex.%d\n",n); } if ( kmdhist != 0 ) free_json(kmdhist); From df9a4fe2f4fe3dcdd399c72e70f7cfa66531cc43 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 12:26:44 -0300 Subject: [PATCH 17/23] test --- iguana/dpow/dpow_prices.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_prices.c b/iguana/dpow/dpow_prices.c index 2f4319083..fe62ef314 100755 --- a/iguana/dpow/dpow_prices.c +++ b/iguana/dpow/dpow_prices.c @@ -1492,7 +1492,8 @@ void PAX_update(struct PAX_data *dp,double *btcusdp,double *kmdbtcp) } if ( (*kmdbtcp= dp->KMDBTC) == 0. ) *kmdbtcp = dp->BTCDBTC / 50.22; - printf("KMD/BTC %.8f\n",*kmdbtcp); + if ( (rand() % 100) == 0 ) + printf("KMD/BTC %.8f\n",*kmdbtcp); if ( btctrades != 0 && (array= jarray(&n,btctrades,0)) != 0 ) { //printf("GOT.(%s)\n",cJSON_Print(array)); From 14c6410f60b6873492f9eb73271a8bc8beccd5e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 14:23:49 -0300 Subject: [PATCH 18/23] test --- iguana/dPoW.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 394ce1446..897139c69 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -19,7 +19,7 @@ #define DPOW_FIRSTRATIFY 1000 #define DPOW_CHECKPOINTFREQ 10 -#define DPOW_MINSIGS ((height < 90000) ? 7 : 11) +#define DPOW_MINSIGS 11 //((height < 90000) ? 7 : 11) //#define DPOW_M(bp) ((bp)->minsigs) // (((bp)->numnotaries >> 1) + 1) #define DPOW_MODIND(bp,offset) (((((bp)->height / DPOW_CHECKPOINTFREQ) % (bp)->numnotaries) + (offset)) % (bp)->numnotaries) #define DPOW_VERSION 0x0768 From 27c01c8f890d98dadeaca3f89447f8c9ce8979a7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 17:26:09 -0300 Subject: [PATCH 19/23] test --- iguana/dpow/dpow_fsm.c | 4 +++- iguana/iguana_notary.c | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 411c40b8d..4f543bb15 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -190,6 +190,7 @@ void dpow_statemachinestart(void *ptr) bp->duration = duration; bp->srccoin = src; bp->destcoin = dest; + bp->myind = -1; bp->opret_symbol = dp->symbol; if ( jsonstr != 0 && (ratified= cJSON_Parse(jsonstr)) != 0 ) { @@ -305,6 +306,7 @@ void dpow_statemachinestart(void *ptr) dp->ratifying -= bp->isratify; return; } + printf("myind.%d\n",myind); } else { @@ -380,7 +382,7 @@ void dpow_statemachinestart(void *ptr) } if ( bp->isratify == 0 || (starttime= checkpoint.timestamp) == 0 ) bp->starttime = starttime = (uint32_t)time(NULL); - printf("isratify.%d DPOW.%s statemachine checkpoint.%d %s start.%u\n",bp->isratify,src->symbol,checkpoint.blockhash.height,bits256_str(str,checkpoint.blockhash.hash),checkpoint.timestamp); + printf("myind.%d isratify.%d DPOW.%s statemachine checkpoint.%d %s start.%u\n",bp->myind,bp->isratify,src->symbol,checkpoint.blockhash.height,bits256_str(str,checkpoint.blockhash.hash),checkpoint.timestamp); for (i=0; iminerkey33[i+1]; //printf("start utxosync start.%u %u\n",starttime,(uint32_t)time(NULL)); diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index a7c7a6d93..9ed4d49b1 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -60,7 +60,7 @@ void dpow_checkpointset(struct supernet_info *myinfo,struct dpow_checkpoint *che void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height,bits256 hash,uint32_t timestamp,uint32_t blocktime) { - void **ptrs; char str[65]; struct dpow_checkpoint checkpoint; int32_t freq,minsigs; uint8_t pubkeys[64][33]; + void **ptrs; char str[65]; struct dpow_checkpoint checkpoint; int32_t freq,minsigs; //uint8_t pubkeys[64][33]; dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime); checkpoint = dp->srcfifo[dp->srcconfirms]; if ( strcmp("BTC",dp->dest) == 0 ) @@ -71,9 +71,9 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he else { freq = 1; - minsigs = (komodo_notaries(dp->symbol,pubkeys,height) >> 1) + 1; - if ( minsigs < DPOW_MINSIGS ) - minsigs = DPOW_MINSIGS; + minsigs = 7;//(komodo_notaries(dp->symbol,pubkeys,height) >> 1) + 1; + //if ( minsigs < DPOW_MINSIGS ) + // minsigs = DPOW_MINSIGS; } printf("%s/%s src ht.%d dest.%u nonz.%d %s minsigs.%d\n",dp->symbol,dp->dest,checkpoint.blockhash.height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash),minsigs); dpow_fifoupdate(myinfo,dp->srcfifo,dp->last); From eac6e4b7dba7092ca86eb9a5713822f8b69ecc34 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 17:45:17 -0300 Subject: [PATCH 20/23] test --- iguana/dPoW.h | 4 ++-- iguana/dpow/dpow_fsm.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 897139c69..b85235628 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -102,9 +102,9 @@ struct dpow_block struct dpow_entry notaries[DPOW_MAXRELAYS]; uint32_t state,starttime,timestamp,waiting,sigcrcs[2],txidcrcs[2],utxocrcs[2],lastepoch; int32_t rawratifiedlens[2],height,numnotaries,numerrors,completed,minsigs,duration,numratified,isratify,require0,scores[DPOW_MAXRELAYS]; - int8_t bestk,ratifybestk,pendingbestk,pendingratifybestk; + int8_t myind,bestk,ratifybestk,pendingbestk,pendingratifybestk; cJSON *ratified; - uint8_t myind,ratified_pubkeys[DPOW_MAXRELAYS][33],ratifysigs[2][DPOW_MAXSIGLEN],ratifysiglens[2]; + uint8_t ratified_pubkeys[DPOW_MAXRELAYS][33],ratifysigs[2][DPOW_MAXSIGLEN],ratifysiglens[2]; char handles[DPOW_MAXRELAYS][32]; char signedtx[32768]; uint8_t ratifyrawtx[2][32768]; uint32_t pendingcrcs[2]; }; diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 4f543bb15..adb900046 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -169,7 +169,6 @@ void dpow_statemachinestart(void *ptr) jsonstr = ptrs[4]; kmdheight = -1; memcpy(&checkpoint,&ptrs[5],sizeof(checkpoint)); - printf("statemachinestart %s->%s %s ht.%d minsigs.%d duration.%d start.%u\n",dp->symbol,dp->dest,bits256_str(str,checkpoint.blockhash.hash),checkpoint.blockhash.height,minsigs,duration,checkpoint.timestamp); src = iguana_coinfind(dp->symbol); dest = iguana_coinfind(dp->dest); dpow_getchaintip(myinfo,&srchash,&srctime,dp->srctx,&dp->numsrctx,src); @@ -315,6 +314,8 @@ void dpow_statemachinestart(void *ptr) dp->ratifying -= bp->isratify; return; } + bp->myind = myind; + printf("[%d] statemachinestart %s->%s %s ht.%d minsigs.%d duration.%d start.%u\n",bp->myind,dp->symbol,dp->dest,bits256_str(str,checkpoint.blockhash.hash),checkpoint.blockhash.height,minsigs,duration,checkpoint.timestamp); if ( bp->isratify != 0 && memcmp(bp->notaries[0].pubkey,bp->ratified_pubkeys[0],33) != 0 ) { for (i=0; i<33; i++) From 262bd9473c9996210252f3f71428a094301d0706 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 17:56:52 -0300 Subject: [PATCH 21/23] test --- iguana/dpow/dpow_fsm.c | 6 +++--- iguana/dpow/dpow_rpc.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index adb900046..d5891d53c 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -327,7 +327,7 @@ void dpow_statemachinestart(void *ptr) dp->ratifying -= bp->isratify; return; } - printf(" myind.%d myaddr.(%s %s)\n",myind,srcaddr,destaddr); + //printf(" myind.%d myaddr.(%s %s)\n",myind,srcaddr,destaddr); if ( myind == 0 && bits256_nonz(destprevtxid0) != 0 && bits256_nonz(srcprevtxid0) != 0 && destprevvout0 >= 0 && srcprevvout0 >= 0 ) { ep->dest.prev_hash = destprevtxid0; @@ -375,7 +375,7 @@ void dpow_statemachinestart(void *ptr) { if ( dp->checkpoint.blockhash.height > checkpoint.blockhash.height ) { - printf("abort ht.%d due to new checkpoint.%d\n",checkpoint.blockhash.height,dp->checkpoint.blockhash.height); + printf("abort %s ht.%d due to new checkpoint.%d\n",dp->symbol,checkpoint.blockhash.height,dp->checkpoint.blockhash.height); dp->ratifying -= bp->isratify; return; } @@ -396,7 +396,7 @@ void dpow_statemachinestart(void *ptr) { if ( bp->isratify == 0 ) { - printf("abort ht.%d due to new checkpoint.%d\n",checkpoint.blockhash.height,dp->checkpoint.blockhash.height); + printf("abort %s ht.%d due to new checkpoint.%d\n",dp->symbol,checkpoint.blockhash.height,dp->checkpoint.blockhash.height); break; } } diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 5b768c75c..94c720493 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -449,10 +449,10 @@ int32_t dpow_haveutxo(struct supernet_info *myinfo,struct iguana_info *coin,bits } if ( haveutxo == 0 ) printf("no utxo: need to fund address.(%s) or wait for splitfund to confirm\n",coinaddr); - } else printf("null utxo array size\n"); + } //else printf("null utxo array size\n"); free_json(unspents); } else printf("null return from dpow_listunspent\n"); - if ( haveutxo > 0 ) + if ( 0 && haveutxo > 0 ) printf("%s haveutxo.%d\n",coin->symbol,haveutxo); return(haveutxo); } From 9d2ad0c524985bdabcb8611cfc5ff9fe1b03f47c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 18:45:02 -0300 Subject: [PATCH 22/23] test --- iguana/iguana_payments.c | 2 +- iguana/iguana_wallet.c | 5 +++-- iguana/tests/listtransactions | 2 +- iguana/tests/listunspent | 2 +- iguana/tests/listunspent2 | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index 7cdf118c6..f5d7a7300 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -1238,7 +1238,7 @@ cJSON *iguana_listunspents(struct supernet_info *myinfo,struct iguana_info *coin { array = iguana_getaddressesbyaccount(myinfo,coin,"*"); flag = 1; - //printf("listunspent.(%s)\n",jprint(array,0)); + printf("listunspent.(%s)\n",jprint(array,0)); } if ( minconf == 0 ) minconf = 1; diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index 834aab885..c7b4815db 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -1731,7 +1731,7 @@ STRING_AND_THREEINTS(bitcoinrpc,listtransactions,account,count,skip,includewatch return(clonestr("{\"error\":\"need to unlock wallet\"}")); retjson = cJSON_CreateObject(); retarray = cJSON_CreateArray(); - if ( (wacct= iguana_waccountfind(myinfo,account)) != 0 ) + if ( account == 0 || account[0] == 0 || (wacct= iguana_waccountfind(myinfo,account)) != 0 ) { if ( (array= iguana_getaddressesbyaccount(myinfo,coin,account)) != 0 ) { @@ -1768,7 +1768,8 @@ STRING_AND_THREEINTS(bitcoinrpc,listtransactions,account,count,skip,includewatch "blocktime": 1448045745, }*/ item = cJSON_CreateObject(); - jaddstr(item,"account",wacct->account); + if ( wacct != 0 ) + jaddstr(item,"account",wacct->account); iguana_txdetails(myinfo,coin,item,txid,vout,iguana_txidheight(myinfo,coin,txid)); jaddi(retarray,item); } diff --git a/iguana/tests/listtransactions b/iguana/tests/listtransactions index 430fee991..add0ca2e9 100755 --- a/iguana/tests/listtransactions +++ b/iguana/tests/listtransactions @@ -1,2 +1,2 @@ #!/bin/bash -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"listtransactions\",\"params\":[1, 9999999, [\"RUXwXF37SMA63vL4bUPnytP3KUwp69PCVv\"]]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"listtransactions\",\"params\":[1, 9999999, [\"RDBjpRUqV1AXzVJCBbbXNskgxGRj711qSc\"]]}" diff --git a/iguana/tests/listunspent b/iguana/tests/listunspent index 3f0142af8..5e66227ec 100755 --- a/iguana/tests/listunspent +++ b/iguana/tests/listunspent @@ -1,2 +1,2 @@ #!/bin/bash -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"method\":\"listunspent\",\"params\":[1, 9999999, []]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"listunspent\",\"params\":[1, 9999999, []]}" diff --git a/iguana/tests/listunspent2 b/iguana/tests/listunspent2 index 5e66227ec..b9c04d79b 100755 --- a/iguana/tests/listunspent2 +++ b/iguana/tests/listunspent2 @@ -1,2 +1,2 @@ #!/bin/bash -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"listunspent\",\"params\":[1, 9999999, []]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"listunspent\",\"params\":[1, 9999999, [\"RNJmgYaFF5DbnrNUX6pMYz9rcnDKC2tuAc\"]]}" From 53df2aebd5060374684c16b493afe55bd2cf98a1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 20:41:06 -0300 Subject: [PATCH 23/23] test --- iguana/tests/listtransactions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/tests/listtransactions b/iguana/tests/listtransactions index add0ca2e9..36926d8ed 100755 --- a/iguana/tests/listtransactions +++ b/iguana/tests/listtransactions @@ -1,2 +1,2 @@ #!/bin/bash -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"listtransactions\",\"params\":[1, 9999999, [\"RDBjpRUqV1AXzVJCBbbXNskgxGRj711qSc\"]]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"listtransactions\",\"params\":[1, 9999999, []]}"