|
@ -321,6 +321,7 @@ void *basilisk_bitcoinbalances(struct basilisk_item *Lptr,struct supernet_info * |
|
|
} |
|
|
} |
|
|
retjson = cJSON_CreateObject(); |
|
|
retjson = cJSON_CreateObject(); |
|
|
jaddstr(retjson,"result","success"); |
|
|
jaddstr(retjson,"result","success"); |
|
|
|
|
|
jaddstr(retjson,"ipaddr",myinfo->ipaddr); |
|
|
jaddnum(retjson,"total",dstr(total)); |
|
|
jaddnum(retjson,"total",dstr(total)); |
|
|
jadd(retjson,"addresses",array); |
|
|
jadd(retjson,"addresses",array); |
|
|
if ( unspents != 0 ) |
|
|
if ( unspents != 0 ) |
|
@ -937,7 +938,7 @@ HASH_ARRAY_STRING(basilisk,history,hash,vals,hexstr) |
|
|
jaddi(array,item); |
|
|
jaddi(array,item); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
//printf("%s numunspents.%d\n",waddr->coinaddr,waddr->numunspents);
|
|
|
printf("%s numunspents.%d\n",waddr->coinaddr,waddr->numunspents); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
portable_mutex_unlock(&myinfo->bu_mutex); |
|
|
portable_mutex_unlock(&myinfo->bu_mutex); |
|
@ -1041,10 +1042,31 @@ void basilisk_unspent_update(struct supernet_info *myinfo,struct iguana_info *co |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void basilisk_relay_unspentsprocess(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *relayjson) |
|
|
|
|
|
{ |
|
|
|
|
|
int32_t RTheight,relayid,num,j; cJSON *unspents,*spends; |
|
|
|
|
|
RTheight = jint(relayjson,"RTheight"); |
|
|
|
|
|
if ( (relayid= basilisk_relayid(myinfo,(uint32_t)calc_ipbits(jstr(relayjson,"relay")))) < BASILISK_MAXRELAYS ) |
|
|
|
|
|
{ |
|
|
|
|
|
coin->relay_RTheights[relayid] = RTheight; |
|
|
|
|
|
} |
|
|
|
|
|
//printf("relayid.%d RT.%d (%s)\n",relayid,RTheight,jprint(relayjson,0));
|
|
|
|
|
|
if ( (unspents= jarray(&num,relayjson,"unspents")) != 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
for (j=0; j<num; j++) |
|
|
|
|
|
basilisk_unspent_update(myinfo,coin,jitem(unspents,j),0,relayid,RTheight); |
|
|
|
|
|
} |
|
|
|
|
|
if ( (spends= jarray(&num,relayjson,"spends")) != 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
for (j=0; j<num; j++) |
|
|
|
|
|
basilisk_unspent_update(myinfo,coin,jitem(spends,j),jint(jitem(spends,j),"spentheight"),relayid,RTheight); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void basilisk_unspents_update(struct supernet_info *myinfo,struct iguana_info *coin) |
|
|
void basilisk_unspents_update(struct supernet_info *myinfo,struct iguana_info *coin) |
|
|
{ |
|
|
{ |
|
|
char *retstr; cJSON *retarray,*vals,*relayjson,*unspents,*spends; int32_t oldest,i,j,n,num,RTheight,relayid; |
|
|
char *retstr; cJSON *retarray,*vals; int32_t oldest,i,n,RTheight; |
|
|
if ( coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 ) |
|
|
//if ( coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 )
|
|
|
{ |
|
|
{ |
|
|
vals = cJSON_CreateObject(); |
|
|
vals = cJSON_CreateObject(); |
|
|
for (i=oldest=0; i<BASILISK_MAXRELAYS; i++) |
|
|
for (i=oldest=0; i<BASILISK_MAXRELAYS; i++) |
|
@ -1052,34 +1074,20 @@ void basilisk_unspents_update(struct supernet_info *myinfo,struct iguana_info *c |
|
|
oldest = RTheight; |
|
|
oldest = RTheight; |
|
|
jaddnum(vals,"firstheight",oldest); |
|
|
jaddnum(vals,"firstheight",oldest); |
|
|
jaddnum(vals,"history",3); |
|
|
jaddnum(vals,"history",3); |
|
|
|
|
|
jaddstr(vals,"coin",coin->symbol); |
|
|
if ( (retstr= basilisk_balances(myinfo,coin,0,0,GENESIS_PUBKEY,vals,"")) != 0 ) |
|
|
if ( (retstr= basilisk_balances(myinfo,coin,0,0,GENESIS_PUBKEY,vals,"")) != 0 ) |
|
|
{ |
|
|
{ |
|
|
//printf("GOT.(%s)\n",retstr);
|
|
|
|
|
|
portable_mutex_lock(&myinfo->bu_mutex); |
|
|
portable_mutex_lock(&myinfo->bu_mutex); |
|
|
if ( (retarray= cJSON_Parse(retstr)) != 0 && (n= cJSON_GetArraySize(retarray)) > 0 ) |
|
|
if ( (retarray= cJSON_Parse(retstr)) != 0 ) |
|
|
{ |
|
|
{ |
|
|
if ( jobj(retarray,"error") == 0 ) |
|
|
if ( jobj(retarray,"error") == 0 ) |
|
|
{ |
|
|
{ |
|
|
for (i=0; i<n; i++) |
|
|
if ( (jstr(retarray,"ipaddr") == 0 || strcmp(jstr(retarray,"ipaddr"),myinfo->ipaddr) != 0) && (n= cJSON_GetArraySize(retarray)) > 0 ) |
|
|
{ |
|
|
{ |
|
|
relayjson = jitem(retarray,i); |
|
|
//printf("n.%d GOT.(%s)\n",n,jprint(retarray,0));
|
|
|
RTheight = jint(relayjson,"RTheight"); |
|
|
for (i=0; i<n; i++) |
|
|
if ( (relayid= basilisk_relayid(myinfo,(uint32_t)calc_ipbits(jstr(relayjson,"relay")))) < BASILISK_MAXRELAYS ) |
|
|
basilisk_relay_unspentsprocess(myinfo,coin,jitem(retarray,i)); |
|
|
{ |
|
|
} else basilisk_relay_unspentsprocess(myinfo,coin,retarray); |
|
|
coin->relay_RTheights[relayid] = RTheight; |
|
|
|
|
|
} |
|
|
|
|
|
//printf("relayid.%d RT.%d\n",relayid,RTheight);
|
|
|
|
|
|
if ( (unspents= jarray(&num,relayjson,"unspents")) != 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
for (j=0; j<num; j++) |
|
|
|
|
|
basilisk_unspent_update(myinfo,coin,jitem(unspents,j),0,relayid,RTheight); |
|
|
|
|
|
} |
|
|
|
|
|
if ( (spends= jarray(&num,relayjson,"spends")) != 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
for (j=0; j<num; j++) |
|
|
|
|
|
basilisk_unspent_update(myinfo,coin,jitem(spends,j),jint(jitem(spends,j),"spentheight"),relayid,RTheight); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if ( retarray != 0 ) |
|
|
if ( retarray != 0 ) |
|
|