diff --git a/iguana/SuperNET_category.c b/iguana/SuperNET_category.c index 12d806b9e..647723455 100755 --- a/iguana/SuperNET_category.c +++ b/iguana/SuperNET_category.c @@ -204,7 +204,7 @@ char *SuperNET_categorymulticast(struct supernet_info *myinfo,int32_t surveyflag char *bitcoin_hexmsg(struct supernet_info *myinfo,struct category_info *cat,void *ptr,int32_t len,char *remoteaddr) { - char *method="",*agent="",*retstr = 0; cJSON *json,*valsobj; struct iguana_info *coin; + char *method="",*agent="",*retstr = 0; int32_t i,j; cJSON *json,*valsobj; struct iguana_info *coin; struct iguana_peer *addr; if ( (json= cJSON_Parse(ptr)) != 0 ) { //printf("bitcoinprocess.(%s)\n",jprint(json,0)); @@ -214,13 +214,38 @@ char *bitcoin_hexmsg(struct supernet_info *myinfo,struct category_info *cat,void { if ( jstr(valsobj,"coin") != 0 && (coin= iguana_coinfind(jstr(valsobj,"coin"))) != 0 ) { - if ( strcmp(method,"rawtx") == 0 && (coin->RELAYNODE != 0 || coin->VALIDATENODE != 0) ) + if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 ) { - return(iguana_rawtx(myinfo,coin,json,remoteaddr,jstr(json,"changeaddr"),jobj(json,"addresses"),valsobj,jstr(json,"spendscriptstr"))); + if ( strcmp(method,"rawtx") == 0 ) + { + retstr = iguana_rawtx(myinfo,coin,json,remoteaddr,jstr(json,"changeaddr"),jobj(json,"addresses"),valsobj,jstr(json,"spendscriptstr")); + } + for (j=0; jpeers.active[i]) != 0 && addr->usock >= 0 ) + { + if ( addr->supernet != 0 && strcmp(addr->ipaddr,remoteaddr) == 0 ) + { + printf("send back rawtx_result addr->supernet.%u to (%s)\n",addr->supernet,addr->ipaddr); + iguana_send_supernet(addr,retstr,0); + return(retstr); + } + } + if ( 0 && addr->ipbits != 0 ) + printf("i.%d (%s) vs (%s) %s\n",i,addr->ipaddr,remoteaddr,coin->symbol); + } + } } - else if ( strcmp(method,"rawtx_result") == 0 ) + else { - return(iguana_rawtx_result(myinfo,coin,json,remoteaddr,juint(json,"rawtxtag"),jobj(json,"vins"),jstr(json,"rawtx"))); + if ( strcmp(method,"rawtx_result") == 0 ) + { + return(iguana_rawtx_result(myinfo,coin,json,remoteaddr,juint(json,"rawtxtag"),jobj(json,"vins"),jstr(json,"rawtx"))); + } } } } diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index 09e94a779..edb74b276 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -545,7 +545,7 @@ char *iguana_createrawtx(struct supernet_info *myinfo,uint32_t rawtxtag,char *sy STRING_ARRAY_OBJ_STRING(iguana,rawtx,changeaddr,addresses,vals,spendscriptstr) { - cJSON *vins=0,*retjson,*hexjson,*valsobj; char buf[2*IGUANA_MAXSCRIPTSIZE+8192],*str,*rawtx=0,*symbol=0; int64_t txfee,satoshis; uint32_t i,j,locktime,minconf,rawtxtag; struct iguana_peer *addr; + cJSON *vins=0,*retjson,*hexjson,*valsobj; char buf[2*IGUANA_MAXSCRIPTSIZE+8192],*str,*rawtx=0,*symbol=0; int64_t txfee,satoshis; uint32_t locktime,minconf,rawtxtag; //printf("RAWTX changeaddr.%s (%s) remote.(%s)\n",changeaddr==0?"":changeaddr,jprint(json,0),remoteaddr); retjson = cJSON_CreateObject(); if ( spendscriptstr != 0 && spendscriptstr[0] != 0 && (symbol= jstr(vals,"coin")) != 0 ) @@ -582,26 +582,6 @@ STRING_ARRAY_OBJ_STRING(iguana,rawtx,changeaddr,addresses,vals,spendscriptstr) jaddbits256(retjson,"categoryhash",myinfo->bitcoin_category); jaddnum(retjson,"timeout",5000); jaddstr(retjson,"hexmsg",buf); - for (j=0; jpeers.active[i]) != 0 && addr->usock >= 0 ) - { - if ( addr->supernet != 0 && strcmp(addr->ipaddr,remoteaddr) == 0 ) - { - printf("send back rawtx_result addr->supernet.%u to (%s)\n",addr->supernet,addr->ipaddr); - iguana_send_supernet(addr,jprint(retjson,0),0); - free(rawtx); - return(jprint(retjson,1)); - } - } - if ( 0 && addr->ipbits != 0 ) - printf("i.%d (%s) vs (%s) %s\n",i,addr->ipaddr,remoteaddr,coin->symbol); - } - } } else jaddstr(retjson,"result",rawtx); free(rawtx); } else jaddstr(retjson,"error","couldnt create rawtx"); diff --git a/iguana/tests/ltest b/iguana/tests/ltest new file mode 100755 index 000000000..76fd2fe8f --- /dev/null +++ b/iguana/tests/ltest @@ -0,0 +1 @@ +curl --url "http://127.0.0.1:7778" --data "{\"method\":\"listunspent\",\"params\":[1, 9999999, [\"RDxggCVF42Ds19DLNSjC6e3BaFk4ScCb2T\"]]}"