diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 4b75e35b2..75769ae74 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -288,11 +288,11 @@ trust(pubkey, trust)\n\ return(LP_peers()); else if ( strcmp(method,"getutxos") == 0 ) return(LP_utxos(1,LP_mypeer,jstr(argjson,"coin"),jint(argjson,"lastn"))); - else if ( strcmp(method,"notified") == 0 ) + else if ( strcmp(method,"utxo") == 0 ) { if ( LP_utxoaddjson(1,LP_mypubsock,argjson) != 0 ) - return(clonestr("{\"result\":\"success\",\"notifyutxo\":\"received\"}")); - else return(clonestr("{\"result\":\"couldnt add utxo\"}")); + retstr = clonestr("{\"result\":\"success\",\"notifyutxo\":\"received\"}"); + else retstr = clonestr("{\"result\":\"couldnt add utxo\"}"); } else { diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index 225d5cdeb..518d86d9d 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -241,51 +241,47 @@ void LP_broadcast_message(int32_t pubsock,char *base,char *rel,bits256 destpub25 encrypted = 1; free(msgstr), msgstr = 0; } - if ( IAMLP != 0 ) + if ( encrypted == 0 ) { - //printf("queuesend %d -> %d\n",msglen,pubsock); - LP_queuesend(crc32,pubsock,base,rel,msg,msglen); + if ( (argjson= cJSON_Parse(msgstr)) != 0 ) + { + if ( (methodstr= jstr(argjson,"method")) != 0 && strlen(methodstr) <= sizeof(method) ) + { + strcpy(method,methodstr); + jdelete(argjson,"method"); + jaddstr(argjson,"method2",method); + jaddstr(argjson,"method",method); + msg = (void *)jprint(argjson,0); + crc32 = calc_crc32(0,&msg[2],(int32_t)strlen((char *)msg)+1-2); + jdelete(argjson,"method"); + jaddstr(argjson,"method","broadcast"); + msg = (void *)jprint(argjson,0); + msglen = (int32_t)strlen((char *)msg) + 1; + if ( IAMLP != 0 ) + LP_queuesend(crc32,pubsock,base,rel,msg,msglen); + else LP_queuesend(crc32,-1,base,rel,msg,msglen); + free(msg); + } else printf("no valid method in (%s)\n",msgstr); + free_json(argjson); + } else printf("couldnt parse (%s)\n",msgstr); } else { - if ( encrypted == 0 ) - { - if ( (argjson= cJSON_Parse(msgstr)) != 0 ) - { - if ( (methodstr= jstr(argjson,"method")) != 0 && strlen(methodstr) <= sizeof(method) ) - { - strcpy(method,methodstr); - jdelete(argjson,"method"); - jaddstr(argjson,"method2",method); - jaddstr(argjson,"method",method); - msg = (void *)jprint(argjson,0); - crc32 = calc_crc32(0,&msg[2],(int32_t)strlen((char *)msg)+1-2); - jdelete(argjson,"method"); - jaddstr(argjson,"method","broadcast"); - msg = (void *)jprint(argjson,0); - msglen = (int32_t)strlen((char *)msg) + 1; - LP_queuesend(crc32,-1,base,rel,msg,msglen); - free(msg); - } else printf("no valid method in (%s)\n",msgstr); - free_json(argjson); - } else printf("couldnt parse (%s)\n",msgstr); - } - else - { - argjson = cJSON_CreateObject(); - init_hexbytes_noT(cipherstr,msg,msglen); - jaddstr(argjson,"cipher",cipherstr); - jaddstr(argjson,"method2","encrypted"); - jaddstr(argjson,"method","encrypted"); - msg = (void *)jprint(argjson,0); - crc32 = calc_crc32(0,&msg[2],(int32_t)strlen((char *)msg)+1-2); - jdelete(argjson,"method"); - jaddstr(argjson,"method","broadcast"); - msg = (void *)jprint(argjson,0); - msglen = (int32_t)strlen((char *)msg) + 1; - LP_queuesend(crc32,-1,base,rel,msg,msglen); - free(msg); - } + argjson = cJSON_CreateObject(); + init_hexbytes_noT(cipherstr,msg,msglen); + jaddstr(argjson,"cipher",cipherstr); + jaddstr(argjson,"method2","encrypted"); + jaddstr(argjson,"method","encrypted"); + msg = (void *)jprint(argjson,0); + crc32 = calc_crc32(0,&msg[2],(int32_t)strlen((char *)msg)+1-2); + jdelete(argjson,"method"); + jaddstr(argjson,"method","broadcast"); + msg = (void *)jprint(argjson,0); + msglen = (int32_t)strlen((char *)msg) + 1; + if ( IAMLP != 0 ) + LP_queuesend(crc32,pubsock,base,rel,msg,msglen); + else LP_queuesend(crc32,-1,base,rel,msg,msglen); + free(msg); } if ( msgstr != 0 ) free(msgstr); diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index 016a2a121..9ee1e5243 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -233,7 +233,7 @@ int32_t LP_utxopurge(int32_t allutxos) cJSON *LP_inventoryjson(cJSON *item,struct LP_utxoinfo *utxo) { struct _LP_utxoinfo u; - jaddstr(item,"method","notified"); + jaddstr(item,"method","utxo"); if ( utxo == 0 ) return(item); if ( utxo->gui[0] != 0 )