diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 66fb8da0d..083e36821 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -71,7 +71,7 @@ int32_t basilisk_submit(struct supernet_info *myinfo,cJSON *reqjson,int32_t time int32_t i,j,k,l,r2,r,n; struct iguana_peer *addr; struct iguana_info *coin; char *reqstr; cJSON *tmpjson; tmpjson = basilisk_json(myinfo,reqjson,ptr->basilisktag,timeout); reqstr = jprint(tmpjson,1); - printf("basilisk_submit.(%s)\n",reqstr); + //printf("basilisk_submit.(%s)\n",reqstr); if ( fanout <= 0 ) fanout = BASILISK_MINFANOUT; else if ( fanout > BASILISK_MAXFANOUT ) @@ -227,7 +227,7 @@ xxx STRING_ARRAY_OBJ_STRING(basilisk,rawtx,changeaddr,addresses,vals,spendscriptstr) { cJSON *argjson=0,*retjson,*hexjson; char *rawtx=0,*symbol=0; int64_t txfee,satoshis; uint32_t locktime,minconf,basilisktag; int32_t timeout; - 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(); if ( spendscriptstr != 0 && spendscriptstr[0] != 0 && (symbol= jstr(vals,"coin")) != 0 ) { @@ -267,16 +267,21 @@ STRING_ARRAY_OBJ_STRING(basilisk,rawtx,changeaddr,addresses,vals,spendscriptstr) return(jprint(retjson,1)); } -INT_ARRAY_STRING(basilisk,result,basilisktag,args,hexmsg) +ARRAY_OBJ_INT(basilisk,result,args,vals,basilisktag) { - struct basilisk_item *ptr = calloc(1,sizeof(*ptr) + strlen(hexmsg) + 1); - ptr->results[0] = clonestr(hexmsg); - ptr->basilisktag = basilisktag; - if ( args != 0 ) - ptr->resultargs[0] = jduplicate(args); - ptr->numresults = 1; - queue_enqueue("resultsQ",&myinfo->basilisks.resultsQ,&ptr->DL,0); - return(clonestr("{\"result\":\"queued basilisk return\"}")); + struct basilisk_item *ptr; char *hexmsg; + if ( vals != 0 && (hexmsg= jstr(vals,"hexmsg")) != 0 ) + { + ptr = calloc(1,sizeof(*ptr) + strlen(hexmsg) + 1); + ptr->results[0] = clonestr(hexmsg); + ptr->basilisktag = basilisktag; + if ( args != 0 ) + ptr->resultargs[0] = jduplicate(args); + ptr->numresults = 1; + queue_enqueue("resultsQ",&myinfo->basilisks.resultsQ,&ptr->DL,0); + return(clonestr("{\"result\":\"queued basilisk return\"}")); + } + return(clonestr("{\"error\":\"no hexmsg to return\"}")); } #include "../includes/iguana_apiundefs.h" @@ -308,7 +313,8 @@ char *basilisk_hexmsg(struct supernet_info *myinfo,struct category_info *cat,voi int32_t minconf = juint(valsobj,"minconf"); int32_t timeout = juint(valsobj,"timeout"); uint32_t locktime = juint(valsobj,"locktime"); - retstr = basilisk_issuerawtx(myinfo,remoteaddr,0,coin->symbol,&vins,locktime,amount,jstr(json,"spendscriptstr"),jstr(json,"changeaddr"),txfee,minconf,jobj(json,"addresses"),timeout); + uint32_t basilisktag = juint(valsobj,"basilisktag"); + retstr = basilisk_issuerawtx(myinfo,remoteaddr,basilisktag,coin->symbol,&vins,locktime,amount,jstr(json,"spendscriptstr"),jstr(json,"changeaddr"),txfee,minconf,jobj(json,"addresses"),timeout); } else if ( strcmp(method,"balances") == 0 ) { @@ -316,7 +322,7 @@ char *basilisk_hexmsg(struct supernet_info *myinfo,struct category_info *cat,voi } if ( retstr == 0 ) return(0); - printf("basilisk will return.(%s)\n",retstr); + //printf("basilisk will return.(%s)\n",retstr); for (j=0; jRELAYNODE != 0 || coin->VALIDATENODE != 0 ) - printf("unhandled bitcoin_hexmsg.(%d) from %s (%s/%s)\n",len,remoteaddr,agent,method); + printf("unhandled bitcoin_hexmsg.(%d) from %s (%s/%s)\n",len,remoteaddr,agent,method); free_json(json); return(retstr); } diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index cc32f844d..07f05d8f1 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -511,6 +511,8 @@ char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coi { uint8_t buf[IGUANA_MAXSCRIPTSIZE]; int32_t i,spendlen,besti=-1; cJSON *hexjson,*retjson,*valsobj,*txobj = 0; char *retstr=0,*rawtx = 0; int64_t cost,bestcost=-1; struct basilisk_item *ptr; *vinsp = 0; + if ( basilisktag == 0 ) + basilisktag = rand(); if ( coin != 0 && basilisk_bitcoinavail(coin) != 0 ) { if ( coin->VALIDATENODE != 0 || coin->RELAYNODE != 0 ) @@ -531,13 +533,16 @@ char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coi { free_json(txobj); hexjson = cJSON_CreateObject(); - jaddstr(hexjson,"rawtx",rawtx); + valsobj = cJSON_CreateObject(); jaddstr(hexjson,"agent","basilisk"); jaddstr(hexjson,"method","result"); - jaddstr(hexjson,"hexmsg",rawtx); + jaddstr(valsobj,"rawtx",rawtx); + jaddstr(valsobj,"coin",coin->symbol); + jadd(hexjson,"vals",valsobj); jadd(hexjson,"args",*vinsp); retjson = basilisk_json(myinfo,hexjson,basilisktag,timeoutmillis); free(rawtx); + free_json(hexjson); return(jprint(retjson,1)); } else free(rawtx); } diff --git a/iguana/SuperNET.c b/iguana/SuperNET.c index 059dfd634..0d420da32 100755 --- a/iguana/SuperNET.c +++ b/iguana/SuperNET.c @@ -807,7 +807,7 @@ char *SuperNET_p2p(struct iguana_info *coin,struct iguana_peer *addr,int32_t *de //printf("validpub.%d: %x vs %x priv.%llx senderpub.%llx\n",addr->validpub,checkc,othercheckc,(long long)myinfo->privkey.txid,(long long)senderpub.txid); } maxdelay = juint(json,"maxdelay"); - if ( 1 && jstr(json,"method") != 0 && strcmp(jstr(json,"method"),"getpeers") != 0 ) + if ( 0 && jstr(json,"method") != 0 && strcmp(jstr(json,"method"),"getpeers") != 0 ) printf("GOT >>>>>>>> SUPERNET P2P.(%s) from.%s %s valid.%d:%d\n",jprint(json,0),coin->symbol,addr->ipaddr,addr->validpub,addr->othervalid); if ( (myipaddr= jstr(json,"yourip")) != 0 ) SuperNET_checkipaddr(SuperNET_MYINFO(0),coin,addr,myipaddr,ipaddr); diff --git a/includes/iguana_apideclares.h b/includes/iguana_apideclares.h index b21d0305a..026e42edb 100755 --- a/includes/iguana_apideclares.h +++ b/includes/iguana_apideclares.h @@ -16,7 +16,8 @@ INT_ARRAY_STRING(basilisk,balances,lastheight,addresses,activecoin); STRING_ARRAY_OBJ_STRING(basilisk,rawtx,changeaddr,addresses,vals,spendscriptstr); -INT_ARRAY_STRING(basilisk,result,basilisktag,args,hexmsg); +//INT_ARRAY_STRING(basilisk,result,basilisktag,args,hexmsg); +ARRAY_OBJ_INT(basilisk,result,args,vals,basilisktag); ZERO_ARGS(bitcoinrpc,getinfo); ZERO_ARGS(bitcoinrpc,getblockcount);