diff --git a/basilisk/basilisk_CMD.c b/basilisk/basilisk_CMD.c index f264a09be..197d8f284 100755 --- a/basilisk/basilisk_CMD.c +++ b/basilisk/basilisk_CMD.c @@ -44,13 +44,14 @@ char *basilisk_addrelay_info(struct supernet_info *myinfo,uint8_t *pubkey33,uint rp->pubkey = pubkey; if ( pubkey33[0] != 0 ) memcpy(rp->pubkey33,pubkey33,33); + printf("updated %x\n",ipbits); return(clonestr("{\"error\":\"relay already there\"}")); } } if ( i >= sizeof(myinfo->relays)/sizeof(*myinfo->relays) ) i = (rand() % (sizeof(myinfo->relays)/sizeof(*myinfo->relays))); + printf("add relay[%d] <- %x\n",i,ipbits); rp = &myinfo->relays[i]; - printf("verify relay sig for %x\n",ipbits); rp->ipbits = ipbits; rp->addr = basilisk_ensurerelay(btcd,rp->ipbits); for (i=0; inumrelays; i++) @@ -61,16 +62,18 @@ char *basilisk_addrelay_info(struct supernet_info *myinfo,uint8_t *pubkey33,uint char *basilisk_respond_relays(struct supernet_info *myinfo,char *CMD,void *_addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) { - bits256 txhash2; uint32_t ipbits; int32_t i,n,len,siglen; uint8_t pubkey33[33],sig[128]; char *sigstr = 0,*retstr; + bits256 txhash2; uint32_t ipbits; int32_t i,n,len,siglen; uint8_t pubkey33[33],sig[128]; char *sigstr = 0,*retstr,pubstr[128]; if ( (sigstr= jstr(valsobj,"sig")) != 0 ) { siglen = (int32_t)strlen(sigstr) >> 1; decode_hex(sig,siglen,sigstr); vcalc_sha256(0,txhash2.bytes,data,datalen); - if ( 1 || bitcoin_recoververify(myinfo->ctx,"BTCD",sig,txhash2,pubkey33) == 0 ) + memset(pubkey33,0,33); + if ( bitcoin_recoververify(myinfo->ctx,"BTCD",sig,txhash2,pubkey33) == 0 || 1 ) { // compare with existing - printf("verified relay data sig.%d\n",siglen); + init_hexbytes_noT(pubstr,pubkey33,33); + printf("skip verified relay data siglen.%d pub33.%s\n",siglen,pubstr); if ( (retstr= basilisk_addrelay_info(myinfo,pubkey33,(uint32_t)calc_ipbits(remoteaddr),hash)) != 0 ) free(retstr); n = (int32_t)(datalen / sizeof(uint32_t)); diff --git a/iguana/iguana_msg.c b/iguana/iguana_msg.c index eaa16f37e..3380d7fb9 100755 --- a/iguana/iguana_msg.c +++ b/iguana/iguana_msg.c @@ -377,17 +377,19 @@ int32_t iguana_send_VPNversion(struct iguana_info *coin,struct iguana_peer *addr return(iguana_queue_send(addr,0,serialized,"version",len)); } -void iguana_supernet_ping(struct iguana_peer *addr) +void iguana_supernet_ping(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr) { if ( addr->supernet != 0 || addr->basilisk != 0 ) { + if ( coin->RELAYNODE != 0 ) + basilisk_relays_send(myinfo,addr); //printf("send getpeers to %s\n",addr->ipaddr); - printf("maybe send basilisk ping here?\n"); + //printf("maybe send basilisk ping here?\n"); //iguana_send_supernet(addr,SUPERNET_GETPEERSTR,0); } } -void iguana_gotverack(struct iguana_info *coin,struct iguana_peer *addr) +void iguana_gotverack(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr) { uint8_t serialized[sizeof(struct iguana_msghdr)]; if ( addr != 0 ) @@ -395,7 +397,7 @@ void iguana_gotverack(struct iguana_info *coin,struct iguana_peer *addr) //printf("gotverack from %s\n",addr->ipaddr); addr->A.nTime = (uint32_t)time(NULL); iguana_queue_send(addr,0,serialized,"getaddr",0); - iguana_supernet_ping(addr); + iguana_supernet_ping(myinfo,coin,addr); } } @@ -419,14 +421,14 @@ void iguana_gotaddr(struct iguana_info *coin,struct iguana_peer *addr,struct igu //printf("gotaddr.(%s:%d) from (%s)\n",ipaddr,port,addr->ipaddr); } -void iguana_gotping(struct iguana_info *coin,struct iguana_peer *addr,uint64_t nonce,uint8_t *data) +void iguana_gotping(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,uint64_t nonce,uint8_t *data) { int32_t len; uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(nonce)]; len = iguana_rwnum(1,&serialized[sizeof(struct iguana_msghdr)],sizeof(uint64_t),&nonce); if ( memcmp(data,&serialized[sizeof(struct iguana_msghdr)],sizeof(nonce)) != 0 ) printf("ping ser error %llx != %llx\n",(long long)nonce,*(long long *)data); iguana_queue_send(addr,0,serialized,"pong",len); - iguana_supernet_ping(addr); + iguana_supernet_ping(myinfo,coin,addr); } int32_t iguana_send_ping(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr) @@ -441,7 +443,7 @@ int32_t iguana_send_ping(struct supernet_info *myinfo,struct iguana_info *coin,s //printf("pingnonce.%llx from (%s)\n",(long long)nonce,addr->ipaddr); iguana_queue_send(addr,0,serialized,"getaddr",0); len = iguana_rwnum(1,&serialized[sizeof(struct iguana_msghdr)],sizeof(uint64_t),&nonce); - iguana_supernet_ping(addr); + iguana_supernet_ping(myinfo,coin,addr); if ( myinfo->IAMRELAY != 0 ) basilisk_relays_send(myinfo,addr); return(iguana_queue_send(addr,0,serialized,"ping",len)); @@ -947,7 +949,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc } else { - iguana_gotverack(coin,addr); + iguana_gotverack(myinfo,coin,addr); addr->msgcounts.verack++; len = 0; } @@ -964,7 +966,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc //printf("%u got nonce.%llx from %s\n",(uint32_t)time(NULL),(long long)nonce,addr->ipaddr); if ( ishost != 0 ) { - iguana_gotping(coin,addr,nonce,data); + iguana_gotping(myinfo,coin,addr,nonce,data); addr->msgcounts.ping++; } else