From fff0f6c5454ae2edaa54cd9a67177332a82724fe Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 21 Mar 2018 21:39:52 +0200 Subject: [PATCH 1/6] Test --- crypto777/bitcoind_RPC.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto777/bitcoind_RPC.c b/crypto777/bitcoind_RPC.c index 810b2c96d..5983725a5 100755 --- a/crypto777/bitcoind_RPC.c +++ b/crypto777/bitcoind_RPC.c @@ -163,7 +163,7 @@ char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char * else specialcase = 0; if ( url[0] == 0 ) strcpy(url,"http://127.0.0.1:7776"); - if ( specialcase != 0 && (0) ) + //if ( specialcase != 0 && (0) ) printf("<<<<<<<<<<< bitcoind_RPC: userpass.(%s) url.(%s) command.(%s) params.(%s)\n",userpass,url,command,params); try_again: if ( retstrp != 0 ) From fee9b4cf9d9e803c87927a3d41f82abbb19af580 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 21 Mar 2018 21:53:22 +0200 Subject: [PATCH 2/6] Test --- crypto777/bitcoind_RPC.c | 6 +++--- iguana/dpow/dpow_fsm.c | 5 +++-- iguana/iguana_wallet.c | 21 +++++++++++++++++---- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/crypto777/bitcoind_RPC.c b/crypto777/bitcoind_RPC.c index 5983725a5..ad18bd919 100755 --- a/crypto777/bitcoind_RPC.c +++ b/crypto777/bitcoind_RPC.c @@ -73,8 +73,8 @@ char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char * long i,j,len; char *retstr = 0; cJSON *json,*result,*error; -#ifdef FROM_MARKETMAKER - //usleep(1000); +#ifndef FROM_MARKETMAKER + usleep(1000); #endif //printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr); if ( command == 0 || rpcstr == 0 || rpcstr[0] == 0 ) @@ -163,7 +163,7 @@ char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char * else specialcase = 0; if ( url[0] == 0 ) strcpy(url,"http://127.0.0.1:7776"); - //if ( specialcase != 0 && (0) ) + if ( specialcase != 0 && (0) ) printf("<<<<<<<<<<< bitcoind_RPC: userpass.(%s) url.(%s) command.(%s) params.(%s)\n",userpass,url,command,params); try_again: if ( retstrp != 0 ) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index eb5638ff4..98cf43934 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -309,7 +309,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu bits256 MoM,blockhash,merkle,*merkles; cJSON *blockjson; uint64_t signedmask; int32_t breakht=0,notht=0,ht,maxdepth = 1440,MoMdepth = 0; memset(MoM.bytes,0,sizeof(MoM)); blockhash = dpow_getblockhash(myinfo,coin,height); - //printf("start MoM calc %s height.%d\n",coin->symbol,height); + printf("start MoM calc %s height.%d\n",coin->symbol,height); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { merkle = jbits256(blockjson,"merkleroot"); @@ -349,6 +349,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu break; } ht = height - MoMdepth; + usleep(10000); } if ( MoMdepth > 0 ) { @@ -364,7 +365,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu } else printf("%s.ht%d null merkles\n",coin->symbol,height); } else printf("%s.ht%d null block\n",coin->symbol,height); *MoMdepthp = MoMdepth; - //printf("done MoM calc %s height.%d MoMdepth.%d\n",coin->symbol,height,MoMdepth); + printf("done MoM calc %s height.%d MoMdepth.%d\n",coin->symbol,height,MoMdepth); return(MoM); } diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index e125aea2a..acf956890 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -1342,7 +1342,7 @@ ZERO_ARGS(bitcoinrpc,walletlock) TWOSTRINGS_AND_INT(bitcoinrpc,walletpassphrase,password,permanentfile,timeout) { - char *retstr; + char *retstr,*tmpstr; cJSON *retjson; if ( remoteaddr != 0 ) return(clonestr("{\"error\":\"no remote\"}")); if ( timeout <= 0 ) @@ -1368,9 +1368,22 @@ TWOSTRINGS_AND_INT(bitcoinrpc,walletpassphrase,password,permanentfile,timeout) bitcoin_address(coin->changeaddr,coin->chain->pubtype,myinfo->persistent_pubkey33,33); if ( coin->FULLNODE < 0 ) { - char wifstr[64]; - bitcoin_priv2wif(wifstr,myinfo->persistent_priv,coin->chain->wiftype); - jumblr_importprivkey(myinfo,coin,wifstr); + char wifstr[64]; int32_t destvalid = 0; cJSON *ismine; + if ( (tmpstr= dpow_validateaddress(myinfo,coin,coin->changeaddr)) != 0 ) + { + retjson = cJSON_Parse(tmpstr); + if ( (ismine= jobj(json,"ismine")) != 0 && is_cJSON_True(ismine) != 0 ) + destvalid = 1; + else destvalid = 0; + free(tmpstr); + free(retjson); + tmpstr = 0; + } + if ( destvalid == 0 ) + { + bitcoin_priv2wif(wifstr,myinfo->persistent_priv,coin->chain->wiftype); + jumblr_importprivkey(myinfo,coin,wifstr); + } } } if ( bits256_nonz(myinfo->persistent_priv) != 0 ) From 4080b9a22f91a1c6e59b6c119fa0d7c8fa3c35e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 21 Mar 2018 21:59:46 +0200 Subject: [PATCH 3/6] Mutex MoM --- iguana/dpow/dpow_fsm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 98cf43934..b4d05421e 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -401,10 +401,10 @@ void dpow_statemachinestart(void *ptr) else if ( strcmp(dest->symbol,"KMD") == 0 ) { kmdheight = dest->longestchain; - //portable_mutex_lock(&myinfo->MoM_mutex); + portable_mutex_lock(&myinfo->MoM_mutex); //if ( Notaries_port != DPOW_SOCKPORT ) MoM = dpow_calcMoM(&MoMdepth,myinfo,src,checkpoint.blockhash.height); - //portable_mutex_unlock(&myinfo->MoM_mutex); + portable_mutex_unlock(&myinfo->MoM_mutex); } if ( (bp= dp->blocks[checkpoint.blockhash.height]) == 0 ) { From 70736e4ab3d6771d88aafaf6894b90292661842c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 21 Mar 2018 22:11:37 +0200 Subject: [PATCH 4/6] Test --- iguana/dpow/dpow_fsm.c | 4 ++-- iguana/iguana_init.c | 1 + includes/iguana_structs.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index b4d05421e..6a61c2f0e 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -401,10 +401,10 @@ void dpow_statemachinestart(void *ptr) else if ( strcmp(dest->symbol,"KMD") == 0 ) { kmdheight = dest->longestchain; - portable_mutex_lock(&myinfo->MoM_mutex); + portable_mutex_lock(&dest->MoM_mutex); //if ( Notaries_port != DPOW_SOCKPORT ) MoM = dpow_calcMoM(&MoMdepth,myinfo,src,checkpoint.blockhash.height); - portable_mutex_unlock(&myinfo->MoM_mutex); + portable_mutex_unlock(&dest->MoM_mutex); } if ( (bp= dp->blocks[checkpoint.blockhash.height]) == 0 ) { diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index bb3c92135..473b46953 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -68,6 +68,7 @@ void iguana_initcoin(struct iguana_info *coin,cJSON *argjson) portable_mutex_init(&coin->RTmutex); portable_mutex_init(&coin->kmdmutex); portable_mutex_init(&coin->peers_mutex); + portable_mutex_init(&coin->MoM_mutex); portable_mutex_init(&coin->blocks_mutex); portable_mutex_init(&coin->special_mutex); portable_mutex_init(&coin->allcoins_mutex); diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index e92e40fa3..feaf910e7 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -511,7 +511,7 @@ struct iguana_info struct OS_memspace TXMEM,MEM,MEMB[IGUANA_MAXBUNDLESIZE]; queue_t acceptQ,hdrsQ,blocksQ,priorityQ,possibleQ,cacheQ,recvQ,msgrequestQ,jsonQ,finishedQ; double parsemillis,avetime; uint32_t Launched[8],Terminated[8]; - portable_mutex_t peers_mutex,blocks_mutex,special_mutex,RTmutex,allcoins_mutex; + portable_mutex_t peers_mutex,blocks_mutex,special_mutex,RTmutex,allcoins_mutex,MoM_mutex; char changeaddr[64]; struct iguana_bundle *bundles[IGUANA_MAXBUNDLES],*current,*lastpending; struct OS_memspace RTrawmem,RTmem,RThashmem; // struct iguana_ramchain RTramchain; From a5a8562a6b3fc1f2b22027768f1c0ab4db574257 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 21 Mar 2018 22:18:39 +0200 Subject: [PATCH 5/6] Test --- iguana/dpow/dpow_fsm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 6a61c2f0e..b3729dc1b 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -260,19 +260,22 @@ int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supe if ( numnotaries >= DPOW_MIN_ASSETCHAIN_SIGS ) { hasnotarization = 1; - *nothtp = height - 10; + *nothtp = 0; if ( (vouts= jarray(&numvouts,txobj,"vout")) != 0 ) { bits256 blockhash,txid,MoM; uint32_t MoMdepth; char symbol[65];//,str[65],str2[65],str3[65]; vout = jitem(vouts,numvouts-1); - if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) > 35*2 && len < sizeof(script)*2 ) + if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) > 36*2 && len < sizeof(script)*2 ) { len >>= 1; decode_hex(script,len,hexstr); if ( dpow_opreturn_parsesrc(&blockhash,nothtp,&txid,symbol,&MoM,&MoMdepth,script,len) > 0 ) { - if ( bits256_nonz(MoM) == 0 || MoMdepth == 0 || *nothtp >= height || *nothtp < 0 ) - *nothtp = 0; + if ( Notaries_port != DPOW_SOCKPORT ) + { + if ( bits256_nonz(MoM) == 0 || MoMdepth == 0 || *nothtp >= height || *nothtp < 0 ) + *nothtp = 0; + } //printf("%s.%d notarizationht.%d %s -> %s MoM.%s [%d]\n",symbol,height,*nothtp,bits256_str(str,blockhash),bits256_str(str2,txid),bits256_str(str3,MoM),MoMdepth); } } @@ -329,7 +332,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu { breakht = notht; //free_json(blockjson); - //printf("%s has notarization at %d for breakht.%d\n",coin->symbol,ht,notht); + printf("%s has notarization at %d for breakht.%d\n",coin->symbol,ht,notht); } merkle = jbits256(blockjson,"merkleroot"); free_json(blockjson); @@ -402,8 +405,7 @@ void dpow_statemachinestart(void *ptr) { kmdheight = dest->longestchain; portable_mutex_lock(&dest->MoM_mutex); - //if ( Notaries_port != DPOW_SOCKPORT ) - MoM = dpow_calcMoM(&MoMdepth,myinfo,src,checkpoint.blockhash.height); + MoM = dpow_calcMoM(&MoMdepth,myinfo,src,checkpoint.blockhash.height); portable_mutex_unlock(&dest->MoM_mutex); } if ( (bp= dp->blocks[checkpoint.blockhash.height]) == 0 ) From 99c783017b7f392910226dea08acde25c9ae3387 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 21 Mar 2018 22:22:06 +0200 Subject: [PATCH 6/6] Test --- iguana/dpow/dpow_fsm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index b3729dc1b..a82f2f63e 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -404,9 +404,9 @@ void dpow_statemachinestart(void *ptr) else if ( strcmp(dest->symbol,"KMD") == 0 ) { kmdheight = dest->longestchain; - portable_mutex_lock(&dest->MoM_mutex); + portable_mutex_lock(&src->MoM_mutex); MoM = dpow_calcMoM(&MoMdepth,myinfo,src,checkpoint.blockhash.height); - portable_mutex_unlock(&dest->MoM_mutex); + portable_mutex_unlock(&src->MoM_mutex); } if ( (bp= dp->blocks[checkpoint.blockhash.height]) == 0 ) {