|
|
@ -111,9 +111,21 @@ void LP_forwarding_register(bits256 pubkey,char *pushaddr,int32_t max) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
cJSON *LP_dereference(cJSON *argjson,char *excludemethod) |
|
|
|
{ |
|
|
|
cJSON *reqjson = 0; |
|
|
|
if ( jstr(argjson,"method2") != 0 && strncmp(excludemethod,jstr(argjson,"method2"),strlen(excludemethod)) != 0 ) |
|
|
|
{ |
|
|
|
reqjson = jduplicate(argjson); |
|
|
|
jdelete(reqjson,"method"); |
|
|
|
jaddstr(reqjson,"method",jstr(argjson,"method2")); |
|
|
|
} |
|
|
|
return(reqjson); |
|
|
|
} |
|
|
|
|
|
|
|
char *LP_forwardhex(bits256 pubkey,char *hexstr) |
|
|
|
{ |
|
|
|
struct LP_forwardinfo *ptr=0; uint8_t *data; int32_t datalen=0,sentbytes=0; char *retstr=0; cJSON *retjson,*argjson; |
|
|
|
struct LP_forwardinfo *ptr=0; uint8_t *data; int32_t datalen=0,sentbytes=0; char *retstr=0; cJSON *retjson,*argjson,*reqjson; |
|
|
|
if ( hexstr == 0 || hexstr[0] == 0 ) |
|
|
|
return(clonestr("{\"error\":\"nohex\"}")); |
|
|
|
if ( bits256_nonz(pubkey) == 0 || bits256_cmp(pubkey,LP_mypubkey) == 0 ) |
|
|
@ -123,7 +135,9 @@ char *LP_forwardhex(bits256 pubkey,char *hexstr) |
|
|
|
decode_hex(data,datalen,hexstr); |
|
|
|
if ( (argjson= cJSON_Parse((char *)data)) != 0 ) |
|
|
|
{ |
|
|
|
retstr = LP_command_process(LP_mypeer != 0 ? LP_mypeer->ipaddr : "127.0.0.1",LP_mypubsock,argjson,0,0,LP_profitratio - 1.); |
|
|
|
reqjson = LP_dereference(argjson,"forward"); |
|
|
|
retstr = LP_command_process(LP_mypeer != 0 ? LP_mypeer->ipaddr : "127.0.0.1",LP_mypubsock,reqjson,0,0,LP_profitratio - 1.); |
|
|
|
free_json(reqjson); |
|
|
|
free_json(argjson); |
|
|
|
} |
|
|
|
return(retstr); |
|
|
|