Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
75b82a2a5b
  1. 33
      iguana/SuperNET_category.c
  2. 22
      iguana/iguana_payments.c
  3. 1
      iguana/tests/ltest

33
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 *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 ) if ( (json= cJSON_Parse(ptr)) != 0 )
{ {
//printf("bitcoinprocess.(%s)\n",jprint(json,0)); //printf("bitcoinprocess.(%s)\n",jprint(json,0));
@ -214,17 +214,42 @@ 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 ( 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"));
} }
else if ( strcmp(method,"rawtx_result") == 0 ) for (j=0; j<IGUANA_MAXCOINS; j++)
{
if ( (coin= Coins[j]) == 0 )
continue;
for (i=0; i<IGUANA_MAXPEERS; i++)
{
if ( (addr= &coin->peers.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 )
{ {
return(iguana_rawtx_result(myinfo,coin,json,remoteaddr,juint(json,"rawtxtag"),jobj(json,"vins"),jstr(json,"rawtx"))); return(iguana_rawtx_result(myinfo,coin,json,remoteaddr,juint(json,"rawtxtag"),jobj(json,"vins"),jstr(json,"rawtx")));
} }
} }
} }
} }
}
printf("bitcoin_hexmsg.(%s) from %s (%s/%s)\n",(char *)ptr,remoteaddr,agent,method); printf("bitcoin_hexmsg.(%s) from %s (%s/%s)\n",(char *)ptr,remoteaddr,agent,method);
return(retstr); return(retstr);
} }

22
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) 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); //printf("RAWTX changeaddr.%s (%s) remote.(%s)\n",changeaddr==0?"":changeaddr,jprint(json,0),remoteaddr);
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
if ( spendscriptstr != 0 && spendscriptstr[0] != 0 && (symbol= jstr(vals,"coin")) != 0 ) 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); jaddbits256(retjson,"categoryhash",myinfo->bitcoin_category);
jaddnum(retjson,"timeout",5000); jaddnum(retjson,"timeout",5000);
jaddstr(retjson,"hexmsg",buf); jaddstr(retjson,"hexmsg",buf);
for (j=0; j<IGUANA_MAXCOINS; j++)
{
if ( (coin= Coins[j]) == 0 )
continue;
for (i=0; i<IGUANA_MAXPEERS; i++)
{
if ( (addr= &coin->peers.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); } else jaddstr(retjson,"result",rawtx);
free(rawtx); free(rawtx);
} else jaddstr(retjson,"error","couldnt create rawtx"); } else jaddstr(retjson,"error","couldnt create rawtx");

1
iguana/tests/ltest

@ -0,0 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"listunspent\",\"params\":[1, 9999999, [\"RDxggCVF42Ds19DLNSjC6e3BaFk4ScCb2T\"]]}"
Loading…
Cancel
Save