Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
a7884832fc
  1. 6
      iguana/SuperNET_category.c
  2. 20
      iguana/iguana_payments.c
  3. 2
      iguana/iguana_sign.c
  4. 2
      iguana/ramchain_api.c
  5. 1
      iguana/swaps/iguana_BTCswap.c
  6. 2
      iguana/tests/balances

6
iguana/SuperNET_category.c

@ -242,7 +242,7 @@ char *bitcoin_hexmsg(struct supernet_info *myinfo,struct category_info *cat,void
{
if ( addr->supernet != 0 && strcmp(addr->ipaddr,remoteaddr) == 0 )
{
printf("send back rawtx_result addr->supernet.%u to (%s)\n",addr->supernet,addr->ipaddr);
//printf("send back rawtx_result addr->supernet.%u to (%s)\n",addr->supernet,addr->ipaddr);
iguana_send_supernet(addr,retstr,0);
free_json(json);
return(retstr);
@ -263,7 +263,7 @@ char *bitcoin_hexmsg(struct supernet_info *myinfo,struct category_info *cat,void
}
}
}
printf("bitcoin_hexmsg.(%s) from %s (%s/%s)\n",(char *)ptr,remoteaddr,agent,method);
printf("bitcoin_hexmsg.(%d) from %s (%s/%s)\n",len,remoteaddr,agent,method);
free_json(json);
return(retstr);
}
@ -283,7 +283,7 @@ void category_init(struct supernet_info *myinfo)
category_processfunc(instantdexhash,GENESIS_PUBKEY,InstantDEX_hexmsg);
category_processfunc(instantdexhash,myinfo->myaddr.persistent,InstantDEX_hexmsg);
bitcoinhash = calc_categoryhashes(0,"InstantDEX",0);
bitcoinhash = calc_categoryhashes(0,"bitcoin",0);
myinfo->bitcoin_category = bitcoinhash;
category_subscribe(myinfo,bitcoinhash,GENESIS_PUBKEY);
category_processfunc(bitcoinhash,GENESIS_PUBKEY,bitcoin_hexmsg);

20
iguana/iguana_payments.c

@ -393,7 +393,7 @@ cJSON *iguana_requestjson(struct supernet_info *myinfo,cJSON *hexjson)
return(retjson);
}
char *iguana_request_andwait(struct supernet_info *myinfo,queue_t *Q,cJSON **vinsp,cJSON *reqjson,uint32_t rawtxtag)
char *iguana_request_andwait(struct supernet_info *myinfo,queue_t *Q,cJSON **vinsp,cJSON *reqjson,uint32_t rawtxtag,int32_t timeout)
{
struct rawtx_queue *ptr; int32_t i,j,n; struct iguana_peer *addr; double expiration; struct iguana_info *coin; char *rawtx,*reqstr; cJSON *tmpjson;
if ( vinsp != 0 )
@ -405,7 +405,7 @@ char *iguana_request_andwait(struct supernet_info *myinfo,queue_t *Q,cJSON **vin
free_json(ptr->vins);
free(ptr);
}
expiration = OS_milliseconds() + 3333;
expiration = OS_milliseconds() + ((timeout == 0) ? 15000 : timeout);
for (i=n=0; i<IGUANA_MAXCOINS; i++)
{
if ( (coin= Coins[i]) != 0 )
@ -445,7 +445,7 @@ char *iguana_request_andwait(struct supernet_info *myinfo,queue_t *Q,cJSON **vin
return(0);
}
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)
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,int32_t timeout)
{
uint8_t buf[IGUANA_MAXSCRIPTSIZE]; int32_t spendlen; cJSON *hexjson,*valsobj,*txobj = 0; char *retstr,*rawtx = 0; struct iguana_info *coin;
*vinsp = 0;
@ -483,7 +483,7 @@ char *iguana_rawtxissue(struct supernet_info *myinfo,uint32_t rawtxtag,char *sym
jaddstr(hexjson,"agent","iguana");
jaddstr(hexjson,"method","rawtx");
//{\"agent\":\"iguana\",\"method\":\"rawtx\",\"changeaddr\":\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\",\"addresses\":[\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\"],\"vals\":{\"coin\":\"BTCD\",\"amount\":\"10000000\"},\"spendscriptstr\":\"76a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac\"}
if ( (retstr= iguana_request_andwait(myinfo,&myinfo->rawtxQ,vinsp,hexjson,rawtxtag)) == 0 )
if ( (retstr= iguana_request_andwait(myinfo,&myinfo->rawtxQ,vinsp,hexjson,rawtxtag,timeout)) == 0 )
return(clonestr("{\"error\":\"timeout waiting for remote request\"}"));
else return(retstr);
}
@ -508,7 +508,7 @@ char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *
bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr);
spendlen = bitcoin_standardspend(spendscript,0,rmd160);
init_hexbytes_noT(spendscriptstr,spendscript,spendlen);
if ( (rawtx= iguana_rawtxissue(myinfo,rand(),coin->symbol,&vins,locktime,satoshis,coin->changeaddr,txfee,addresses,minconf,spendscriptstr)) != 0 )
if ( (rawtx= iguana_rawtxissue(myinfo,rand(),coin->symbol,&vins,locktime,satoshis,coin->changeaddr,txfee,addresses,minconf,spendscriptstr,15000)) != 0 )
{
if ( (signedtx= iguana_signrawtx(myinfo,coin,&signedtxid,&completed,vins,rawtx)) != 0 )
{
@ -540,11 +540,11 @@ char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *
return(clonestr("{\"error\":\"need address and amount\"}"));
}
char *iguana_createrawtx(struct supernet_info *myinfo,uint32_t rawtxtag,char *symbol,cJSON **vinsp,uint32_t locktime,uint64_t satoshis,char *spendscriptstr,char *changeaddr,int64_t txfee,int32_t minconf,cJSON *addresses)
char *iguana_createrawtx(struct supernet_info *myinfo,uint32_t rawtxtag,char *symbol,cJSON **vinsp,uint32_t locktime,uint64_t satoshis,char *spendscriptstr,char *changeaddr,int64_t txfee,int32_t minconf,cJSON *addresses,int32_t timeout)
{
char *rawtx=0;
*vinsp = 0;
if ( (rawtx= iguana_rawtxissue(myinfo,rawtxtag,symbol,vinsp,locktime,satoshis,changeaddr,txfee,addresses,minconf,spendscriptstr)) != 0 )
if ( (rawtx= iguana_rawtxissue(myinfo,rawtxtag,symbol,vinsp,locktime,satoshis,changeaddr,txfee,addresses,minconf,spendscriptstr,timeout)) != 0 )
{
/*if ( *vinsp != 0 && (coin= iguana_coinfind(symbol)) != 0 && (signedtx= iguana_signrawtx(myinfo,coin,&signedtxid,&completed,*vinsp,rawtx)) != 0 )
{
@ -603,7 +603,7 @@ INT_ARRAY_STRING(iguana,balances,lastheight,addresses,activecoin)
jaddnum(retjson,"lastheight",lastheight);
if ( remoteaddr != 0 && remoteaddr[0] != 0 && strcmp(remoteaddr,"127.0.0.1") != 0 )
{
printf("remote req.(%s)\n",jprint(retjson,0));
//printf("remote req.(%s)\n",jprint(retjson,0));
hexjson = cJSON_CreateObject();
jaddstr(hexjson,"rawtx",jprint(retjson,1));
jaddstr(hexjson,"agent","iguana");
@ -616,7 +616,7 @@ INT_ARRAY_STRING(iguana,balances,lastheight,addresses,activecoin)
}
else if ( remoteaddr == 0 || remoteaddr[0] == 0 || strcmp(remoteaddr,"127.0.0.1") == 0 )
{
if ( (retstr= iguana_request_andwait(myinfo,&myinfo->rawtxQ,0,json,lastheight)) == 0 )
if ( (retstr= iguana_request_andwait(myinfo,&myinfo->rawtxQ,0,json,lastheight,juint(json,"timeout"))) == 0 )
return(clonestr("{\"error\":\"timeout waiting for remote request\"}"));
else return(retstr);
} else return(clonestr("{\"error\":\"invalid remoterequest when not relaynode\"}"));
@ -636,7 +636,7 @@ STRING_ARRAY_OBJ_STRING(iguana,rawtx,changeaddr,addresses,vals,spendscriptstr)
txfee = j64bits(vals,"txfee");
if ( (rawtxtag= juint(vals,"rawtxtag")) == 0 )
OS_randombytes((uint8_t *)&rawtxtag,sizeof(rawtxtag));
if ( (rawtx= iguana_createrawtx(myinfo,rawtxtag,symbol,&vins,locktime,satoshis,spendscriptstr,changeaddr,txfee,minconf,addresses)) != 0 )
if ( (rawtx= iguana_createrawtx(myinfo,rawtxtag,symbol,&vins,locktime,satoshis,spendscriptstr,changeaddr,txfee,minconf,addresses,juint(json,"timeout"))) != 0 )
{
//printf("return rawtx.(%s) remote.%p symbol.%s\n",rawtx,remoteaddr,symbol);
if ( remoteaddr != 0 && remoteaddr[0] != 0 && (coin= iguana_coinfind(symbol)) != 0 )

2
iguana/iguana_sign.c

@ -90,7 +90,7 @@ int32_t iguana_voutparse(int32_t rwflag,uint8_t *serialized,struct iguana_msgvou
if ( rwflag == 0 )
msg->pk_script = &serialized[len];
else memcpy(&serialized[len],msg->pk_script,msg->pk_scriptlen);
if ( 1 )
if ( 0 )
{
int32_t i;
for (i=0; i<msg->pk_scriptlen; i++)

2
iguana/ramchain_api.c

@ -50,7 +50,7 @@ TWO_STRINGS_AND_TWO_DOUBLES(iguana,balance,activecoin,address,lastheightd,mincon
memset(pubkey33,0,sizeof(pubkey33));
P = calloc(coin->bundlescount,sizeof(*P));
array = cJSON_CreateArray();
printf("Start %s balance.(%s) height.%d\n",coin->symbol,address,lastheight);
//printf("Start %s balance.(%s) height.%d\n",coin->symbol,address,lastheight);
if ( lastheight == 0 )
lastheight = IGUANA_MAXHEIGHT;
iguana_pkhasharray(myinfo,coin,array,minconf,maxconf,&total,P,coin->bundlescount,rmd160,address,pubkey33,lastheight,0,0,0);

1
iguana/swaps/iguana_BTCswap.c

@ -118,6 +118,7 @@ struct bitcoin_statetx *instantdex_signtx(struct supernet_info *myinfo,struct ig
}
bitcoin_pubkey33(myinfo->ctx,pubkey33,myinfo->persistent_priv);
bitcoin_address(coinaddr,coin->chain->pubtype,pubkey33,33);
printf("%s persistent.(%s) (%s)\n",coin->symbol,myinfo->myaddr.BTC,coinaddr);
jaddistr(addresses,coinaddr);
if ( (rawtx= iguana_calcrawtx(myinfo,coin,&vins,txobj,satoshis,coin->changeaddr,txfee,addresses,minconf)) != 0 && vins != 0 )
{

2
iguana/tests/balances

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"balances\",\"lastheight\":0,\"activecoin\":\"BTCD\",\"addresses\":[\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\"]}"
curl --url "http://127.0.0.1:7778" --data "{\"timeout\":20000,\"agent\":\"iguana\",\"method\":\"balances\",\"lastheight\":0,\"activecoin\":\"BTCD\",\"addresses\":[\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\"]}"

Loading…
Cancel
Save