diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index a1f4db3bc..bb16a60ee 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -474,12 +474,19 @@ dividends(coin, height, )\n\ } else if ( strcmp(method,"notify") == 0 ) { - char *rmd160str; bits256 pub; struct LP_pubkeyinfo *pubp; + char *rmd160str,*secpstr; bits256 pub; struct LP_pubkeyinfo *pubp; pub = jbits256(argjson,"pub"); if ( bits256_nonz(pub) != 0 && (rmd160str= jstr(argjson,"rmd160")) != 0 && strlen(rmd160str) == 40 ) { if ( (pubp= LP_pubkeyadd(pub)) != 0 ) + { decode_hex(pubp->rmd160,20,rmd160str); + if ( (secpstr= jstr(argjson,"pubsecp")) != 0 ) + { + decode_hex(pubp->pubsecp,sizeof(pubp->pubsecp),secpstr); + printf("got pubkey.(%s)\n",secpstr); + } + } //printf("NOTIFIED pub %s rmd160 %s\n",bits256_str(str,pub),rmd160str); } retstr = clonestr("{\"result\":\"success\",\"notify\":\"received\"}"); diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 2e94838d8..07af4de99 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -413,13 +413,14 @@ int32_t LP_utxos_sync(struct LP_peerinfo *peer) int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int32_t pubsock,char *pushaddr,uint16_t myport) { static uint32_t counter,numpeers; - struct iguana_info *coin,*ctmp; char *retstr,*origipaddr; struct LP_peerinfo *peer,*tmp; uint32_t now; bits256 zero; int32_t height,nonz = 0; + struct iguana_info *coin,*ctmp; char *retstr,*origipaddr; struct LP_peerinfo *peer,*tmp; uint32_t now; bits256 zero; int32_t needpings,height,nonz = 0; now = (uint32_t)time(NULL); if ( (origipaddr= myipaddr) == 0 ) origipaddr = "127.0.0.1"; if ( mypeer == 0 ) myipaddr = "127.0.0.1"; numpeers = LP_numpeers(); + needpings = 0; HASH_ITER(hh,LP_peerinfos,peer,tmp) { if ( peer->errors >= LP_MAXPEER_ERRORS ) @@ -450,11 +451,17 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int } if ( peer->needping != 0 ) { + needpings++; if ( (retstr= issue_LP_notify(peer->ipaddr,peer->port,"127.0.0.1",0,numpeers,G.LP_sessionid,G.LP_myrmd160str,G.LP_mypub25519)) != 0 ) free(retstr); peer->needping = 0; } } + if ( needpings != 0 ) + { + printf("needpings.%d send notify\n",needpings); + LP_notify_pubkeys(ctx,pubsock); + } if ( (counter % 6000) == 10 ) { LP_privkey_updates(ctx,pubsock,0); diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 5f443beaf..9a536a236 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -231,6 +231,19 @@ char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *re return(clonestr("{\"result\":\"success\"}")); } +void LP_notify_pubkeys(void *ctx,int32_t pubsock) +{ + bits256 zero; char *msg,secpstr[67]; cJSON *reqjson = cJSON_CreateObject(); + memset(zero.bytes,0,sizeof(zero)); + jaddstr(reqjson,"method","notify"); + jaddstr(reqjson,"rmd160",G.LP_myrmd160str); + jaddbits256(reqjson,"pub",G.LP_mypub25519); + init_hexbytes_noT(secpstr,G.LP_pubsecp,33); + jaddstr(reqjson,"pubsecp",secpstr); + msg = jprint(reqjson,1); + LP_broadcast_message(pubsock,"","",zero,msg); +} + char *LP_postedprice(cJSON *argjson) { bits256 pubkey; double price; char *base,*rel;