diff --git a/iguana/SuperNET_category.c b/iguana/SuperNET_category.c index b826e2483..2a2d32375 100755 --- a/iguana/SuperNET_category.c +++ b/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); diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index 7331d5773..122f9aa68 100755 --- a/iguana/iguana_payments.c +++ b/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; irawtxQ,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 ) diff --git a/iguana/iguana_sign.c b/iguana/iguana_sign.c index a61b9be39..43892b9c3 100755 --- a/iguana/iguana_sign.c +++ b/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; ipk_scriptlen; i++) diff --git a/iguana/ramchain_api.c b/iguana/ramchain_api.c index 7150cdf82..be06ee032 100755 --- a/iguana/ramchain_api.c +++ b/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); diff --git a/iguana/swaps/iguana_BTCswap.c b/iguana/swaps/iguana_BTCswap.c index 9855931e2..dbc0d85b6 100755 --- a/iguana/swaps/iguana_BTCswap.c +++ b/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 ) { diff --git a/iguana/tests/balances b/iguana/tests/balances index eaafa9f7e..0583f8f62 100755 --- a/iguana/tests/balances +++ b/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\"]}"