jl777 8 years ago
parent
commit
55cb1e982f
  1. 2
      basilisk/basilisk.c
  2. 21
      basilisk/basilisk_DEX.c
  3. 15
      basilisk/basilisk_bitcoin.c
  4. 2
      iguana/tests/addnode2
  5. 1
      includes/iguana_funcs.h

2
basilisk/basilisk.c

@ -914,7 +914,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
void basilisks_loop(void *arg)
{
struct iguana_info *virt,*tmpcoin,*coin,*notary; struct basilisk_message *msg,*tmpmsg; struct basilisk_item *tmp,*pending; uint32_t now; int32_t iter,maxmillis,flag=0; struct supernet_info *myinfo = arg;
struct iguana_info *virt,*tmpcoin,*notary; struct basilisk_message *msg,*tmpmsg; struct basilisk_item *tmp,*pending; uint32_t now; int32_t iter,maxmillis,flag=0; struct supernet_info *myinfo = arg;
iter = 0;
while ( 1 )
{

21
basilisk/basilisk_DEX.c

@ -413,10 +413,29 @@ ZERO_ARGS(InstantDEX,allcoins)
STRING_ARG(InstantDEX,available,source)
{
char *retstr; cJSON *vals,*balancejson,*retjson = 0;
if ( source != 0 && source[0] != 0 && (coin= iguana_coinfind(source)) != 0 )
{
if ( myinfo->expiration != 0 )
return(bitcoinrpc_getbalance(myinfo,coin,json,remoteaddr,"*",coin->chain->minconfirms,1,1<<30));
{
//return(bitcoinrpc_getbalance(myinfo,coin,json,remoteaddr,"*",coin->chain->minconfirms,1,1<<30));
if ( (vals= basilisk_balance_valsobj(myinfo,coin)) != 0 )
{
if ( (retstr= basilisk_balances(myinfo,coin,0,0,GENESIS_PUBKEY,vals,"")) != 0 )
{
if ( (balancejson= cJSON_Parse(retstr)) != 0 )
{
retjson = cJSON_CreateObject();
jaddnum(retjson,"result",jdouble(balancejson,"balance"));
free_json(balancejson);
}
free(retstr);
}
free_json(vals);
if ( retjson != 0 )
return(jprint(retjson,1));
}
}
printf("InstantDEX_available: need to unlock wallet\n");
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
}

15
basilisk/basilisk_bitcoin.c

@ -334,6 +334,7 @@ void *basilisk_bitcoinbalances(struct basilisk_item *Lptr,struct supernet_info *
jaddstr(retjson,"result","success");
jaddstr(retjson,"ipaddr",myinfo->ipaddr);
jaddnum(retjson,"total",dstr(total));
jaddnum(retjson,"balance",dstr(total));
jadd(retjson,"addresses",array);
if ( unspents != 0 )
jadd(retjson,"unspents",unspents);
@ -1006,17 +1007,23 @@ void basilisk_unspents_process(struct supernet_info *myinfo,struct iguana_info *
portable_mutex_unlock(&myinfo->bu_mutex);
}
void basilisk_unspents_update(struct supernet_info *myinfo,struct iguana_info *coin)
cJSON *basilisk_balance_valsobj(struct supernet_info *myinfo,struct iguana_info *coin)
{
char *retstr; cJSON *vals; int32_t oldest,i,RTheight;
vals = cJSON_CreateObject();
int32_t oldest,i,RTheight; cJSON *vals;
for (i=oldest=0; i<BASILISK_MAXRELAYS; i++)
if ( (RTheight= coin->relay_RTheights[i]) != 0 && (oldest == 0 || RTheight < oldest) )
oldest = RTheight;
vals = cJSON_CreateObject();
jaddnum(vals,"firstheight",oldest);
jaddnum(vals,"history",3);
jaddstr(vals,"coin",coin->symbol);
if ( (retstr= basilisk_balances(myinfo,coin,0,0,GENESIS_PUBKEY,vals,"")) != 0 )
return(vals);
}
void basilisk_unspents_update(struct supernet_info *myinfo,struct iguana_info *coin)
{
char *retstr; cJSON *vals;
if ( (vals= basilisk_balance_valsobj(myinfo,coin)) != 0 && (retstr= basilisk_balances(myinfo,coin,0,0,GENESIS_PUBKEY,vals,"")) != 0 )
{
basilisk_unspents_process(myinfo,coin,retstr);
free(retstr);

2
iguana/tests/addnode2

@ -0,0 +1,2 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"BTC\",\"ipaddr\":\"5.9.102.210\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"BTC\",\"ipaddr\":\"78.47.196.146\"}"

1
includes/iguana_funcs.h

@ -438,6 +438,7 @@ int64_t iguana_addressreceived(struct supernet_info *myinfo,struct iguana_info *
cJSON *iguana_walletjson(struct supernet_info *myinfo);
int32_t iguana_payloadupdate(struct supernet_info *myinfo,struct iguana_info *coin,char *retstr,struct iguana_waddress *waddr,char *account);
int32_t bitcoin_MofNspendscript(uint8_t p2sh_rmd160[20],uint8_t *script,int32_t n,const struct vin_info *vp);
cJSON *basilisk_balance_valsobj(struct supernet_info *myinfo,struct iguana_info *coin);
void basilisk_unspents_update(struct supernet_info *myinfo,struct iguana_info *coin);
struct iguana_txid *iguana_blocktx(struct iguana_info *coin,struct iguana_txid *tx,struct iguana_block *block,int32_t i);
cJSON *iguana_p2shjson(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *retjson,struct iguana_waddress *waddr);

Loading…
Cancel
Save