diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 4ea68f074..a0076c183 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -250,7 +250,7 @@ char *LP_process_message(void *ctx,char *typestr,char *myipaddr,int32_t pubsock, if ( duplicate != 0 ) dup++; else uniq++; - //portable_mutex_lock(&LP_commandmutex); + portable_mutex_lock(&LP_commandmutex); if ( (LP_rand() % 100000) == 0 ) printf("%s dup.%d (%u / %u) %.1f%% encrypted.%d recv.%u [%02x %02x] vs %02x %02x\n",typestr,duplicate,dup,dup+uniq,(double)100*dup/(dup+uniq),encrypted,crc32,ptr[0],ptr[1],crc32&0xff,(crc32>>8)&0xff); if ( duplicate == 0 ) @@ -341,7 +341,7 @@ char *LP_process_message(void *ctx,char *typestr,char *myipaddr,int32_t pubsock, free_json(argjson); } } //else printf("DUPLICATE.(%s)\n",(char *)ptr); - //portable_mutex_unlock(&LP_commandmutex); + portable_mutex_unlock(&LP_commandmutex); if ( jsonstr != 0 && (void *)jsonstr != (void *)ptr && encrypted == 0 ) free(jsonstr); return(retstr); @@ -448,7 +448,7 @@ int32_t LP_nanomsg_recvs(void *ctx) int32_t n=0,nonz = 0; char *origipaddr; struct LP_peerinfo *peer,*tmp; if ( (origipaddr= LP_myipaddr) == 0 ) origipaddr = "127.0.0.1"; - //portable_mutex_lock(&LP_nanorecvsmutex); + portable_mutex_lock(&LP_nanorecvsmutex); HASH_ITER(hh,LP_peerinfos,peer,tmp) { if ( n++ > 0 && peer->errors >= LP_MAXPEER_ERRORS ) @@ -474,7 +474,7 @@ int32_t LP_nanomsg_recvs(void *ctx) { nonz += LP_sock_check("PULL",ctx,origipaddr,-1,LP_mypullsock,"127.0.0.1",1); } - //portable_mutex_unlock(&LP_nanorecvsmutex); + portable_mutex_unlock(&LP_nanorecvsmutex); return(nonz); } diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index a2b9494a5..9c3c3ae47 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -254,7 +254,7 @@ int32_t LP_wifstr_valid(char *symbol,char *wifstr) bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguana_info *coin,char *passphrase,char *wifstr) { //static uint32_t counter; - bits256 privkey,userpub,zero,userpass,checkkey,tmpkey; char tmpstr[128]; cJSON *retjson; uint8_t tmptype; int32_t notarized; uint64_t nxtaddr; + bits256 privkey,userpub,zero,userpass,checkkey,tmpkey; char str[65],str2[65],tmpstr[128]; cJSON *retjson; uint8_t tmptype,sig[128]; int32_t notarized,siglen; uint64_t nxtaddr; if ( (wifstr == 0 || wifstr[0] == 0) && LP_wifstr_valid(coin->symbol,passphrase) > 0 ) { wifstr = passphrase; @@ -294,6 +294,17 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan RS_encode(G.LP_NXTaddr,nxtaddr); } bitcoin_priv2pub(ctx,coin->symbol,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype); + OS_randombytes(tmpkey.bytes,sizeof(tmpkey)); + if ( bits256_nonz(privkey) == 0 || (siglen= bitcoin_sign(ctx,coin->symbol,sig,tmpkey,privkey,0)) <= 0 ) + { + printf("illegal privkey %s\n",bits256_str(str,privkey)); + exit(0); + } + if ( bitcoin_verify(ctx,sig,siglen,tmpkey,coin->pubkey33,33) != 0 ) + { + printf("signature.[%d] for %s by %s didnt verify\n",siglen,bits256_str(str,tmpkey),bits256_str(str2,privkey)); + exit(0); + } if ( coin->counter == 0 ) { coin->counter++; diff --git a/iguana/exchanges/LP_secp.c b/iguana/exchanges/LP_secp.c index 516e2be75..fe8e2e937 100644 --- a/iguana/exchanges/LP_secp.c +++ b/iguana/exchanges/LP_secp.c @@ -94,7 +94,7 @@ int32_t bitcoin_sign(void *ctx,char *symbol,uint8_t *sig,bits256 txhash2,bits256 funcp = secp256k1_nonce_function_rfc6979; if ( secp256k1_ec_seckey_verify(ctx,privkey.bytes) == 0 ) { - //printf("bitcoin_sign illegal privkey\n"); + printf("bitcoin_sign illegal privkey\n"); return(-1); } if ( strcmp(symbol,"BCH") == 0 || strcmp(symbol,"BTG") == 0 ) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 68568345b..9be0e469c 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -444,7 +444,7 @@ int32_t bitcoin_verifyvins(void *ctx,char *symbol,uint8_t taddr,uint8_t pubtype, if ( sig == 0 || siglen == 0 ) { memset(vp->signers[j].pubkey,0,sizeof(vp->signers[j].pubkey)); - printf("no sig.%p or siglen.%d zero\n",sig,siglen); + char str[65]; printf("no sig.%p or siglen.%d zero priv.(%s)\n",sig,siglen,bits256_str(str,vp->signers[j].privkey)); continue; } if ( bitcoin_verify(ctx,sig,siglen-1,sigtxid,vp->signers[j].pubkey,bitcoin_pubkeylen(vp->signers[j].pubkey)) < 0 )