diff --git a/iguana/SuperNET_category.c b/iguana/SuperNET_category.c index 4f12bc559..4dd860116 100755 --- a/iguana/SuperNET_category.c +++ b/iguana/SuperNET_category.c @@ -210,7 +210,7 @@ char *bitcoin_hexmsg(struct supernet_info *myinfo,struct category_info *cat,void //printf("bitcoinprocess.(%s)\n",jprint(json,0)); agent = jstr(json,"agent"); method = jstr(json,"method"); - if ( (valsobj= jobj(json,"vals")) != 0 && strcmp(agent,"iguana") == 0 ) + if ( strcmp(agent,"iguana") == 0 ) { if ( jstr(valsobj,"coin") != 0 ) coin = iguana_coinfind(jstr(valsobj,"coin")); @@ -220,7 +220,7 @@ char *bitcoin_hexmsg(struct supernet_info *myinfo,struct category_info *cat,void { if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 ) { - if ( strcmp(method,"rawtx") == 0 ) + if ( (valsobj= jobj(json,"vals")) != 0 && strcmp(method,"rawtx") == 0 ) { retstr = iguana_rawtx(myinfo,coin,json,remoteaddr,jstr(json,"changeaddr"),jobj(json,"addresses"),valsobj,jstr(json,"spendscriptstr")); } @@ -230,7 +230,7 @@ char *bitcoin_hexmsg(struct supernet_info *myinfo,struct category_info *cat,void } if ( retstr == 0 ) return(0); - printf("RELAY will return.(%s)\n",retstr); + //printf("RELAY will return.(%s)\n",retstr); for (j=0; jvins); @@ -446,7 +447,7 @@ char *iguana_request_andwait(queue_t *Q,cJSON **vinsp,char *reqstr,uint32_t rawt char *iguana_rawtxissue(struct supernet_info *myinfo,uint32_t rawtxtag,char *symbol,cJSON **vinsp,uint32_t locktime,uint64_t satoshis,char *changeaddr,uint64_t txfee,cJSON *addresses,int32_t minconf,char *spendscriptstr) { - uint8_t buf[IGUANA_MAXSCRIPTSIZE]; int32_t spendlen; cJSON *hexjson,*reqjson,*valsobj,*txobj = 0; char *retstr,*rawtx = 0; struct iguana_info *coin; + uint8_t buf[IGUANA_MAXSCRIPTSIZE]; int32_t spendlen; cJSON *hexjson,*valsobj,*txobj = 0; char *retstr,*rawtx = 0; struct iguana_info *coin; *vinsp = 0; if ( (coin= iguana_coinfind(symbol)) != 0 && (coin->VALIDATENODE != 0 || coin->RELAYNODE != 0) ) { @@ -481,9 +482,8 @@ char *iguana_rawtxissue(struct supernet_info *myinfo,uint32_t rawtxtag,char *sym jadd(hexjson,"vals",valsobj); jaddstr(hexjson,"agent","iguana"); jaddstr(hexjson,"method","rawtx"); - reqjson = iguana_requestjson(myinfo,hexjson); //{\"agent\":\"iguana\",\"method\":\"rawtx\",\"changeaddr\":\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\",\"addresses\":[\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\"],\"vals\":{\"coin\":\"BTCD\",\"amount\":\"10000000\"},\"spendscriptstr\":\"76a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac\"} - if ( (retstr= iguana_request_andwait(&myinfo->rawtxQ,vinsp,jprint(reqjson,1),rawtxtag)) == 0 ) + if ( (retstr= iguana_request_andwait(myinfo,&myinfo->rawtxQ,vinsp,hexjson,rawtxtag)) == 0 ) return(clonestr("{\"error\":\"timeout waiting for remote request\"}")); else return(retstr); } @@ -567,7 +567,7 @@ char *iguana_createrawtx(struct supernet_info *myinfo,uint32_t rawtxtag,char *sy INT_ARRAY_STRING(iguana,balances,lastheight,addresses,activecoin) { - uint64_t amount,total = 0; cJSON *item,*result,*reqjson,*array,*retjson,*hexjson; int32_t i,n,minconf=0; char *retstr,*balancestr,*coinaddr; + uint64_t amount,total = 0; cJSON *item,*result,*array,*retjson,*hexjson; int32_t i,n,minconf=0; char *retstr,*balancestr,*coinaddr; retjson = cJSON_CreateObject(); if ( activecoin != 0 && activecoin[0] != 0 && (coin= iguana_coinfind(activecoin)) != 0 ) { @@ -613,10 +613,9 @@ INT_ARRAY_STRING(iguana,balances,lastheight,addresses,activecoin) } else jaddstr(retjson,"result","success"); return(jprint(retjson,1)); } - else if ( remoteaddr == 0 && remoteaddr[0] != 0 && strcmp(remoteaddr,"127.0.0.1") != 0 ) + else if ( remoteaddr == 0 || remoteaddr[0] == 0 || strcmp(remoteaddr,"127.0.0.1") == 0 ) { - reqjson = iguana_requestjson(myinfo,json); - if ( (retstr= iguana_request_andwait(&myinfo->rawtxQ,0,jprint(reqjson,1),lastheight)) == 0 ) + if ( (retstr= iguana_request_andwait(myinfo,&myinfo->rawtxQ,0,json,lastheight)) == 0 ) return(clonestr("{\"error\":\"timeout waiting for remote request\"}")); else return(retstr); } else return(clonestr("{\"error\":\"invalid remoterequest when not relaynode\"}"));