Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
b8735b216c
  1. 2
      basilisk/basilisk.c
  2. 18
      basilisk/basilisk_bitcoin.c
  3. 2
      datachain/datachain.c
  4. 9
      gecko/gecko_mempool.c
  5. 12
      iguana/exchanges/bitcoin.c
  6. 2
      iguana/iguana777.c
  7. 89
      iguana/iguana_payments.c
  8. 2
      iguana/iguana_ramchain.c
  9. 103
      iguana/iguana_realtime.c
  10. 4
      iguana/iguana_recv.c
  11. 368
      iguana/iguana_unspents.c
  12. 61
      iguana/iguana_volatiles.c
  13. 10
      iguana/iguana_wallet.c
  14. 2
      iguana/main.c
  15. 12
      iguana/ramchain_api.c
  16. 36
      includes/iguana_funcs.h
  17. 21
      includes/iguana_structs.h

2
basilisk/basilisk.c

@ -816,7 +816,7 @@ void basilisks_loop(void *arg)
//for (i=0; i<BASILISK_MAXRELAYS; i++) //for (i=0; i<BASILISK_MAXRELAYS; i++)
// if ( coin->relay_RTheights[i] != 0 ) // if ( coin->relay_RTheights[i] != 0 )
// break; // break;
if ( (time(NULL) % 10) == 0 ) //i == BASILISK_MAXRELAYS || // if ( (time(NULL) % 10) == 0 ) //i == BASILISK_MAXRELAYS ||
{ {
basilisk_unspents_update(myinfo,coin); basilisk_unspents_update(myinfo,coin);
} }

18
basilisk/basilisk_bitcoin.c

@ -308,17 +308,19 @@ void *basilisk_bitcoinbalances(struct basilisk_item *Lptr,struct supernet_info *
if ( (hist & 2) != 0 ) if ( (hist & 2) != 0 )
spends = cJSON_CreateArray(); spends = cJSON_CreateArray();
} }
printf("hist.%d (%s) %p %p\n",hist,jprint(vals,0),unspents,spends);
if ( (addresses= jarray(&n,vals,"addresses")) != 0 ) if ( (addresses= jarray(&n,vals,"addresses")) != 0 )
{ {
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
if ( coin->RTheight > 0 ) //if ( coin->RTheight > 0 )
balance = iguana_addressreceived(myinfo,coin,vals,remoteaddr,0,0,unspents,spends,jstri(addresses,i),juint(vals,"minconf"),juint(vals,"firstheight")); balance = iguana_addressreceived(myinfo,coin,vals,remoteaddr,0,0,unspents,spends,jstri(addresses,i),juint(vals,"minconf"),juint(vals,"firstheight"));
else balance = 0; //else balance = 0;
item = cJSON_CreateObject(); item = cJSON_CreateObject();
jaddnum(item,jstri(addresses,i),dstr(balance)); jaddnum(item,jstri(addresses,i),dstr(balance));
jaddi(array,item); jaddi(array,item);
total += balance; total += balance;
printf("%.8f ",dstr(balance));
} }
} }
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
@ -873,11 +875,13 @@ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr)
jaddnum(vals,"fanout",8); jaddnum(vals,"fanout",8);
if ( jobj(vals,"numrequired") == 0 ) if ( jobj(vals,"numrequired") == 0 )
jaddnum(vals,"numrequired",myinfo->numrelays); jaddnum(vals,"numrequired",myinfo->numrelays);
//printf("vals.(%s)\n",jprint(vals,0));
if ( coin != 0 ) if ( coin != 0 )
{ {
if ( jobj(vals,"addresses") == 0 ) if ( jobj(vals,"addresses") == 0 )
{
jadd(vals,"addresses",iguana_getaddressesbyaccount(myinfo,coin,"*")); jadd(vals,"addresses",iguana_getaddressesbyaccount(myinfo,coin,"*"));
//printf("added all addresses: %s\n",jprint(vals,0));
} //else printf("have addresses.(%s)\n",jprint(jobj(vals,"addresses"),0));
if ( (basilisktag= juint(vals,"basilisktag")) == 0 ) if ( (basilisktag= juint(vals,"basilisktag")) == 0 )
basilisktag = rand(); basilisktag = rand();
if ( (timeoutmillis= juint(vals,"timeout")) <= 0 ) if ( (timeoutmillis= juint(vals,"timeout")) <= 0 )
@ -888,7 +892,7 @@ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr)
ptr->finished = (uint32_t)time(NULL); ptr->finished = (uint32_t)time(NULL);
return(retstr); return(retstr);
} }
} } else printf("no coin\n");
return(basilisk_standardservice("BAL",myinfo,0,hash,vals,hexstr,1)); return(basilisk_standardservice("BAL",myinfo,0,hash,vals,hexstr,1));
} }
@ -968,7 +972,7 @@ HASH_ARRAY_STRING(basilisk,history,hash,vals,hexstr)
} }
#include "../includes/iguana_apiundefs.h" #include "../includes/iguana_apiundefs.h"
int32_t basilisk_unspentfind(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,uint8_t *spendscript,int16_t hdrsi,uint32_t unspentind,int64_t value) int32_t basilisk_unspentfind(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,uint8_t *spendscript,struct iguana_outpoint outpt,int64_t value)
{ {
struct basilisk_unspent *bu; int32_t i,spendlen; struct iguana_waccount *wacct,*tmp; struct iguana_waddress *waddr,*tmp2; char str[65]; struct basilisk_unspent *bu; int32_t i,spendlen; struct iguana_waccount *wacct,*tmp; struct iguana_waddress *waddr,*tmp2; char str[65];
memset(txidp,0,sizeof(*txidp)); memset(txidp,0,sizeof(*txidp));
@ -981,7 +985,7 @@ int32_t basilisk_unspentfind(struct supernet_info *myinfo,struct iguana_info *co
for (i=0; i<waddr->numunspents; i++) for (i=0; i<waddr->numunspents; i++)
{ {
bu = &waddr->unspents[i]; bu = &waddr->unspents[i];
if ( bu->hdrsi == hdrsi && bu->unspentind == unspentind && bu->value == value ) if ( bu->hdrsi == outpt.hdrsi && bu->unspentind == outpt.unspentind && bu->value == value )
{ {
if ( bu->status == 0 ) if ( bu->status == 0 )
{ {
@ -1133,7 +1137,7 @@ void basilisk_relay_unspentsprocess(struct supernet_info *myinfo,struct iguana_i
{ {
coin->relay_RTheights[relayid] = RTheight; coin->relay_RTheights[relayid] = RTheight;
} }
//printf("relayid.%d RT.%d (%s)\n",relayid,RTheight,jprint(relayjson,0)); printf("basilisk_relay_unspentsprocess relayid.%d RT.%d (%s)\n",relayid,RTheight,jprint(relayjson,0));
if ( (unspents= jarray(&num,relayjson,"unspents")) != 0 ) if ( (unspents= jarray(&num,relayjson,"unspents")) != 0 )
{ {
for (j=0; j<num; j++) for (j=0; j<num; j++)

2
datachain/datachain.c

@ -58,7 +58,7 @@ int32_t datachain_events_rewind(struct supernet_info *myinfo,int32_t ordered,str
int32_t datachain_checkpoint_update(struct supernet_info *myinfo,struct iguana_info *coin,uint32_t timestamp) int32_t datachain_checkpoint_update(struct supernet_info *myinfo,struct iguana_info *coin,uint32_t timestamp)
{ {
int32_t i,num,n,lastheight; bits256 *tree,hash2,lasthash2,merkle; struct iguana_block *block; int32_t i,num,n,lastheight; bits256 *tree,hash2,lasthash2,merkle; struct iguana_block *block;
printf("datachain_checkpoint_update\n"); //printf("datachain_checkpoint_update\n");
if ( coin->lastcheckpoint <= coin->blocks.hwmchain.height ) if ( coin->lastcheckpoint <= coin->blocks.hwmchain.height )
{ {
num = (coin->blocks.hwmchain.height - coin->lastcheckpoint) + 1; num = (coin->blocks.hwmchain.height - coin->lastcheckpoint) + 1;

9
gecko/gecko_mempool.c

@ -226,7 +226,7 @@ int32_t basilisk_respond_geckogettx(struct supernet_info *myinfo,struct iguana_i
char *gecko_txarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *serialized,int32_t datalen,bits256 txid) char *gecko_txarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *serialized,int32_t datalen,bits256 txid)
{ {
struct gecko_mempool *pool; int64_t txfee,vinstotal,voutstotal; uint64_t hdrsi_unspentind,value; int32_t i,numvins,numvouts,txlen,spentheight,minconf,maxconf,unspentind,hdrsi; struct iguana_msgtx msg; char *rawtx; struct gecko_memtx *memtx; struct iguana_info *btcd; struct gecko_mempool *pool; int64_t txfee,vinstotal,voutstotal; uint64_t value; int32_t i,numvins,numvouts,txlen,spentheight,minconf,maxconf,unspentind; struct iguana_msgtx msg; char *rawtx; struct gecko_memtx *memtx; struct iguana_info *btcd; struct iguana_outpoint outpt;
memset(&msg,0,sizeof(msg)); memset(&msg,0,sizeof(msg));
iguana_memreset(&virt->TXMEM); iguana_memreset(&virt->TXMEM);
txlen = iguana_rwtx(virt->chain->zcash,0,&virt->TXMEM,serialized,&msg,datalen,&txid,virt->chain->isPoS,strcmp("VPN",virt->symbol) == 0); txlen = iguana_rwtx(virt->chain->zcash,0,&virt->TXMEM,serialized,&msg,datalen,&txid,virt->chain->isPoS,strcmp("VPN",virt->symbol) == 0);
@ -239,9 +239,10 @@ char *gecko_txarrived(struct supernet_info *myinfo,struct iguana_info *virt,char
{ {
if ( (unspentind= iguana_RTunspentindfind(myinfo,virt,0,0,0,&value,&spentheight,msg.vins[i].prev_hash,msg.vins[i].prev_vout,virt->bundlescount-1,1)) != 0 ) if ( (unspentind= iguana_RTunspentindfind(myinfo,virt,0,0,0,&value,&spentheight,msg.vins[i].prev_hash,msg.vins[i].prev_vout,virt->bundlescount-1,1)) != 0 )
{ {
hdrsi = spentheight / virt->chain->bundlesize; memset(&outpt,0,sizeof(outpt));
hdrsi_unspentind = ((uint64_t)hdrsi << 32) | unspentind; outpt.hdrsi = spentheight / virt->chain->bundlesize;
if ( iguana_unspentavail(myinfo,virt,hdrsi_unspentind,minconf,maxconf) != value ) outpt.unspentind = unspentind;
if ( iguana_unspentavail(myinfo,virt,outpt,minconf,maxconf) != value )
{ {
printf("vin.%d already spent\n",i); printf("vin.%d already spent\n",i);
return(clonestr("{\"error\":\"gecko tx has double spend\"}")); return(clonestr("{\"error\":\"gecko tx has double spend\"}"));

12
iguana/exchanges/bitcoin.c

@ -445,7 +445,7 @@ char *PARSEBALANCE(struct exchange_info *exchange,double *balancep,char *coinstr
cJSON *BALANCES(struct exchange_info *exchange,cJSON *argjson) cJSON *BALANCES(struct exchange_info *exchange,cJSON *argjson)
{ {
double balance; int16_t hdrsi; uint32_t unspentind; int32_t i,minconfirms,numunspents,max; struct iguana_info *coin,*tmp; struct supernet_info *myinfo; cJSON *retjson,*array,*item,*addresses=0; int64_t *unspents=0,value,avail; double balance; int32_t i,minconfirms,numunspents,max; struct iguana_info *coin,*tmp; struct supernet_info *myinfo; cJSON *retjson,*array,*item,*addresses=0; int64_t avail; struct iguana_outpoint outpt,*unspents=0;
retjson = cJSON_CreateArray(); retjson = cJSON_CreateArray();
myinfo = SuperNET_accountfind(argjson); myinfo = SuperNET_accountfind(argjson);
//portable_mutex_lock(&myinfo->allcoins_mutex); //portable_mutex_lock(&myinfo->allcoins_mutex);
@ -463,12 +463,10 @@ cJSON *BALANCES(struct exchange_info *exchange,cJSON *argjson)
for (i=0; i<numunspents; i++) for (i=0; i<numunspents; i++)
{ {
item = cJSON_CreateArray(); item = cJSON_CreateArray();
hdrsi = (int16_t)(unspents[(i << 1)] >> 32); outpt = unspents[i];
unspentind = (uint32_t)unspents[(i << 1)]; jaddinum(item,outpt.hdrsi);
value = unspents[(i << 1) + 1]; jaddinum(item,outpt.unspentind);
jaddinum(item,hdrsi); jaddinum(item,dstr(outpt.value));
jaddinum(item,unspentind);
jaddinum(item,dstr(value));
jaddi(array,item); jaddi(array,item);
} }
item = cJSON_CreateObject(); item = cJSON_CreateObject();

2
iguana/iguana777.c

@ -841,7 +841,7 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,
if ( (coin= iguana_coinfind(symbol)) == 0 ) if ( (coin= iguana_coinfind(symbol)) == 0 )
coin = iguana_coinadd(symbol,name,json,virtcoin); coin = iguana_coinadd(symbol,name,json,virtcoin);
//printf("ensure directories maxval.%d mult.%d start.%d end.%d\n",maxval,mult,coin->startPEND,coin->endPEND); //printf("ensure directories maxval.%d mult.%d start.%d end.%d\n",maxval,mult,coin->startPEND,coin->endPEND);
mult = (strcmp("BTC",coin->symbol) != 0) ? 64 : 128; mult = (strcmp("BTC",coin->symbol) != 0) ? 16 : 4;
maxval = IGUANA_MAXPENDBUNDLES; maxval = IGUANA_MAXPENDBUNDLES;
if ( coin->virtualchain == 0 ) if ( coin->virtualchain == 0 )
{ {

89
iguana/iguana_payments.c

@ -162,17 +162,17 @@ cJSON *iguana_scriptobj(struct iguana_info *coin,uint8_t rmd160[20],char *coinad
return(scriptobj); return(scriptobj);
} }
int32_t iguana_RTbestunspent(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t *belowp,int64_t *unspents,int32_t numunspents,uint64_t value) int32_t iguana_RTbestunspent(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t *belowp,struct iguana_outpoint *unspents,int32_t numunspents,uint64_t value)
{ {
int32_t i,abovei,belowi; int64_t above,below,gap,atx_value; int32_t i,abovei,belowi; int64_t above,below,gap,atx_value;
abovei = belowi = -1; abovei = belowi = -1;
for (above=below=i=0; i<numunspents; i++) for (above=below=i=0; i<numunspents; i++)
{ {
if ( (atx_value= unspents[(i << 1) + 1]) <= 0 ) if ( (atx_value= unspents[i].value) <= 0 )
continue; continue;
if ( iguana_RTunspent_check(myinfo,coin,(uint16_t)(unspents[i << 1] >> 32),(uint32_t)unspents[i << 1]) != 0 ) if ( iguana_RTunspent_check(myinfo,coin,unspents[i]) != 0 )
{ {
printf("(%d u%d) %.8f already used\n",(uint16_t)(unspents[i << 1] >> 32),(uint32_t)unspents[i << 1],dstr(atx_value)); printf("(%d u%d) %.8f already used\n",unspents[i].hdrsi,unspents[i].unspentind,dstr(atx_value));
continue; continue;
} }
//printf("(%.8f vs %.8f)\n",dstr(atx_value),dstr(value)); //printf("(%.8f vs %.8f)\n",dstr(atx_value),dstr(value));
@ -216,9 +216,9 @@ cJSON *iguana_inputjson(bits256 txid,int32_t vout,uint8_t *spendscript,int32_t s
return(item); return(item);
} }
cJSON *iguana_RTinputsjson(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *totalp,uint64_t amount,int64_t *unspents,int32_t num) cJSON *iguana_RTinputsjson(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *totalp,uint64_t amount,struct iguana_outpoint *unspents,int32_t num)
{ {
cJSON *vins; uint8_t spendscript[IGUANA_MAXSCRIPTSIZE]; struct iguana_txid *T; struct iguana_unspent *U,*u; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; char coinaddr[64]; int32_t vout,height,abovei,belowi,i,spendlen,ind,hdrsi; uint32_t txidind,unspentind; struct iguana_ramchaindata *rdata; bits256 txid; int64_t value,above,below,total = 0; int64_t remains = amount; cJSON *vins; uint8_t spendscript[IGUANA_MAXSCRIPTSIZE]; struct iguana_txid *T; struct iguana_unspent *U,*u; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; char coinaddr[64]; int32_t vout,height,abovei,belowi,i,spendlen,ind; uint32_t txidind; struct iguana_ramchaindata *rdata; bits256 txid; int64_t above,below,total = 0; struct iguana_outpoint outpt; int64_t remains = amount;
*totalp = 0; *totalp = 0;
vins = cJSON_CreateArray(); vins = cJSON_CreateArray();
for (i=0; i<num; i++) for (i=0; i<num; i++)
@ -233,36 +233,34 @@ cJSON *iguana_RTinputsjson(struct supernet_info *myinfo,struct iguana_info *coin
if ( belowi < 0 || (num == 0 && abovei >= 0) ) if ( belowi < 0 || (num == 0 && abovei >= 0) )
ind = abovei; ind = abovei;
else ind = belowi; else ind = belowi;
hdrsi = (int16_t)(unspents[(ind << 1)] >> 32); outpt = unspents[ind];
unspentind = (uint32_t)unspents[(ind << 1)]; memset(&unspents[ind],0,sizeof(unspents[ind]));
value = unspents[(ind << 1) + 1];
unspents[(ind << 1) + 1] = -1;
if ( coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 ) if ( coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 )
{ {
if ( (spendlen= basilisk_unspentfind(myinfo,coin,&txid,&vout,spendscript,hdrsi,unspentind,value)) > 0 ) if ( (spendlen= basilisk_unspentfind(myinfo,coin,&txid,&vout,spendscript,outpt,outpt.value)) > 0 )
{ {
jaddi(vins,iguana_inputjson(txid,vout,spendscript,spendlen)); jaddi(vins,iguana_inputjson(txid,vout,spendscript,spendlen));
total += value; total += outpt.value;
remains -= value; remains -= outpt.value;
//printf("%s value %.8f -> remains %.8f\n",coinaddr,dstr(value),dstr(remains)); //printf("%s value %.8f -> remains %.8f\n",coinaddr,dstr(value),dstr(remains));
if ( remains <= 0 ) if ( remains <= 0 )
break; break;
} }
continue; continue;
} }
if ( (spendlen= iguana_RTunspentfind(myinfo,coin,&txid,&vout,spendscript,hdrsi,unspentind,value)) > 0 ) if ( (spendlen= _iguana_RTunspentfind(myinfo,coin,&txid,&vout,spendscript,outpt,outpt.value)) > 0 )
{ {
jaddi(vins,iguana_inputjson(txid,vout,spendscript,spendlen)); jaddi(vins,iguana_inputjson(txid,vout,spendscript,spendlen));
total += value; total += outpt.value;
remains -= value; remains -= outpt.value;
//printf("%s value %.8f -> remains %.8f\n",coinaddr,dstr(value),dstr(remains)); //printf("%s value %.8f -> remains %.8f\n",coinaddr,dstr(value),dstr(remains));
if ( remains <= 0 ) if ( remains <= 0 )
break; break;
continue; continue;
} }
if ( (bp= coin->bundles[hdrsi]) == 0 ) if ( (bp= coin->bundles[outpt.hdrsi]) == 0 )
{ {
printf("no bundle.[%d]\n",hdrsi); printf("no bundle.[%d]\n",outpt.hdrsi);
free_json(vins); free_json(vins);
return(0); return(0);
} }
@ -271,16 +269,16 @@ cJSON *iguana_RTinputsjson(struct supernet_info *myinfo,struct iguana_info *coin
continue; continue;
U = RAMCHAIN_PTR(rdata,Uoffset); U = RAMCHAIN_PTR(rdata,Uoffset);
T = RAMCHAIN_PTR(rdata,Toffset); T = RAMCHAIN_PTR(rdata,Toffset);
if ( unspentind > 0 && unspentind < rdata->numunspents ) if ( outpt.unspentind > 0 && outpt.unspentind < rdata->numunspents )
{ {
u = &U[unspentind]; u = &U[outpt.unspentind];
if ( (txidind= u->txidind) > 0 && txidind < rdata->numtxids ) if ( (txidind= u->txidind) > 0 && txidind < rdata->numtxids )
{ {
if ( iguana_unspentindfind(myinfo,coin,coinaddr,spendscript,&spendlen,&amount,&height,T[txidind].txid,u->vout,coin->bundlescount-1,0) == unspentind && spendlen > 0 ) if ( iguana_unspentindfind(myinfo,coin,coinaddr,spendscript,&spendlen,&amount,&height,T[txidind].txid,u->vout,coin->bundlescount-1,0) == outpt.unspentind && spendlen > 0 )
{ {
jaddi(vins,iguana_inputjson(T[txidind].txid,u->vout,spendscript,spendlen)); jaddi(vins,iguana_inputjson(T[txidind].txid,u->vout,spendscript,spendlen));
total += value; total += outpt.value;
remains -= value; remains -= outpt.value;
//printf("%s value %.8f -> remains %.8f\n",coinaddr,dstr(value),dstr(remains)); //printf("%s value %.8f -> remains %.8f\n",coinaddr,dstr(value),dstr(remains));
if ( remains <= 0 ) if ( remains <= 0 )
break; break;
@ -294,14 +292,14 @@ cJSON *iguana_RTinputsjson(struct supernet_info *myinfo,struct iguana_info *coin
} }
else else
{ {
printf("illegal txidind.%d [%d]\n",txidind,hdrsi); printf("illegal txidind.%d [%d]\n",txidind,outpt.hdrsi);
free_json(vins); free_json(vins);
return(0); return(0);
} }
} }
else else
{ {
printf("illegal unspentind.u%d [%d]\n",unspentind,hdrsi); printf("illegal unspentind.u%d [%d]\n",outpt.unspentind,outpt.hdrsi);
free_json(vins); free_json(vins);
return(0); return(0);
} }
@ -366,7 +364,7 @@ bits256 iguana_sendrawtransaction(struct supernet_info *myinfo,struct iguana_inf
char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJSON **vinsp,cJSON *txobj,int64_t satoshis,char *changeaddr,int64_t txfee,cJSON *addresses,int32_t minconf,uint8_t *opreturn,int32_t oplen,int64_t burnamount,char *remoteaddr) char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJSON **vinsp,cJSON *txobj,int64_t satoshis,char *changeaddr,int64_t txfee,cJSON *addresses,int32_t minconf,uint8_t *opreturn,int32_t oplen,int64_t burnamount,char *remoteaddr)
{ {
uint8_t addrtype,rmd160[20],spendscript[IGUANA_MAXSCRIPTSIZE]; int32_t max,num,spendlen; char *rawtx=0; bits256 txid; cJSON *vins=0; int64_t avail,total,change,*unspents = 0; struct vin_info *V=0; uint8_t addrtype,rmd160[20],spendscript[IGUANA_MAXSCRIPTSIZE]; int32_t max,num,spendlen; char *rawtx=0; bits256 txid; cJSON *vins=0; int64_t avail,total,change; struct iguana_outpoint *unspents = 0; struct vin_info *V=0;
*vinsp = 0; *vinsp = 0;
max = 10000; max = 10000;
satoshis += burnamount; satoshis += burnamount;
@ -432,14 +430,14 @@ char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJS
void iguana_RTunspentslock(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins) void iguana_RTunspentslock(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins)
{ {
uint32_t spent_unspentind; char coinaddr[64]; int16_t spent_hdrsi; int32_t i,RTspentflag,num; struct iguana_outpoint spentpt; char coinaddr[64]; int32_t i,RTspentflag,num;
if ( coin->MAXPEERS == 1 || coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 ) if ( coin->MAXPEERS == 1 || coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 )
{ {
num = cJSON_GetArraySize(vins); num = cJSON_GetArraySize(vins);
for (i=0; i<num; i++) for (i=0; i<num; i++)
{ {
if ( iguana_RTinputaddress(myinfo,coin,coinaddr,&spent_hdrsi,&spent_unspentind,jitem(vins,i)) != 0 ) if ( iguana_RTinputaddress(myinfo,coin,coinaddr,&spentpt,jitem(vins,i)) != 0 )
iguana_RTutxofind(coin,spent_hdrsi,spent_unspentind,&RTspentflag,1); iguana_RTutxofind(coin,spentpt,&RTspentflag,1);
} }
} }
} }
@ -679,12 +677,12 @@ INT_ARRAY_STRING(bitcoinrpc,addmultisigaddress,M,pubkeys,account) //
HASH_AND_TWOINTS(bitcoinrpc,gettxout,txid,vout,mempool) HASH_AND_TWOINTS(bitcoinrpc,gettxout,txid,vout,mempool)
{ {
uint8_t script[IGUANA_MAXSCRIPTSIZE],rmd160[20],pubkey33[33]; char coinaddr[128],asmstr[IGUANA_MAXSCRIPTSIZE*2+1]; struct iguana_bundle *bp; int32_t minconf,scriptlen,unspentind,height,spentheight; int64_t RTspend; int64_t value; struct iguana_ramchaindata *rdata; struct iguana_pkhash *P; struct iguana_txid *T; struct iguana_unspent *U; struct iguana_ramchain *ramchain; cJSON *scriptobj,*retjson = cJSON_CreateObject(); uint8_t script[IGUANA_MAXSCRIPTSIZE],rmd160[20],pubkey33[33]; char coinaddr[128],asmstr[IGUANA_MAXSCRIPTSIZE*2+1]; struct iguana_bundle *bp; int32_t minconf,scriptlen,unspentind,height,spentheight; int64_t RTspend; int64_t value; struct iguana_ramchaindata *rdata; struct iguana_pkhash *P; struct iguana_txid *T; struct iguana_unspent *U; struct iguana_outpoint outpt; struct iguana_ramchain *ramchain; cJSON *scriptobj,*retjson = cJSON_CreateObject();
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
if ( coin != 0 ) if ( coin != 0 )
{ {
if ( (value= RTgettxout(coin,&height,&scriptlen,script,rmd160,coinaddr,txid,vout,mempool)) > 0 ) if ( (value= _RTgettxout(coin,&height,&scriptlen,script,rmd160,coinaddr,txid,vout,mempool)) > 0 )
{ {
jaddbits256(retjson,"bestblock",coin->blocks.hwmchain.RO.hash2); jaddbits256(retjson,"bestblock",coin->blocks.hwmchain.RO.hash2);
jaddnum(retjson,"bestheight",coin->blocks.hwmchain.height); jaddnum(retjson,"bestheight",coin->blocks.hwmchain.height);
@ -700,7 +698,7 @@ HASH_AND_TWOINTS(bitcoinrpc,gettxout,txid,vout,mempool)
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
minconf = (mempool != 0) ? 0 : 1; minconf = (mempool != 0) ? 0 : 1;
if ( (unspentind= iguana_unspentindfind(myinfo,coin,0,0,0,0,&height,txid,vout,coin->bundlescount-1,0)) != 0 ) if ( (unspentind= iguana_RTunspentindfind(myinfo,coin,0,0,0,0,&height,txid,vout,coin->bundlescount-1,0)) != 0 )
{ {
if ( height >= 0 && height < coin->longestchain && (bp= coin->bundles[height / coin->chain->bundlesize]) != 0 ) if ( height >= 0 && height < coin->longestchain && (bp= coin->bundles[height / coin->chain->bundlesize]) != 0 )
{ {
@ -711,7 +709,10 @@ HASH_AND_TWOINTS(bitcoinrpc,gettxout,txid,vout,mempool)
P = RAMCHAIN_PTR(rdata,Poffset); P = RAMCHAIN_PTR(rdata,Poffset);
T = RAMCHAIN_PTR(rdata,Toffset); T = RAMCHAIN_PTR(rdata,Toffset);
RTspend = 0; RTspend = 0;
if ( iguana_spentflag(myinfo,coin,&RTspend,&spentheight,ramchain,bp->hdrsi,unspentind,height,minconf,coin->longestchain,U[unspentind].value) == 0 ) memset(&outpt,0,sizeof(outpt));
outpt.hdrsi = bp->hdrsi;
outpt.unspentind = unspentind;
if ( iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,ramchain,outpt,height,minconf,coin->longestchain,U[unspentind].value) == 0 )
{ {
jaddbits256(retjson,"bestblock",coin->blocks.hwmchain.RO.hash2); jaddbits256(retjson,"bestblock",coin->blocks.hwmchain.RO.hash2);
jaddnum(retjson,"bestheight",coin->blocks.hwmchain.height); jaddnum(retjson,"bestheight",coin->blocks.hwmchain.height);
@ -726,7 +727,7 @@ HASH_AND_TWOINTS(bitcoinrpc,gettxout,txid,vout,mempool)
if ( (scriptobj= iguana_scriptobj(coin,rmd160,coinaddr,asmstr,script,scriptlen)) != 0 ) if ( (scriptobj= iguana_scriptobj(coin,rmd160,coinaddr,asmstr,script,scriptlen)) != 0 )
jadd(retjson,"scriptPubKey",scriptobj); jadd(retjson,"scriptPubKey",scriptobj);
} }
jadd(retjson,"iguana",iguana_unspentjson(myinfo,coin,bp->hdrsi,unspentind,T,&U[unspentind],rmd160,coinaddr,pubkey33,spentheight,remoteaddr)); jadd(retjson,"iguana",iguana_RTunspentjson(myinfo,coin,outpt,T[U[unspentind].txidind].txid,unspentind-T[U[unspentind].txidind].firstvout,U[unspentind].value,&U[unspentind],rmd160,coinaddr,pubkey33,spentheight,remoteaddr));
if ( (height % coin->chain->bundlesize) == 0 && vout == 0 ) if ( (height % coin->chain->bundlesize) == 0 && vout == 0 )
jadd(retjson,"coinbase",jtrue()); jadd(retjson,"coinbase",jtrue());
else jadd(retjson,"coinbase",jfalse()); else jadd(retjson,"coinbase",jfalse());
@ -1219,7 +1220,7 @@ ZERO_ARGS(bitcoinrpc,getrawchangeaddress)
INT_AND_ARRAY(bitcoinrpc,lockunspent,flag,array) INT_AND_ARRAY(bitcoinrpc,lockunspent,flag,array)
{ {
int32_t RTspendflag,vout,hdrsi,i,n,height; cJSON *item,*retjson; bits256 txid; uint32_t unspentind; struct iguana_outpoint outpt; int32_t RTspendflag,vout,i,n,height; cJSON *item,*retjson; bits256 txid; uint32_t unspentind;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
@ -1234,8 +1235,10 @@ INT_AND_ARRAY(bitcoinrpc,lockunspent,flag,array)
vout = jint(item,"vout"); vout = jint(item,"vout");
if ( (unspentind= iguana_RTunspentindfind(myinfo,coin,0,0,0,0,&height,txid,vout,coin->bundlescount-1,0)) != 0 ) if ( (unspentind= iguana_RTunspentindfind(myinfo,coin,0,0,0,0,&height,txid,vout,coin->bundlescount-1,0)) != 0 )
{ {
hdrsi = height / coin->chain->bundlesize; memset(&outpt,0,sizeof(outpt));
iguana_RTutxofind(coin,hdrsi,unspentind,&RTspendflag,!flag); outpt.hdrsi = height / coin->chain->bundlesize;
outpt.unspentind = unspentind;
iguana_RTutxofind(coin,outpt,&RTspendflag,!flag);
} }
} }
} }
@ -1245,26 +1248,26 @@ INT_AND_ARRAY(bitcoinrpc,lockunspent,flag,array)
ZERO_ARGS(bitcoinrpc,listlockunspent) ZERO_ARGS(bitcoinrpc,listlockunspent)
{ {
cJSON *array,*item,*retjson; bits256 txid; struct iguana_hhutxo *hhutxo,*tmputxo; int32_t hdrsi,vout; uint32_t unspentind; cJSON *array,*retjson; //int32_t vout; //struct iguana_outpoint outpt;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
array = cJSON_CreateArray(); array = cJSON_CreateArray();
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
if ( coin->utxotable != 0 ) printf("need to port listlockunspent to new RT method\n");
jaddstr(retjson,"error","need to port listlockunspent to new RT method");
/*if ( coin->utxotable != 0 )
{ {
HASH_ITER(hh,coin->utxotable,hhutxo,tmputxo) HASH_ITER(hh,coin->utxotable,hhutxo,tmputxo)
{ {
item = cJSON_CreateObject(); item = cJSON_CreateObject();
hdrsi = (int32_t)(hhutxo->uval >> 32); //if ( (vout= iguana_RTuvaltxid(myinfo,&txid,coin,hhutxo->outpt)) >= 0 )
unspentind = (uint32_t)hhutxo->uval;
if ( (vout= iguana_RTuvaltxid(myinfo,&txid,coin,hdrsi,unspentind)) >= 0 )
{ {
jaddbits256(item,"txid",txid); jaddbits256(item,"txid",txid);
jaddnum(item,"vout",vout); jaddnum(item,"vout",vout);
jaddi(array,item); jaddi(array,item);
} }
} }
} }*/
jadd(retjson,"result",array); jadd(retjson,"result",array);
return(jprint(retjson,1)); return(jprint(retjson,1));
} }

2
iguana/iguana_ramchain.c

@ -2810,7 +2810,7 @@ int32_t iguana_RTramchaindata(struct supernet_info *myinfo,struct iguana_info *c
for (i=0; i<txn_count; i++,ramchain->H.txidind++) for (i=0; i<txn_count; i++,ramchain->H.txidind++)
{ {
tx = &txarray[i]; tx = &txarray[i];
RTptr = iguana_RTtxid(coin,block,polarity,i,txn_count,tx->txid,tx->tx_out,tx->tx_in,tx->lock_time,tx->version,tx->timestamp); RTptr = iguana_RTtxid_create(coin,block,polarity,i,txn_count,tx->txid,tx->tx_out,tx->tx_in,tx->lock_time,tx->version,tx->timestamp);
if ( polarity > 0 ) if ( polarity > 0 )
{ {
if ( iter == 0 ) if ( iter == 0 )

103
iguana/iguana_realtime.c

@ -26,7 +26,7 @@ void iguana_RTramchainfree(struct iguana_info *coin,struct iguana_bundle *bp)
if ( coin->utxotable != 0 ) if ( coin->utxotable != 0 )
{ {
printf("free RTramchain\n"); printf("free RTramchain\n");
iguana_utxoupdate(coin,-1,0,0,0,0,-1,0); // free hashtables //iguana_utxoupdate(coin,-1,0,0,0,0,-1,0); // free hashtables
coin->lastRTheight = coin->RTheight = 0;//(coin->bundlescount-1) * coin->chain->bundlesize; coin->lastRTheight = coin->RTheight = 0;//(coin->bundlescount-1) * coin->chain->bundlesize;
coin->RTgenesis = 0; coin->RTgenesis = 0;
iguana_utxoaddrs_purge(coin); iguana_utxoaddrs_purge(coin);
@ -466,6 +466,19 @@ int32_t iguana_realtime_update(struct supernet_info *myinfo,struct iguana_info *
} }
#endif #endif
struct iguana_RTaddr *iguana_RTaddrfind(struct iguana_info *coin,uint8_t *rmd160,char *coinaddr)
{
struct iguana_RTaddr *RTaddr; int32_t len; char _coinaddr[64];
if ( coinaddr == 0 )
{
coinaddr = _coinaddr;
bitcoin_address(coinaddr,coin->chain->pubtype,rmd160,20);
}
len = (int32_t)strlen(coinaddr);
HASH_FIND(hh,coin->RTaddrs,coinaddr,len,RTaddr);
return(RTaddr);
}
int64_t iguana_RTbalance(struct iguana_info *coin,char *coinaddr) int64_t iguana_RTbalance(struct iguana_info *coin,char *coinaddr)
{ {
struct iguana_RTaddr *RTaddr; uint8_t addrtype,rmd160[20]; int32_t len; struct iguana_RTaddr *RTaddr; uint8_t addrtype,rmd160[20]; int32_t len;
@ -521,11 +534,15 @@ void iguana_RTcoinaddr(struct iguana_info *coin,struct iguana_RTtxid *RTptr,stru
printf("%lld %s %.8f h %.8f, cr %.8f deb %.8f [%.8f] numunspents.%d %p\n",(long long)polarity,coinaddr,dstr(value),dstr(RTaddr->histbalance),dstr(RTaddr->credits),dstr(RTaddr->debits),dstr(RTaddr->credits)-dstr(RTaddr->debits)+dstr(RTaddr->histbalance),RTaddr->numunspents,unspent); printf("%lld %s %.8f h %.8f, cr %.8f deb %.8f [%.8f] numunspents.%d %p\n",(long long)polarity,coinaddr,dstr(value),dstr(RTaddr->histbalance),dstr(RTaddr->credits),dstr(RTaddr->debits),dstr(RTaddr->credits)-dstr(RTaddr->debits)+dstr(RTaddr->histbalance),RTaddr->numunspents,unspent);
} }
struct iguana_RTunspent *iguana_RTunspent_create(uint8_t *rmd160,int64_t value,uint8_t *script,int32_t scriptlen) struct iguana_RTunspent *iguana_RTunspent_create(uint8_t *rmd160,int64_t value,uint8_t *script,int32_t scriptlen,struct iguana_RTtxid *parent,int32_t vout)
{ {
struct iguana_RTunspent *unspent; struct iguana_RTunspent *unspent;
unspent = calloc(1,sizeof(*unspent) + scriptlen); unspent = calloc(1,sizeof(*unspent) + scriptlen);
unspent->value = value; unspent->value = value;
if ( (unspent->parent= parent) != 0 )
unspent->height = parent->height;
else unspent->height = -1;
unspent->vout = vout;
unspent->scriptlen = scriptlen; unspent->scriptlen = scriptlen;
memcpy(unspent->rmd160,rmd160,sizeof(unspent->rmd160)); memcpy(unspent->rmd160,rmd160,sizeof(unspent->rmd160));
memcpy(unspent->script,script,scriptlen); memcpy(unspent->script,script,scriptlen);
@ -544,7 +561,7 @@ void iguana_RTunspent(struct iguana_info *coin,struct iguana_RTtxid *RTptr,struc
{ {
if ( polarity > 0 ) if ( polarity > 0 )
{ {
unspent = iguana_RTunspent_create(rmd160,value,script,scriptlen); unspent = iguana_RTunspent_create(rmd160,value,script,scriptlen>0?scriptlen:0,RTptr,vout);
RTptr->unspents[vout] = unspent; RTptr->unspents[vout] = unspent;
} else printf("iguana_RTunspent missing vout.%d ptr\n",vout); } else printf("iguana_RTunspent missing vout.%d ptr\n",vout);
} }
@ -619,7 +636,7 @@ void iguana_RTspend(struct supernet_info *myinfo,struct iguana_info *coin,struct
{ {
bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr); bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr);
//printf("found unspentind (%s %.8f).%d spendlen.%d\n",coinaddr,dstr(value),addrtype,spendlen); //printf("found unspentind (%s %.8f).%d spendlen.%d\n",coinaddr,dstr(value),addrtype,spendlen);
unspent = iguana_RTunspent_create(rmd160,value,spendscript,spendlen); unspent = iguana_RTunspent_create(rmd160,value,spendscript,spendlen>0?spendlen:0,0,prev_vout);
} }
} }
if ( unspent != 0 ) if ( unspent != 0 )
@ -661,9 +678,14 @@ void iguana_RTdataset_free(struct iguana_info *coin)
} }
} }
struct iguana_RTtxid *iguana_RTtxid(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,int32_t txi,int32_t txn_count,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp) struct iguana_RTtxid *iguana_RTtxid_create(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,int32_t txi,int32_t txn_count,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp)
{ {
struct iguana_RTtxid *RTptr; char str[65]; struct iguana_RTtxid *RTptr; char str[65];
if ( block == 0 || block->height < coin->firstRTheight || block->height >= coin->firstRTheight+sizeof(coin->RTblocks)/sizeof(*coin->RTblocks) )
{
printf("iguana_RTtxid_create: illegal block height.%d\n",block!=0?block->height:-1);
return(0);
}
HASH_FIND(hh,coin->RTdataset,txid.bytes,sizeof(txid),RTptr); HASH_FIND(hh,coin->RTdataset,txid.bytes,sizeof(txid),RTptr);
if ( RTptr == 0 ) if ( RTptr == 0 )
{ {
@ -671,6 +693,7 @@ struct iguana_RTtxid *iguana_RTtxid(struct iguana_info *coin,struct iguana_block
RTptr->txi = txi, RTptr->txn_count = txn_count; RTptr->txi = txi, RTptr->txn_count = txn_count;
RTptr->coin = coin; RTptr->coin = coin;
RTptr->block = block; RTptr->block = block;
RTptr->height = block->height;
RTptr->txid = txid; RTptr->txid = txid;
RTptr->txn_count = txn_count; RTptr->txn_count = txn_count;
RTptr->numvouts = numvouts; RTptr->numvouts = numvouts;
@ -691,10 +714,58 @@ struct iguana_RTtxid *iguana_RTtxid(struct iguana_info *coin,struct iguana_block
return(RTptr); return(RTptr);
} }
int64_t _RTgettxout(struct iguana_info *coin,int32_t *height,int32_t *scriptlen,uint8_t *script,uint8_t *rmd160,char *coinaddr,bits256 txid,int32_t vout,int32_t mempool)
{
int64_t value = 0; struct iguana_RTtxid *RTptr; struct iguana_RTunspent *unspent = 0;
HASH_FIND(hh,coin->RTdataset,txid.bytes,sizeof(txid),RTptr);
if ( RTptr != 0 && (RTptr->height <= coin->blocks.hwmchain.height || mempool != 0) )
{
if ( vout >= 0 && vout < RTptr->txn_count && (unspent= RTptr->unspents[vout]) != 0 )
{
*height = RTptr->height;
if ( (*scriptlen= unspent->scriptlen) > 0 )
memcpy(script,unspent->script,*scriptlen);
memcpy(rmd160,unspent->rmd160,sizeof(unspent->rmd160));
bitcoin_address(coinaddr,coin->chain->pubtype,rmd160,sizeof(unspent->rmd160));
value = unspent->value;
} else printf("vout.%d error %p\n",vout,unspent);
}
return(value);
}
int32_t iguana_RTunspentindfind(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,uint8_t *spendscript,int32_t *spendlenp,uint64_t *valuep,int32_t *heightp,bits256 txid,int32_t vout,int32_t lasthdrsi,int32_t mempool)
{
char _coinaddr[64]; uint8_t rmd160[20]; int64_t value;
if ( coinaddr == 0 )
coinaddr = _coinaddr;
if ( (value= _RTgettxout(coin,heightp,spendlenp,spendscript,rmd160,coinaddr,txid,vout,mempool)) > 0 )
{
if ( valuep != 0 )
*valuep = value;
return(0);
}
else return(iguana_unspentindfind(myinfo,coin,coinaddr,spendscript,spendlenp,valuep,heightp,txid,vout,lasthdrsi,mempool));
}
int32_t _iguana_RTunspentfind(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,uint8_t *spendscript,struct iguana_outpoint outpt,int64_t value)
{
int32_t spendlen = 0; struct iguana_RTunspent *unspent; struct iguana_RTtxid *parent;
if ( outpt.isptr != 0 && (unspent= outpt.ptr) != 0 && (parent= unspent->parent) != 0 )
{
if ( value != unspent->value )
printf("_iguana_RTunspentfind: mismatched value %.8f != %.8f\n",dstr(value),dstr(unspent->value));
if ( (spendlen= unspent->scriptlen) > 0 )
memcpy(spendscript,unspent->script,spendlen);
*txidp = parent->txid;
*voutp = unspent->vout;
}
return(spendlen);
}
void iguana_RTreset(struct iguana_info *coin) void iguana_RTreset(struct iguana_info *coin)
{ {
iguana_utxoaddrs_purge(coin); iguana_utxoaddrs_purge(coin);
iguana_utxoupdate(coin,-1,0,0,0,0,-1,0); // free hashtables //iguana_utxoupdate(coin,-1,0,0,0,0,-1,0); // free hashtables
coin->lastRTheight = 0; coin->lastRTheight = 0;
coin->RTheight = coin->firstRTheight; coin->RTheight = coin->firstRTheight;
iguana_RTdataset_free(coin); iguana_RTdataset_free(coin);
@ -850,11 +921,21 @@ int32_t iguana_RTiterate(struct supernet_info *myinfo,struct iguana_info *coin,i
struct iguana_block *iguana_RTblock(struct iguana_info *coin,int32_t height) struct iguana_block *iguana_RTblock(struct iguana_info *coin,int32_t height)
{ {
int32_t offset; int32_t offset; struct iguana_block *block;
offset = height - coin->firstRTheight; offset = height - coin->firstRTheight;
//printf("%s iguana_RTblock.%d offset.%d\n",coin->symbol,height,offset); //printf("%s iguana_RTblock.%d offset.%d\n",coin->symbol,height,offset);
if ( offset < sizeof(coin->RTblocks)/sizeof(*coin->RTblocks) ) if ( offset < sizeof(coin->RTblocks)/sizeof(*coin->RTblocks) )
return(coin->RTblocks[offset]); {
if ( (block= coin->RTblocks[offset]) != 0 )
{
if ( block->height != coin->firstRTheight+offset )
{
printf("block height mismatch patch %d != %d\n",block->height,coin->firstRTheight+offset);
block->height = coin->firstRTheight+offset;
}
return(block);
}
}
else printf("RTblock offset.%d too big\n",offset); else printf("RTblock offset.%d too big\n",offset);
return(0); return(0);
} }
@ -899,6 +980,12 @@ int32_t iguana_RTblocksub(struct supernet_info *myinfo,struct iguana_info *coin,
void iguana_RTnewblock(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_block *block) void iguana_RTnewblock(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_block *block)
{ {
int32_t i,n,height,hdrsi,bundlei; struct iguana_block *addblock,*subblock; struct iguana_bundle *bp; int32_t i,n,height,hdrsi,bundlei; struct iguana_block *addblock,*subblock; struct iguana_bundle *bp;
if ( block->height < coin->firstRTheight || block->height >= coin->firstRTheight+sizeof(coin->RTblocks)/sizeof(*coin->RTblocks) )
{
if ( coin->firstRTheight > 0 )
printf("iguana_RTnewblock illegal blockheight.%d\n",block->height);
return;
}
if ( coin->RTheight > 0 ) if ( coin->RTheight > 0 )
{ {
if ( block->height > coin->lastRTheight ) if ( block->height > coin->lastRTheight )

4
iguana/iguana_recv.c

@ -517,7 +517,7 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i
for (i=0; i<coin->bundlescount; i++) for (i=0; i<coin->bundlescount; i++)
if ( (bp= coin->bundles[i]) != 0 && bp->utxofinish <= 1 ) if ( (bp= coin->bundles[i]) != 0 && bp->utxofinish <= 1 )
break; break;
if ( i > coin->bundlescount-2 && coin->blocks.hwmchain.height > coin->longestchain-coin->chain->bundlesize*2 ) if ( (i > coin->bundlescount-2 && coin->blocks.hwmchain.height > coin->longestchain-coin->chain->bundlesize*2) || coin->RTheight > 0 )
{ {
portable_mutex_lock(&coin->RTmutex); portable_mutex_lock(&coin->RTmutex);
iguana_RTrawdata(coin,txdata->zblock.RO.hash2,data,&recvlen,&numtx,0); iguana_RTrawdata(coin,txdata->zblock.RO.hash2,data,&recvlen,&numtx,0);
@ -1845,7 +1845,7 @@ int32_t iguana_processrecv(struct supernet_info *myinfo,struct iguana_info *coin
fprintf(stderr,"%s call balanceflush\n",coin->symbol); fprintf(stderr,"%s call balanceflush\n",coin->symbol);
//portable_mutex_lock(&coin->RTmutex); //portable_mutex_lock(&coin->RTmutex);
coin->disableUTXO = 1; coin->disableUTXO = 1;
iguana_utxoupdate(coin,-1,0,0,0,0,-1,0); // free hashtables //iguana_utxoupdate(coin,-1,0,0,0,0,-1,0); // free hashtables
if ( iguana_balanceflush(myinfo,coin,coin->balanceflush) > 0 ) if ( iguana_balanceflush(myinfo,coin,coin->balanceflush) > 0 )
printf("balanceswritten.%d flushed coin->balanceflush %d vs %d coin->longestchain/coin->chain->bundlesize\n",coin->balanceswritten,coin->balanceflush,coin->longestchain/coin->chain->bundlesize); printf("balanceswritten.%d flushed coin->balanceflush %d vs %d coin->longestchain/coin->chain->bundlesize\n",coin->balanceswritten,coin->balanceflush,coin->longestchain/coin->chain->bundlesize);
//portable_mutex_unlock(&coin->RTmutex); //portable_mutex_unlock(&coin->RTmutex);

368
iguana/iguana_unspents.c

@ -20,40 +20,50 @@
#include "iguana777.h" #include "iguana777.h"
#include "exchanges/bitcoin.h" #include "exchanges/bitcoin.h"
int32_t iguana_RTunspentind2txid(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *spentheightp,bits256 *txidp,int32_t *voutp,struct iguana_outpoint outpt)
int32_t iguana_unspentind2txid(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *spentheightp,bits256 *txidp,int32_t *voutp,int16_t hdrsi,uint32_t unspentind)
{ {
struct iguana_ramchaindata *rdata=0; struct iguana_bundle *bp=0; struct iguana_unspent *U,*u; struct iguana_txid *T,*t; struct iguana_ramchaindata *rdata=0; struct iguana_bundle *bp=0; struct iguana_unspent *U,*u; struct iguana_txid *T,*t; struct iguana_RTunspent *unspent; struct iguana_RTtxid *parent;
*voutp = *spentheightp = -1; *voutp = *spentheightp = -1;
memset(txidp,0,sizeof(*txidp)); memset(txidp,0,sizeof(*txidp));
if ( outpt.isptr != 0 && (unspent= outpt.ptr) != 0 )
{
if ( (parent= unspent->parent) != 0 )
{
*txidp = parent->txid;
*spentheightp = parent->height;
}
*voutp = unspent->vout;
return(0);
}
memset(txidp,0,sizeof(*txidp));
//if ( hdrsi == coin->bundlescount-1 ) //if ( hdrsi == coin->bundlescount-1 )
// rdata = coin->RTramchain.H.data; // rdata = coin->RTramchain.H.data;
//else if ( (bp= coin->bundles[hdrsi]) != 0 ) //else if ( (bp= coin->bundles[hdrsi]) != 0 )
bp = coin->bundles[hdrsi]; bp = coin->bundles[outpt.hdrsi];
rdata = bp->ramchain.H.data; rdata = bp->ramchain.H.data;
while ( rdata != 0 && unspentind > 0 && unspentind < rdata->numunspents ) while ( rdata != 0 && outpt.unspentind > 0 && outpt.unspentind < rdata->numunspents )
{ {
U = RAMCHAIN_PTR(rdata,Uoffset); U = RAMCHAIN_PTR(rdata,Uoffset);
u = &U[unspentind]; u = &U[outpt.unspentind];
if ( u->txidind > 0 && u->txidind < rdata->numtxids ) if ( u->txidind > 0 && u->txidind < rdata->numtxids )
{ {
T = RAMCHAIN_PTR(rdata,Toffset); T = RAMCHAIN_PTR(rdata,Toffset);
t = &T[u->txidind]; t = &T[u->txidind];
if ( unspentind >= t->firstvout ) if ( outpt.unspentind >= t->firstvout )
{ {
*txidp = t->txid; *txidp = t->txid;
*spentheightp = (hdrsi * coin->chain->bundlesize) + t->bundlei; *spentheightp = (outpt.hdrsi * coin->chain->bundlesize) + t->bundlei;
*voutp = unspentind - t->firstvout; *voutp = outpt.unspentind - t->firstvout;
return(0); return(0);
} }
} }
else if ( bp == 0 && (bp= coin->bundles[hdrsi]) != 0 ) else if ( bp == 0 && (bp= coin->bundles[outpt.hdrsi]) != 0 )
rdata = bp->ramchain.H.data; rdata = bp->ramchain.H.data;
else break; else break;
} }
return(-1); return(-1);
//{"txid":"e34686afc17ec37a8438f0c9a7e48f98d0c625c7917a59c2d7fa22b53d570115","vout":1,"address":"16jsjc1YvzDXqKf7PorMhTyK8ym3ra3uxm","scriptPubKey":"76a9143ef4734c1141725c095342095f6e0e7748b6c16588ac","amount":0.01000000,"timestamp":0,"height":419261,"confirmations":1729,"checkind":4497018,"account":"default","spendable":true,"spent":{"hdrsi":209,"pkind":2459804,"unspentind":4497018,"prevunspentind":0,"satoshis":"1000000","txidind":1726947,"vout":1,"type":2,"fileid":0,"scriptpos":0,"scriptlen":25},"spentheight":419713,"dest":{"spentfrom":"22651e62f248fe2e72053d650f177e4b246ee016605102a40419e603b2bbeac8","vin":0,"timestamp":0,"vouts":[{"1KRhTPvoxyJmVALwHFXZdeeWFbcJSbkFPu":0.00010000}, {"1GQHQ7vwVpGeir2kKrYATsLtrkUQSc7FGY":0.00980000}],"total":0.00990000,"ratio":1}} //{"txid":"e34686afc17ec37a8438f0c9a7e48f98d0c625c7917a59c2d7fa22b53d570115","vout":1,"address":"16jsjc1YvzDXqKf7PorMhTyK8ym3ra3uxm","scriptPubKey":"76a9143ef4734c1141725c095342095f6e0e7748b6c16588ac","amount":0.01000000,"timestamp":0,"height":419261,"confirmations":1729,"checkind":4497018,"account":"default","spendable":true,"spent":{"hdrsi":209,"pkind":2459804,"unspentind":4497018,"prevunspentind":0,"satoshis":"1000000","txidind":1726947,"vout":1,"type":2,"fileid":0,"scriptpos":0,"scriptlen":25},"spentheight":419713,"dest":{"spentfrom":"22651e62f248fe2e72053d650f177e4b246ee016605102a40419e603b2bbeac8","vin":0,"timestamp":0,"vouts":[{"1KRhTPvoxyJmVALwHFXZdeeWFbcJSbkFPu":0.00010000}, {"1GQHQ7vwVpGeir2kKrYATsLtrkUQSc7FGY":0.00980000}],"total":0.00990000,"ratio":1}}
cJSON *retarray,*item,*uitem,*sitem; char *retstr; int32_t i,n,retval = -1; /* cJSON *retarray,*item,*uitem,*sitem; char *retstr; int32_t i,n,retval = -1;
*voutp = *spentheightp = -1; *voutp = *spentheightp = -1;
memset(txidp,0,sizeof(*txidp)); memset(txidp,0,sizeof(*txidp));
if ( (retstr= bitcoinrpc_listunspent(myinfo,coin,0,0,0,0,0)) != 0 ) if ( (retstr= bitcoinrpc_listunspent(myinfo,coin,0,0,0,0,0)) != 0 )
@ -93,12 +103,12 @@ int32_t iguana_unspentind2txid(struct supernet_info *myinfo,struct iguana_info *
} }
free(retstr); free(retstr);
} }
return(retval); return(retval);*/
} }
int32_t iguana_unspentindfind(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,uint8_t *spendscript,int32_t *spendlenp,uint64_t *valuep,int32_t *heightp,bits256 txid,int32_t vout,int32_t lasthdrsi,int32_t mempool) int32_t iguana_unspentindfind(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,uint8_t *spendscript,int32_t *spendlenp,uint64_t *valuep,int32_t *heightp,bits256 txid,int32_t vout,int32_t lasthdrsi,int32_t mempool)
{ {
struct iguana_txid *tp,TX; struct gecko_memtx *memtx; struct iguana_pkhash *P; struct iguana_unspent *U; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata; int64_t RTspend; int64_t value; int32_t pkind,hdrsi,firstvout,spentheight,flag=0,unspentind = -1; struct iguana_txid *tp,TX; struct gecko_memtx *memtx; struct iguana_pkhash *P; struct iguana_unspent *U; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata; int64_t RTspend; int64_t value; struct iguana_outpoint spentpt; int32_t pkind,hdrsi,firstvout,spentheight,flag=0,unspentind = -1;
//portable_mutex_lock(&coin->RTmutex); //portable_mutex_lock(&coin->RTmutex);
if ( valuep != 0 ) if ( valuep != 0 )
*valuep = 0; *valuep = 0;
@ -117,7 +127,10 @@ int32_t iguana_unspentindfind(struct supernet_info *myinfo,struct iguana_info *c
{ {
RTspend = 0; RTspend = 0;
flag++; flag++;
if ( iguana_spentflag(myinfo,coin,&RTspend,&spentheight,&bp->ramchain,bp->hdrsi,unspentind,0,1,coin->longestchain,U[unspentind].value) == 0 ) //bp == coin->current ? &coin->RTramchain : memset(&spentpt,0,sizeof(spentpt));
spentpt.hdrsi = bp->hdrsi;
spentpt.unspentind = unspentind;
if ( iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,&bp->ramchain,spentpt,0,1,coin->longestchain,U[unspentind].value) == 0 ) //bp == coin->current ? &coin->RTramchain :
{ {
if ( valuep != 0 ) if ( valuep != 0 )
*valuep = U[unspentind].value; *valuep = U[unspentind].value;
@ -148,11 +161,11 @@ int32_t iguana_unspentindfind(struct supernet_info *myinfo,struct iguana_info *c
return(unspentind); return(unspentind);
} }
char *iguana_RTinputaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int16_t *spent_hdrsip,uint32_t *unspentindp,cJSON *vinobj) char *iguana_RTinputaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,struct iguana_outpoint *spentp,cJSON *vinobj)
{ {
bits256 txid; int32_t vout,checkind,height; bits256 txid; int32_t vout,checkind,height;
*unspentindp = 0; memset(spentp,0,sizeof(*spentp));
*spent_hdrsip = -1; spentp->hdrsi = -1;
if ( jobj(vinobj,"txid") != 0 && jobj(vinobj,"vout") != 0 ) if ( jobj(vinobj,"txid") != 0 && jobj(vinobj,"vout") != 0 )
{ {
txid = jbits256(vinobj,"txid"); txid = jbits256(vinobj,"txid");
@ -161,8 +174,8 @@ char *iguana_RTinputaddress(struct supernet_info *myinfo,struct iguana_info *coi
checkind = jint(vinobj,"checkind"); checkind = jint(vinobj,"checkind");
if ( (height != 0 && checkind != 0) || (checkind= iguana_RTunspentindfind(myinfo,coin,coinaddr,0,0,0,&height,txid,vout,coin->bundlescount-1,0)) > 0 ) if ( (height != 0 && checkind != 0) || (checkind= iguana_RTunspentindfind(myinfo,coin,coinaddr,0,0,0,&height,txid,vout,coin->bundlescount-1,0)) > 0 )
{ {
*spent_hdrsip = (height / coin->chain->bundlesize); spentp->hdrsi = (height / coin->chain->bundlesize);
*unspentindp = checkind; spentp->unspentind = checkind;
return(coinaddr); return(coinaddr);
} }
else else
@ -191,7 +204,7 @@ cJSON *ramchain_unspentjson(struct iguana_unspent *up,uint32_t unspentind)
return(item); return(item);
} }
cJSON *ramchain_spentjson(struct iguana_info *coin,int32_t spentheight,int32_t hdrsi,int32_t unspentind,bits256 txid,int32_t vout,int64_t uvalue) cJSON *ramchain_spentjson(struct iguana_info *coin,int32_t spentheight,bits256 txid,int32_t vout,int64_t uvalue)
{ {
char coinaddr[64]; bits256 hash2,*X; struct iguana_txid T,*tx,*spentT,*spent_tx; struct iguana_bundle *bp; int32_t j,i,ind; struct iguana_block *block; int64_t total = 0; struct iguana_unspent *U,*u; struct iguana_pkhash *P; struct iguana_spend *S,*s; struct iguana_ramchaindata *rdata; cJSON *addrs,*item,*voutobj; char coinaddr[64]; bits256 hash2,*X; struct iguana_txid T,*tx,*spentT,*spent_tx; struct iguana_bundle *bp; int32_t j,i,ind; struct iguana_block *block; int64_t total = 0; struct iguana_unspent *U,*u; struct iguana_pkhash *P; struct iguana_spend *S,*s; struct iguana_ramchaindata *rdata; cJSON *addrs,*item,*voutobj;
item = cJSON_CreateObject(); item = cJSON_CreateObject();
@ -252,7 +265,7 @@ cJSON *ramchain_spentjson(struct iguana_info *coin,int32_t spentheight,int32_t h
return(item); return(item);
} }
cJSON *iguana_unspentjson(struct supernet_info *myinfo,struct iguana_info *coin,int32_t hdrsi,uint32_t unspentind,struct iguana_txid *T,struct iguana_unspent *up,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t spentheight,char *remoteaddr) cJSON *iguana_RTunspentjson(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint outpt,bits256 txid,int32_t vout,int64_t value,struct iguana_unspent *up,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t spentheight,char *remoteaddr)
{ {
/*{ /*{
"txid" : "d54994ece1d11b19785c7248868696250ab195605b469632b7bd68130e880c9a", "txid" : "d54994ece1d11b19785c7248868696250ab195605b469632b7bd68130e880c9a",
@ -265,16 +278,27 @@ cJSON *iguana_unspentjson(struct supernet_info *myinfo,struct iguana_info *coin,
"spendable" : true "spendable" : true
},*/ },*/
//struct iguana_unspent { uint64_t value; uint32_t txidind,pkind,prevunspentind; uint16_t hdrsi:12,type:4,vout; } __attribute__((packed)); //struct iguana_unspent { uint64_t value; uint32_t txidind,pkind,prevunspentind; uint16_t hdrsi:12,type:4,vout; } __attribute__((packed));
struct iguana_waccount *wacct; struct iguana_waddress *waddr; int32_t height; char scriptstr[8192],asmstr[sizeof(scriptstr)+1024]; cJSON *item; uint32_t checkind; struct iguana_waccount *wacct; struct iguana_waddress *waddr; int32_t height; char scriptstr[8192],asmstr[sizeof(scriptstr)+1024]; cJSON *item; uint32_t checkind; struct iguana_RTunspent *unspent;
item = cJSON_CreateObject(); item = cJSON_CreateObject();
jaddbits256(item,"txid",T[up->txidind].txid); jaddbits256(item,"txid",txid);
jaddnum(item,"vout",up->vout); jaddnum(item,"vout",vout);
jaddstr(item,"address",coinaddr); jaddstr(item,"address",coinaddr);
if ( iguana_scriptget(coin,scriptstr,asmstr,sizeof(scriptstr),hdrsi,unspentind,T[up->txidind].txid,up->vout,rmd160,up->type,pubkey33) != 0 ) if ( outpt.isptr != 0 && (unspent= outpt.ptr) != 0 )
jaddstr(item,"scriptPubKey",scriptstr); {
jaddnum(item,"amount",dstr(up->value)); if ( unspent->scriptlen > 0 )
jaddnum(item,"timestamp",T[up->txidind].timestamp); {
if ( (checkind= iguana_unspentindfind(myinfo,coin,0,0,0,0,&height,T[up->txidind].txid,up->vout,coin->bundlescount-1,0)) != 0 ) init_hexbytes_noT(scriptstr,unspent->script,unspent->scriptlen);
jaddstr(item,"scriptPubKey",scriptstr);
}
}
else
{
if ( iguana_scriptget(coin,scriptstr,asmstr,sizeof(scriptstr),outpt.hdrsi,outpt.unspentind,txid,up->vout,rmd160,up->type,pubkey33) != 0 )
jaddstr(item,"scriptPubKey",scriptstr);
}
jaddnum(item,"amount",dstr(value));
//jaddnum(item,"timestamp",T[up->txidind].timestamp);
if ( (checkind= iguana_RTunspentindfind(myinfo,coin,0,0,0,0,&height,txid,vout,coin->bundlescount-1,0)) != 0 )
{ {
jaddnum(item,"height",height); jaddnum(item,"height",height);
jaddnum(item,"confirmations",coin->blocks.hwmchain.height - height + 1); jaddnum(item,"confirmations",coin->blocks.hwmchain.height - height + 1);
@ -285,25 +309,41 @@ cJSON *iguana_unspentjson(struct supernet_info *myinfo,struct iguana_info *coin,
if ( (waddr= iguana_waddresssearch(myinfo,&wacct,coinaddr)) != 0 ) if ( (waddr= iguana_waddresssearch(myinfo,&wacct,coinaddr)) != 0 )
{ {
jaddstr(item,"account",wacct->account); jaddstr(item,"account",wacct->account);
jadd(item,"spendable",jtrue()); if ( spentheight == 0 )
jadd(item,"spendable",jtrue());
else jadd(item,"spendable",jfalse());
} else jadd(item,"spendable",jfalse()); } else jadd(item,"spendable",jfalse());
} }
if ( spentheight > 0 ) if ( spentheight > 0 )
{ {
jadd(item,"spent",ramchain_unspentjson(up,unspentind)); if ( up != 0 )
jadd(item,"spent",ramchain_unspentjson(up,outpt.unspentind));
jaddnum(item,"spentheight",spentheight); jaddnum(item,"spentheight",spentheight);
jadd(item,"dest",ramchain_spentjson(coin,spentheight,hdrsi,unspentind,T[up->txidind].txid,up->vout,up->value)); jadd(item,"dest",ramchain_spentjson(coin,spentheight,txid,vout,value));
}
} else jadd(item,"unspent",ramchain_unspentjson(up,unspentind)); else if ( up != 0 )
jadd(item,"unspent",ramchain_unspentjson(up,outpt.unspentind));
return(item); return(item);
} }
struct iguana_pkhash *iguana_pkhashfind(struct iguana_info *coin,struct iguana_ramchain **ramchainp,int64_t *depositsp,uint32_t *lastunspentindp,struct iguana_pkhash *p,uint8_t rmd160[20],int32_t firsti,int32_t endi) struct iguana_pkhash *iguana_pkhashfind(struct iguana_info *coin,struct iguana_ramchain **ramchainp,int64_t *depositsp,struct iguana_outpoint *lastptp,struct iguana_pkhash *p,uint8_t rmd160[20],int32_t firsti,int32_t endi)
{ {
uint8_t *PKbits; struct iguana_pkhash *P; uint32_t pkind,numpkinds,i; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; struct iguana_ramchaindata *rdata; struct iguana_account *ACCTS; uint8_t *PKbits; struct iguana_pkhash *P; uint32_t pkind,numpkinds,i; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; struct iguana_ramchaindata *rdata; struct iguana_account *ACCTS; struct iguana_RTaddr *RTaddr;
*depositsp = 0; *depositsp = 0;
*ramchainp = 0; *ramchainp = 0;
*lastunspentindp = 0; memset(lastptp,0,sizeof(*lastptp));
if ( firsti == coin->bundlescount && endi == firsti )
{
if ( (RTaddr= iguana_RTaddrfind(coin,rmd160,0)) != 0 )
{
*depositsp = RTaddr->credits;
if ( (lastptp->ptr= RTaddr->lastunspent) != 0 )
lastptp->isptr = 1;
memcpy(p->rmd160,rmd160,sizeof(p->rmd160));
p->pkind = 0;
return(p);
} else return(0);
}
for (i=firsti; i<coin->bundlescount&&i<=endi; i++) for (i=firsti; i<coin->bundlescount&&i<=endi; i++)
{ {
if ( (bp= coin->bundles[i]) != 0 ) if ( (bp= coin->bundles[i]) != 0 )
@ -326,7 +366,8 @@ struct iguana_pkhash *iguana_pkhashfind(struct iguana_info *coin,struct iguana_r
{ {
*ramchainp = ramchain; *ramchainp = ramchain;
*depositsp = ACCTS[pkind].total; *depositsp = ACCTS[pkind].total;
*lastunspentindp = ACCTS[pkind].lastunspentind; lastptp->hdrsi = bp->hdrsi;
lastptp->unspentind = ACCTS[pkind].lastunspentind;
//printf("[%d] return pkind.%u of %u P.%p %.8f last.%u ACCTS.%p %p\n",i,pkind,numpkinds,P,dstr(*depositsp),*lastunspentindp,ACCTS,ramchain->A); //printf("[%d] return pkind.%u of %u P.%p %.8f last.%u ACCTS.%p %p\n",i,pkind,numpkinds,P,dstr(*depositsp),*lastunspentindp,ACCTS,ramchain->A);
if ( P != 0 ) if ( P != 0 )
*p = P[pkind]; *p = P[pkind];
@ -349,19 +390,18 @@ int32_t iguana_uheight(struct iguana_info *coin,int32_t bundleheight,struct igua
int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20]) int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20])
{ {
int64_t deposits,crypto777_payment; uint32_t lastunspentind,unspentind; int32_t i,j,num,uheight; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; struct iguana_ramchaindata *rdata; struct iguana_pkhash *P,p; struct iguana_unspent *U,*u; struct iguana_txid *T,*tx; int64_t deposits,crypto777_payment; struct iguana_outpoint lastpt; uint32_t unspentind; int32_t i,j,num,uheight; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; struct iguana_ramchaindata *rdata; struct iguana_pkhash *P,p; struct iguana_unspent *U,*u; struct iguana_txid *T,*tx;
for (i=num=0; i<coin->bundlescount; i++) for (i=num=0; i<coin->bundlescount&&i*coin->chain->bundlesize<coin->firstRTheight; i++)
{ {
if ( (bp= coin->bundles[i]) != 0 ) if ( (bp= coin->bundles[i]) != 0 )
{ {
//iguana_volatilesalloc(coin,&bp->ramchain,1);
//iguana_volatilesmap(coin,&bp->ramchain);
ramchain = 0; ramchain = 0;
if ( iguana_pkhashfind(coin,&ramchain,&deposits,&lastunspentind,&p,rmd160,i,i) != 0 ) memset(&lastpt,0,sizeof(lastpt));
if ( iguana_pkhashfind(coin,&ramchain,&deposits,&lastpt,&p,rmd160,i,i) != 0 )
{ {
if ( ramchain != 0 && (rdata= ramchain->H.data) != 0 ) if ( ramchain != 0 && (rdata= ramchain->H.data) != 0 )
{ {
unspentind = lastunspentind; unspentind = lastpt.unspentind;
U = RAMCHAIN_PTR(rdata,Uoffset); U = RAMCHAIN_PTR(rdata,Uoffset);
T = RAMCHAIN_PTR(rdata,Toffset); T = RAMCHAIN_PTR(rdata,Toffset);
P = RAMCHAIN_PTR(rdata,Poffset); P = RAMCHAIN_PTR(rdata,Poffset);
@ -372,7 +412,6 @@ int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *c
uheight = iguana_uheight(coin,ramchain->height,T,rdata->numtxids,u); uheight = iguana_uheight(coin,ramchain->height,T,rdata->numtxids,u);
for (crypto777_payment=j=0; j<tx->numvouts; j++,u++) for (crypto777_payment=j=0; j<tx->numvouts; j++,u++)
{ {
//u = &U[tx->firstvout + j];
crypto777_payment = datachain_update(myinfo,0,coin,tx->timestamp,bp,P[u->pkind].rmd160,crypto777_payment,u->type,uheight,(((uint64_t)bp->hdrsi << 32) | unspentind),u->value,u->fileid,u->scriptpos,u->scriptlen,tx->txid,j); crypto777_payment = datachain_update(myinfo,0,coin,tx->timestamp,bp,P[u->pkind].rmd160,crypto777_payment,u->type,uheight,(((uint64_t)bp->hdrsi << 32) | unspentind),u->value,u->fileid,u->scriptpos,u->scriptlen,tx->txid,j);
} }
num++; num++;
@ -382,13 +421,38 @@ int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *c
} }
} }
} }
//iguana_utxoaddr_gen(myinfo,coin,(coin->bundlescount - 1) * coin->chain->bundlesize); // do a RT scan here
return(num); return(num);
} }
int64_t iguana_pkhashbalance(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int64_t *spentp,int64_t *unspents,int32_t *nump,struct iguana_ramchain *ramchain,struct iguana_pkhash *p,uint32_t lastunspentind,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t hdrsi,int32_t lastheight,int32_t minconf,int32_t maxconf,char *remoteaddr) int32_t iguana_RTscanunspents(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,cJSON *array,int64_t *spentp,int64_t *depositsp,struct iguana_outpoint *unspents,int32_t max,uint8_t *rmd160,char *coinaddr,uint8_t *pubkey33,struct iguana_outpoint lastpt,int32_t lastheight)
{
int32_t spentheight,n = 0; struct iguana_outpoint outpt; bits256 txid; struct iguana_RTunspent *unspent = lastpt.ptr;
while ( unspent != 0 )
{
if ( lastheight <= 0 || unspent->height < lastheight )
{
if ( unspent->spend == 0 )
{
spentheight = unspent->height;
if ( array != 0 )
jaddi(array,iguana_RTunspentjson(myinfo,coin,outpt,txid,unspent->vout,unspent->value,0,rmd160,coinaddr,pubkey33,spentheight,remoteaddr));
*depositsp += unspent->value;
memset(&outpt,0,sizeof(outpt));
outpt.isptr = 1;
outpt.ptr = unspent;
outpt.hdrsi = unspent->height / coin->chain->bundlesize;
unspents[n++] = outpt;
} else *spentp += unspent->value;
}
unspent = unspent->prevunspent;
}
return(n);
}
int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int64_t *spentp,struct iguana_outpoint *unspents,int32_t *nump,struct iguana_ramchain *ramchain,struct iguana_pkhash *p,struct iguana_outpoint lastpt,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t lastheight,int32_t minconf,int32_t maxconf,char *remoteaddr)
{ {
struct iguana_unspent *U; struct iguana_utxo *U2; int32_t max,uheight,spentheight; uint32_t pkind=0,unspentind; int64_t spent = 0,checkval,deposits = 0; struct iguana_txid *T; struct iguana_account *A2; struct iguana_ramchaindata *rdata = 0; int64_t RTspend = 0; //struct iguana_spend *S; struct iguana_unspent *U; struct iguana_utxo *U2; int32_t max,uheight,spentheight; uint32_t pkind=0,unspentind; int64_t spent = 0,checkval,deposits = 0; struct iguana_txid *T; struct iguana_account *A2; struct iguana_outpoint outpt; struct iguana_ramchaindata *rdata = 0; int64_t RTspend = 0; //struct iguana_spend *S;
max = *nump; max = *nump;
*spentp = *nump = 0; *spentp = *nump = 0;
if ( 0 && coin->RTramchain_busy != 0 ) if ( 0 && coin->RTramchain_busy != 0 )
@ -396,6 +460,14 @@ int64_t iguana_pkhashbalance(struct supernet_info *myinfo,struct iguana_info *co
printf("iguana_pkhashbalance: unexpected access when RTramchain_busy\n"); printf("iguana_pkhashbalance: unexpected access when RTramchain_busy\n");
return(0); return(0);
} }
if ( ramchain == 0 ) // RT search
{
if ( lastpt.isptr != 0 )
{
*nump = iguana_RTscanunspents(myinfo,coin,remoteaddr,array,spentp,&deposits,unspents,max,rmd160,coinaddr,pubkey33,lastpt,lastheight);
} else printf("iguana_pkhashbalance: unexpected non-ptr lastpt\n");
return(deposits - *spentp);
}
if ( ramchain->Uextras == 0 || (rdata= ramchain->H.data) == 0 ) if ( ramchain->Uextras == 0 || (rdata= ramchain->H.data) == 0 )
{ {
if ( ramchain->height < (coin->bundlescount-1)*coin->chain->bundlesize ) if ( ramchain->height < (coin->bundlescount-1)*coin->chain->bundlesize )
@ -404,7 +476,7 @@ int64_t iguana_pkhashbalance(struct supernet_info *myinfo,struct iguana_info *co
} else iguana_volatilesalloc(coin,ramchain,0); } else iguana_volatilesalloc(coin,ramchain,0);
return(0); return(0);
} }
unspentind = lastunspentind; unspentind = lastpt.unspentind;
U = RAMCHAIN_PTR(rdata,Uoffset); U = RAMCHAIN_PTR(rdata,Uoffset);
T = RAMCHAIN_PTR(rdata,Toffset); T = RAMCHAIN_PTR(rdata,Toffset);
RTspend = 0; RTspend = 0;
@ -416,25 +488,27 @@ int64_t iguana_pkhashbalance(struct supernet_info *myinfo,struct iguana_info *co
if ( lastheight <= 0 || uheight < lastheight ) if ( lastheight <= 0 || uheight < lastheight )
{ {
deposits += U[unspentind].value; deposits += U[unspentind].value;
if ( iguana_spentflag(myinfo,coin,&RTspend,&spentheight,ramchain,hdrsi,unspentind,lastheight,minconf,maxconf,U[unspentind].value) == 0 ) memset(&outpt,0,sizeof(outpt));
outpt.hdrsi = lastpt.hdrsi;
outpt.isptr = 0;
outpt.unspentind = unspentind;
outpt.value = U[unspentind].value;
if ( iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,ramchain,outpt,lastheight,minconf,maxconf,U[unspentind].value) == 0 )
{ {
if ( *nump < max && unspents != 0 ) if ( *nump < max && unspents != 0 )
{ unspents[*nump] = outpt;
unspents[*nump << 1] = ((uint64_t)hdrsi << 32) | unspentind;
unspents[(*nump << 1) + 1] = U[unspentind].value;
}
//printf("+%.8f ",dstr(U[unspentind].value)); //printf("+%.8f ",dstr(U[unspentind].value));
(*nump)++; (*nump)++;
if ( array != 0 )
jaddi(array,iguana_unspentjson(myinfo,coin,hdrsi,unspentind,T,&U[unspentind],rmd160,coinaddr,pubkey33,spentheight,remoteaddr));
} }
else else
{ {
//printf("-%.8f ",dstr(U[unspentind].value)); //printf("-%.8f ",dstr(U[unspentind].value));
spent += U[unspentind].value; spent += U[unspentind].value;
} }
if ( array != 0 )
jaddi(array,iguana_RTunspentjson(myinfo,coin,outpt,T[U[unspentind].txidind].txid,U[unspentind].vout,U[unspentind].value,&U[unspentind],rmd160,coinaddr,pubkey33,spentheight,remoteaddr));
if ( p->pkind != U[unspentind].pkind ) if ( p->pkind != U[unspentind].pkind )
printf("warning: [%d] p->pkind.%u vs U->pkind.%u for u%d\n",hdrsi,p->pkind,U[unspentind].pkind,unspentind); printf("warning: [%d] p->pkind.%u vs U->pkind.%u for u%d\n",lastpt.hdrsi,p->pkind,U[unspentind].pkind,unspentind);
} // else printf("skip uheight.%d lastheight.%d\n",uheight,lastheight); } // else printf("skip uheight.%d lastheight.%d\n",uheight,lastheight);
pkind = p->pkind; pkind = p->pkind;
unspentind = U[unspentind].prevunspentind; unspentind = U[unspentind].prevunspentind;
@ -455,16 +529,16 @@ int64_t iguana_pkhashbalance(struct supernet_info *myinfo,struct iguana_info *co
unspentind = U2[unspentind].prevunspentind; unspentind = U2[unspentind].prevunspentind;
} }
if ( 0 && llabs(spent - checkval - RTspend) > SMALLVAL ) if ( 0 && llabs(spent - checkval - RTspend) > SMALLVAL )
printf("spend %s: [%d] deposits %.8f spent %.8f check %.8f (%.8f) vs A2[%u] %.8f\n",lastheight==IGUANA_MAXHEIGHT?"checkerr":"",hdrsi,dstr(deposits),dstr(spent),dstr(checkval)+dstr(RTspend),dstr(*spentp),pkind,dstr(A2[pkind].total)); printf("spend %s: [%d] deposits %.8f spent %.8f check %.8f (%.8f) vs A2[%u] %.8f\n",lastheight==IGUANA_MAXHEIGHT?"checkerr":"",lastpt.hdrsi,dstr(deposits),dstr(spent),dstr(checkval)+dstr(RTspend),dstr(*spentp),pkind,dstr(A2[pkind].total));
} }
(*spentp) = spent; (*spentp) = spent;
//printf("(%s) spent %.8f, RTspent %.8f deposits %.8f\n",coinaddr,dstr(spent),dstr(RTspend),dstr(deposits)); //printf("(%s) spent %.8f, RTspent %.8f deposits %.8f\n",coinaddr,dstr(spent),dstr(RTspend),dstr(deposits));
return(deposits - spent); return(deposits - spent);
} }
int32_t iguana_pkhasharray(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,int64_t *totalp,struct iguana_pkhash *P,int32_t max,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t lastheight,int64_t *unspents,int32_t *numunspentsp,int32_t maxunspents,char *remoteaddr) int32_t iguana_RTpkhasharray(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,int64_t *totalp,struct iguana_pkhash *P,int32_t max,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t lastheight,struct iguana_outpoint *unspents,int32_t *numunspentsp,int32_t maxunspents,char *remoteaddr)
{ {
int32_t i,n,m,numunspents; int64_t spent,deposits,netbalance,total; uint32_t lastunspentind; struct iguana_pkhash *p,_p; struct iguana_ramchain *ramchain; struct iguana_bundle *bp; int32_t i,n,m,numunspents; int64_t spent,deposits,netbalance,total; struct iguana_outpoint lastpt; struct iguana_pkhash *p,_p; struct iguana_ramchain *ramchain; struct iguana_bundle *bp;
if ( 0 && coin->RTramchain_busy != 0 ) if ( 0 && coin->RTramchain_busy != 0 )
{ {
printf("iguana_pkhasharray: unexpected access when RTramchain_busy\n"); printf("iguana_pkhasharray: unexpected access when RTramchain_busy\n");
@ -476,11 +550,12 @@ int32_t iguana_pkhasharray(struct supernet_info *myinfo,struct iguana_info *coin
if ( max > coin->bundlescount ) if ( max > coin->bundlescount )
max = coin->bundlescount; max = coin->bundlescount;
//printf("minconf.%d maxconf.%d max.%d addr.%s last.%d maxunspents.%d\n",minconf,maxconf,max,coinaddr,lastheight,maxunspents); //printf("minconf.%d maxconf.%d max.%d addr.%s last.%d maxunspents.%d\n",minconf,maxconf,max,coinaddr,lastheight,maxunspents);
for (total=n=i=0; i<max; i++) for (total=n=i=0; i<max+(lastheight>=coin->RTheight); i++)
{ {
if ( (bp= coin->bundles[i]) == 0 ) if ( i != max && (bp= coin->bundles[i]) == 0 )
continue; continue;
if ( 0 ) else bp = 0;
if ( bp != 0 )
{ {
if ( lastheight > 0 && bp->bundleheight > lastheight ) if ( lastheight > 0 && bp->bundleheight > lastheight )
{ {
@ -498,11 +573,11 @@ int32_t iguana_pkhasharray(struct supernet_info *myinfo,struct iguana_info *coin
break; break;
} }
} }
if ( iguana_pkhashfind(coin,&ramchain,&deposits,&lastunspentind,P != 0 ? &P[n] : &_p,rmd160,i,i) != 0 ) if ( iguana_pkhashfind(coin,&ramchain,&deposits,&lastpt,P != 0 ? &P[n] : &_p,rmd160,i,i) != 0 )
{ {
m = maxunspents >> 1; m = maxunspents;
p = (P == 0) ? &_p : &P[n]; p = (P == 0) ? &_p : &P[n];
if ( (netbalance= iguana_pkhashbalance(myinfo,coin,array,&spent,unspents != 0 ? &unspents[numunspents << 1] : 0,&m,ramchain,p,lastunspentind,rmd160,coinaddr,pubkey33,i,lastheight,minconf,maxconf,remoteaddr)) != deposits-spent && lastheight == IGUANA_MAXHEIGHT && minconf == 1 && maxconf > coin->blocks.hwmchain.height ) if ( (netbalance= iguana_RTpkhashbalance(myinfo,coin,array,&spent,unspents != 0 ? &unspents[numunspents] : 0,&m,ramchain,p,lastpt,rmd160,coinaddr,pubkey33,lastheight,minconf,maxconf,remoteaddr)) != deposits-spent && lastheight == IGUANA_MAXHEIGHT && minconf == 1 && maxconf > coin->blocks.hwmchain.height )
{ {
printf("pkhash balance mismatch from m.%d check %.8f vs %.8f spent %.8f [%.8f]\n",m,dstr(netbalance),dstr(deposits),dstr(spent),dstr(deposits)-dstr(spent)); printf("pkhash balance mismatch from m.%d check %.8f vs %.8f spent %.8f [%.8f]\n",m,dstr(netbalance),dstr(deposits),dstr(spent),dstr(deposits)-dstr(spent));
} }
@ -529,7 +604,7 @@ int32_t iguana_pkhasharray(struct supernet_info *myinfo,struct iguana_info *coin
return(n); return(n);
} }
int64_t iguana_unspents(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,uint8_t *rmdarray,int32_t numrmds,int32_t lastheight,int64_t *unspents,int32_t *numunspentsp,char *remoteaddr) int64_t iguana_RTunspents(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,uint8_t *rmdarray,int32_t numrmds,int32_t lastheight,struct iguana_outpoint *unspents,int32_t *numunspentsp,char *remoteaddr)
{ {
int64_t total=0,sum=0; struct iguana_pkhash *P; uint8_t *addrtypes,*pubkeys; int32_t i,numunspents,maxunspents,flag = 0; char coinaddr[64]; int64_t total=0,sum=0; struct iguana_pkhash *P; uint8_t *addrtypes,*pubkeys; int32_t i,numunspents,maxunspents,flag = 0; char coinaddr[64];
//portable_mutex_lock(&coin->RTmutex); //portable_mutex_lock(&coin->RTmutex);
@ -550,7 +625,7 @@ int64_t iguana_unspents(struct supernet_info *myinfo,struct iguana_info *coin,cJ
{ {
bitcoin_address(coinaddr,addrtypes[i],&rmdarray[i * 20],20); bitcoin_address(coinaddr,addrtypes[i],&rmdarray[i * 20],20);
*numunspentsp = 0; *numunspentsp = 0;
iguana_pkhasharray(myinfo,coin,array,minconf,maxconf,&total,P,coin->bundlescount,&rmdarray[i * 20],coinaddr,&pubkeys[33*i],lastheight,&unspents[numunspents << 1],numunspentsp,maxunspents,remoteaddr); iguana_RTpkhasharray(myinfo,coin,array,minconf,maxconf,&total,P,coin->bundlescount,&rmdarray[i * 20],coinaddr,&pubkeys[33*i],lastheight,&unspents[numunspents],numunspentsp,maxunspents,remoteaddr);
//printf("iguana_unspents: i.%d of %d: %s %.8f numunspents.%d\n",i,numrmds,coinaddr,dstr(total),*numunspentsp); //printf("iguana_unspents: i.%d of %d: %s %.8f numunspents.%d\n",i,numrmds,coinaddr,dstr(total),*numunspentsp);
maxunspents -= *numunspentsp; maxunspents -= *numunspentsp;
numunspents += *numunspentsp; numunspents += *numunspentsp;
@ -622,7 +697,7 @@ int64_t *iguana_PoS_weights(struct supernet_info *myinfo,struct iguana_info *coi
if ( (rmdarray= iguana_rmdarray(myinfo,coin,&numrmds,array,0)) != 0 ) if ( (rmdarray= iguana_rmdarray(myinfo,coin,&numrmds,array,0)) != 0 )
{ {
numunspents = 0; numunspents = 0;
balance = iguana_unspents(myinfo,coin,0,minconf,(1 << 30),rmdarray,numrmds,lastheight,0,&numunspents,0); balance = iguana_RTunspents(myinfo,coin,0,minconf,(1 << 30),rmdarray,numrmds,lastheight,0,&numunspents,0);
free(rmdarray); free(rmdarray);
weights[pkind] += balance; weights[pkind] += balance;
if ( weights[pkind] != balance ) if ( weights[pkind] != balance )
@ -695,64 +770,39 @@ int32_t iguana_staker_sort(struct iguana_info *coin,bits256 *hash2p,uint8_t *ref
return((int32_t)sortbuf[1].uints[5]); return((int32_t)sortbuf[1].uints[5]);
} }
int32_t iguana_unspent_check(struct supernet_info *myinfo,struct iguana_info *coin,uint16_t hdrsi,uint32_t unspentind) int32_t iguana_RTunspent_check(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint outpt)
{ {
bits256 txid; int32_t vout,spentheight; bits256 txid; int32_t vout,spentheight;
memset(&txid,0,sizeof(txid)); memset(&txid,0,sizeof(txid));
if ( iguana_unspentind2txid(myinfo,coin,&spentheight,&txid,&vout,hdrsi,unspentind) == 0 ) if ( iguana_RTunspentind2txid(myinfo,coin,&spentheight,&txid,&vout,outpt) == 0 )
{ {
//char str[65]; printf("verify %s/v%d is not already used\n",bits256_str(str,txid),vout); //char str[65]; printf("verify %s/v%d is not already used\n",bits256_str(str,txid),vout);
if ( basilisk_addspend(myinfo,coin->symbol,txid,vout,0) != 0 ) if ( basilisk_addspend(myinfo,coin->symbol,txid,vout,0) != 0 )
{ {
char str[65]; printf("iguana_unspent_check found unspentind (%u %d) %s\n",hdrsi,unspentind,bits256_str(str,txid)); char str[65]; printf("iguana_unspent_check found unspentind (%u %d) %s\n",outpt.hdrsi,outpt.unspentind,bits256_str(str,txid));
return(1); return(1);
} else return(0); } else return(0);
} }
printf("iguana_unspent_check: couldnt find (%d %d)\n",hdrsi,unspentind); printf("iguana_unspent_check: couldnt find (%d %d)\n",outpt.hdrsi,outpt.unspentind);
return(-1); return(-1);
} }
int32_t iguana_addr_unspents(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *sump,int64_t *unspents,int32_t max,char *coinaddr,char *remoteaddr,int32_t lastheight) int32_t iguana_RTaddr_unspents(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *sump,struct iguana_outpoint *unspents,int32_t max,char *coinaddr,char *remoteaddr,int32_t lastheight)
{ {
int32_t n,k,numunspents,minconf = 0; int64_t total; uint8_t rmd160[20],pubkey[65],addrtype; int32_t n,k,numunspents,minconf = 0; int64_t total; uint8_t rmd160[20],pubkey[65],addrtype;
total = 0; total = 0;
n = numunspents = 0; n = numunspents = 0;
bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr); bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr);
iguana_pkhasharray(myinfo,coin,0,minconf,coin->longestchain,&total,0,coin->bundlescount,rmd160,coinaddr,pubkey,lastheight,unspents,&n,max-1000,remoteaddr); iguana_RTpkhasharray(myinfo,coin,0,minconf,coin->longestchain,&total,0,coin->bundlescount,rmd160,coinaddr,pubkey,lastheight,unspents,&n,max-1000,remoteaddr);
/*if ( n > 0 )
{
candidates = unspents;
for (j=0; j<n; j++)
{
hdrsi = (int32_t)(candidates[j << 1] >> 32);
unspentind = (int32_t)candidates[j << 1];
if ( iguana_unspent_check(myinfo,coin,hdrsi,unspentind) == 0 )
{
//printf("(%d u%d) %.8f not in mempool\n",hdrsi,unspentind,dstr(candidates[(j << 1) + 1]));
//for (k=0; k<numunspents; k++)
// if ( &unspents[k<<1] != &candidates[j<<1] && unspents[k << 1] == candidates[j << 1] )
// break;
//if ( k == numunspents )
{
//unspents[numunspents << 1] = candidates[j << 1];
//unspents[(numunspents << 1) + 1] = candidates[(j << 1) + 1];
printf("[%d u%d %.8f] ",hdrsi,unspentind,dstr(unspents[(numunspents << 1) + 1]));
(*sump) += unspents[(numunspents << 1) + 1];
unspents += 2;
numunspents++;
} else printf("found duplicate unspent j.%d numunspents.%d\n",j,numunspents);
} else printf("found spent unspent j.%d numunspents.%d\n",j,numunspents);
}
}*/
numunspents = n; numunspents = n;
for (k=0; k<n; k++) for (k=0; k<n; k++)
(*sump) += unspents[(k << 1) + 1]; (*sump) += unspents[k].value;
return(numunspents); return(numunspents);
} }
int32_t iguana_unspentslists(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *totalp,int64_t *unspents,int32_t max,int64_t required,int32_t minconf,cJSON *addresses,char *remoteaddr) int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *totalp,struct iguana_outpoint *unspents,int32_t max,int64_t required,int32_t minconf,cJSON *addresses,char *remoteaddr)
{ {
int64_t sum = 0; int32_t k,i,j,r,numunspents,numaddrs; uint8_t pubkey[65]; char *coinaddr,str[65]; struct iguana_waddress *waddr; struct iguana_waccount *wacct; struct basilisk_unspent *bu; int64_t sum = 0; int32_t k,i,j,r,numunspents,numaddrs; uint8_t pubkey[65]; char *coinaddr,str[65]; struct iguana_waddress *waddr; struct iguana_waccount *wacct; struct basilisk_unspent *bu; struct iguana_outpoint outpt;
*totalp = 0; *totalp = 0;
if ( (numaddrs= cJSON_GetArraySize(addresses)) == 0 ) if ( (numaddrs= cJSON_GetArraySize(addresses)) == 0 )
{ {
@ -768,7 +818,7 @@ int32_t iguana_unspentslists(struct supernet_info *myinfo,struct iguana_info *co
//printf("i.%d coinaddr.(%s) minconf.%d longest.%d diff.%d\n",i,coinaddr,minconf,coin->longestchain,coin->blocks.hwmchain.height - minconf); //printf("i.%d coinaddr.(%s) minconf.%d longest.%d diff.%d\n",i,coinaddr,minconf,coin->longestchain,coin->blocks.hwmchain.height - minconf);
if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 ) if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 )
{ {
numunspents = iguana_addr_unspents(myinfo,coin,&sum,unspents,max,coinaddr,remoteaddr,coin->blocks.hwmchain.height - minconf); numunspents += iguana_RTaddr_unspents(myinfo,coin,&sum,&unspents[numunspents],max-numunspents,coinaddr,remoteaddr,coin->blocks.hwmchain.height - minconf);
} }
else else
{ {
@ -785,8 +835,12 @@ int32_t iguana_unspentslists(struct supernet_info *myinfo,struct iguana_info *co
{ {
// filterout duplicates here // filterout duplicates here
} }
unspents[0] = ((uint64_t)bu->hdrsi << 32) | bu->unspentind; memset(&outpt,0,sizeof(outpt));
unspents[1] = bu->value; outpt.hdrsi = bu->hdrsi;
outpt.isptr = 0;
outpt.unspentind = bu->unspentind;
outpt.value = bu->value;
*unspents = outpt;
sum += bu->value; sum += bu->value;
printf("ADD unspent, mark spent\n"); printf("ADD unspent, mark spent\n");
basilisk_addspend(myinfo,coin->symbol,bu->txid,bu->vout,1); basilisk_addspend(myinfo,coin->symbol,bu->txid,bu->vout,1);
@ -805,90 +859,69 @@ int32_t iguana_unspentslists(struct supernet_info *myinfo,struct iguana_info *co
return(numunspents); return(numunspents);
} }
int32_t iguana_uvaltxid(struct supernet_info *myinfo,bits256 *txidp,struct iguana_info *coin,int16_t hdrsi,uint32_t unspentind) int32_t iguana_RTuvaltxid(struct supernet_info *myinfo,bits256 *txidp,struct iguana_info *coin,struct iguana_outpoint outpt)
{ {
struct iguana_bundle *bp; struct iguana_unspent *U,*u; struct iguana_txid *T; struct iguana_ramchain *ramchain; struct iguana_ramchaindata *rdata; struct iguana_bundle *bp; struct iguana_unspent *U,*u; struct iguana_txid *T; struct iguana_ramchain *ramchain; struct iguana_ramchaindata *rdata; struct iguana_RTunspent *unspent; struct iguana_RTtxid *parent;
if ( (bp= coin->bundles[hdrsi]) == 0 ) if ( outpt.isptr != 0 && (unspent= outpt.ptr) != 0 && (parent= unspent->parent) != 0 )
{
*txidp = parent->txid;
return(unspent->vout);
}
if ( (bp= coin->bundles[outpt.hdrsi]) == 0 )
return(-1); return(-1);
ramchain = &bp->ramchain;//(bp == coin->current) ? &coin->RTramchain : &bp->ramchain; ramchain = &bp->ramchain;//(bp == coin->current) ? &coin->RTramchain : &bp->ramchain;
if ( (rdata= ramchain->H.data) != 0 ) if ( (rdata= ramchain->H.data) != 0 )
{ {
U = RAMCHAIN_PTR(rdata,Uoffset); U = RAMCHAIN_PTR(rdata,Uoffset);
T = RAMCHAIN_PTR(rdata,Toffset); T = RAMCHAIN_PTR(rdata,Toffset);
if ( unspentind > 0 && unspentind < rdata->numunspents ) if ( outpt.unspentind > 0 && outpt.unspentind < rdata->numunspents )
{ {
u = &U[unspentind]; u = &U[outpt.unspentind];
if ( u->txidind > 0 && u->txidind < rdata->numtxids ) if ( u->txidind > 0 && u->txidind < rdata->numtxids )
{ {
*txidp = T[u->txidind].txid; *txidp = T[u->txidind].txid;
return(unspentind - T[u->txidind].firstvout); return(outpt.unspentind - T[u->txidind].firstvout);
} }
} }
} }
return(-1); return(-1);
} }
int64_t iguana_unspentavail(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t hdrsi_unspentind,int32_t minconf,int32_t maxconf) int64_t iguana_unspentavail(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint outpt,int32_t minconf,int32_t maxconf)
{ {
struct iguana_ramchain *ramchain; struct iguana_bundle *bp; int64_t RTspend; int32_t hdrsi,spentheight,spentflag; struct iguana_unspent *U,*u; uint32_t unspentind; struct iguana_ramchaindata *rdata; struct iguana_ramchain *ramchain; struct iguana_bundle *bp; int64_t RTspend; int32_t spentheight,spentflag; struct iguana_unspent *U,*u; struct iguana_ramchaindata *rdata;
if ( (bp= coin->bundles[hdrsi_unspentind>>32]) == 0 ) if ( (bp= coin->bundles[outpt.hdrsi]) == 0 )
return(-1); return(-1);
hdrsi = (int16_t)(hdrsi_unspentind >> 32);
unspentind = (uint32_t)hdrsi_unspentind;
ramchain = &bp->ramchain;//(bp == coin->current) ? &coin->RTramchain : &bp->ramchain; ramchain = &bp->ramchain;//(bp == coin->current) ? &coin->RTramchain : &bp->ramchain;
if ( (rdata= ramchain->H.data) == 0 ) if ( (rdata= ramchain->H.data) == 0 )
return(0); return(0);
if ( (spentflag= iguana_spentflag(myinfo,coin,&RTspend,&spentheight,ramchain,hdrsi,unspentind,0,minconf,maxconf,0)) > 0 ) if ( (spentflag= iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,ramchain,outpt,0,minconf,maxconf,0)) > 0 )
{ {
printf("[%d].u%d was already spent ht.%d\n",bp->hdrsi,(uint32_t)unspentind,spentheight); printf("[%d].u%d was already spent ht.%d\n",outpt.hdrsi,outpt.unspentind,spentheight);
return(-1); return(-1);
} }
else if ( spentflag == 0 ) else if ( spentflag == 0 )
{ {
U = RAMCHAIN_PTR(rdata,Uoffset); U = RAMCHAIN_PTR(rdata,Uoffset);
if ( unspentind > 0 && unspentind < rdata->numunspents ) if ( outpt.unspentind > 0 && outpt.unspentind < rdata->numunspents )
{ {
u = &U[unspentind]; u = &U[outpt.unspentind];
return(u->value); return(u->value);
} }
else else
{ {
printf("illegal unspentind.%u vs %u [%d]\n",unspentind,rdata->numunspents,bp->hdrsi); printf("illegal unspentind.%u vs %u [%d]\n",outpt.unspentind,rdata->numunspents,bp->hdrsi);
return(-2); return(-2);
} }
} }
else return(0); else return(0);
} }
int32_t iguana_RTunspent_check(struct supernet_info *myinfo,struct iguana_info *coin,uint16_t hdrsi,uint32_t unspentind)
{
// check RT
return(iguana_unspent_check(myinfo,coin,hdrsi,unspentind));
}
int32_t iguana_RTuvaltxid(struct supernet_info *myinfo,bits256 *txidp,struct iguana_info *coin,int16_t hdrsi,uint32_t unspentind)
{
//check RT
return(iguana_uvaltxid(myinfo,txidp,coin,hdrsi,unspentind));
}
int32_t iguana_RTunspentindfind(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,uint8_t *spendscript,int32_t *spendlenp,uint64_t *valuep,int32_t *heightp,bits256 txid,int32_t vout,int32_t lasthdrsi,int32_t mempool)
{
// check RT
return(iguana_unspentindfind(myinfo,coin,coinaddr,spendscript,spendlenp,valuep,heightp,txid,vout,lasthdrsi,mempool));
}
int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *totalp,int64_t *unspents,int32_t max,int64_t required,int32_t minconf,cJSON *addresses,char *remoteaddr)
{
// check RTlists
return(iguana_unspentslists(myinfo,coin,totalp,unspents,max,required,minconf,addresses,remoteaddr));
}
cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *argarray,int32_t minconf,int32_t maxconf,char *remoteaddr) cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *argarray,int32_t minconf,int32_t maxconf,char *remoteaddr)
{ {
int32_t numrmds,numunspents=0; uint8_t *rmdarray; cJSON *retjson = cJSON_CreateArray(); int32_t numrmds,numunspents=0; uint8_t *rmdarray; cJSON *retjson = cJSON_CreateArray();
rmdarray = iguana_rmdarray(myinfo,coin,&numrmds,argarray,0); rmdarray = iguana_rmdarray(myinfo,coin,&numrmds,argarray,0);
iguana_unspents(myinfo,coin,retjson,minconf,maxconf,rmdarray,numrmds,(1 << 30),0,&numunspents,remoteaddr); iguana_RTunspents(myinfo,coin,retjson,minconf,maxconf,rmdarray,numrmds,(1 << 30),0,&numunspents,remoteaddr);
if ( rmdarray != 0 ) if ( rmdarray != 0 )
free(rmdarray); free(rmdarray);
/*{ /*{
@ -905,32 +938,6 @@ cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coi
return(retjson); return(retjson);
} }
int64_t RTgettxout(struct iguana_info *coin,int32_t *height,int32_t *scriptlen,uint8_t *script,uint8_t *rmd160,char *coinaddr,bits256 txid,int32_t vout,int32_t mempool)
{
int64_t value = 0;
// RT only
return(value);
}
int32_t iguana_RTunspentfind(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,uint8_t *spendscript,uint16_t hdrsi,uint32_t unspentind,int64_t value)
{
int32_t spendlen = 0;
// only RT
return(spendlen);
}
struct iguana_utxo iguana_RTutxofind(struct iguana_info *coin,int16_t spent_hdrsi,uint32_t spent_unspentind,int32_t *RTspendflagp,int32_t lockflag)
{
// check RT
return(iguana_RTutxofind(coin,spent_hdrsi,spent_unspentind,RTspendflagp,lockflag));
}
int32_t iguana_RTspentflag(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *RTspendp,int32_t *spentheightp,struct iguana_ramchain *ramchain,int16_t spent_hdrsi,uint32_t spent_unspentind,int32_t height,int32_t minconf,int32_t maxconf,uint64_t amount)
{
// check RT
return(iguana_spentflag(myinfo,coin,RTspendp,spentheightp,ramchain,spent_hdrsi,spent_unspentind,height,minconf,maxconf,amount));
}
#define UTXOADDR_ITEMSIZE 32 #define UTXOADDR_ITEMSIZE 32
#define iguana_utxotable_numinds(ind) (((ind) == 0xffff) ? coin->utxoaddrlastcount : (coin->utxoaddroffsets[(ind) + 1] - coin->utxoaddroffsets[ind])) #define iguana_utxotable_numinds(ind) (((ind) == 0xffff) ? coin->utxoaddrlastcount : (coin->utxoaddroffsets[(ind) + 1] - coin->utxoaddroffsets[ind]))
@ -959,7 +966,7 @@ int64_t iguana_utxoaddrtablefind(struct iguana_info *coin,int16_t search_hdrsi,u
struct iguana_utxoaddr UA; int32_t ind,num,i; uint8_t *ptr; struct iguana_utxoaddr UA; int32_t ind,num,i; uint8_t *ptr;
memset(&UA,0,sizeof(UA)); memset(&UA,0,sizeof(UA));
ind = rmd160[0] + ((uint32_t)rmd160[1] << 8); ind = rmd160[0] + ((uint32_t)rmd160[1] << 8);
if ( (num= iguana_utxotable_numinds(ind)) > 0 ) if ( coin->utxoaddroffsets != 0 && (num= iguana_utxotable_numinds(ind)) > 0 )
{ {
for (i=0; i<num; i++) for (i=0; i<num; i++)
{ {
@ -1163,7 +1170,7 @@ void iguana_utxoaddr_purge(struct iguana_info *coin)
coin->utxoaddrfilesize = 0; coin->utxoaddrfilesize = 0;
} }
int32_t iguana_utxoaddr_check(struct supernet_info *myinfo,struct iguana_info *coin,int32_t lastheight,int64_t *unspents,int32_t max,struct iguana_utxoaddr *utxoaddr) int32_t iguana_utxoaddr_check(struct supernet_info *myinfo,struct iguana_info *coin,int32_t lastheight,struct iguana_outpoint *unspents,int32_t max,struct iguana_utxoaddr *utxoaddr)
{ {
static int32_t good,bad; static int32_t good,bad;
char coinaddr[64]; int64_t sum,checkbalance; int32_t iter,i,numunspents = 0; char coinaddr[64]; int64_t sum,checkbalance; int32_t iter,i,numunspents = 0;
@ -1171,7 +1178,7 @@ int32_t iguana_utxoaddr_check(struct supernet_info *myinfo,struct iguana_info *c
for (iter=0; iter<2; iter++) for (iter=0; iter<2; iter++)
{ {
bitcoin_address(coinaddr,iter == 0 ? coin->chain->pubtype : coin->chain->p2shtype,utxoaddr->rmd160,sizeof(utxoaddr->rmd160)); bitcoin_address(coinaddr,iter == 0 ? coin->chain->pubtype : coin->chain->p2shtype,utxoaddr->rmd160,sizeof(utxoaddr->rmd160));
numunspents += iguana_addr_unspents(myinfo,coin,&sum,&unspents[numunspents],max-numunspents,coinaddr,0,lastheight); numunspents += iguana_RTaddr_unspents(myinfo,coin,&sum,&unspents[numunspents],max-numunspents,coinaddr,0,lastheight);
if ( sum == utxoaddr->histbalance ) if ( sum == utxoaddr->histbalance )
{ {
checkbalance = iguana_utxoaddrtablefind(coin,0,0,utxoaddr->rmd160); checkbalance = iguana_utxoaddrtablefind(coin,0,0,utxoaddr->rmd160);
@ -1184,7 +1191,7 @@ int32_t iguana_utxoaddr_check(struct supernet_info *myinfo,struct iguana_info *c
{ {
bad++; bad++;
for (i=0; i<numunspents; i++) for (i=0; i<numunspents; i++)
printf("(%lld %lld %.8f) ",(long long)(unspents[i<<1]>>32)&0xffffffff,(long long)unspents[i<<1]&0xffffffff,dstr(unspents[(i<<1)+1])); printf("(%d %u %.8f) ",unspents[i].hdrsi,unspents[i].unspentind,dstr(unspents[i].value));
for (i=0; i<20; i++) for (i=0; i<20; i++)
printf("%02x",utxoaddr->rmd160[i]); printf("%02x",utxoaddr->rmd160[i]);
bitcoin_address(coinaddr,coin->chain->pubtype,utxoaddr->rmd160,sizeof(utxoaddr->rmd160)); bitcoin_address(coinaddr,coin->chain->pubtype,utxoaddr->rmd160,sizeof(utxoaddr->rmd160));
@ -1199,7 +1206,7 @@ int32_t iguana_utxoaddr_check(struct supernet_info *myinfo,struct iguana_info *c
int32_t iguana_utxoaddr_validate(struct supernet_info *myinfo,struct iguana_info *coin,int32_t lastheight) int32_t iguana_utxoaddr_validate(struct supernet_info *myinfo,struct iguana_info *coin,int32_t lastheight)
{ {
int64_t *unspents; uint8_t *item; struct iguana_bundle *bp; struct iguana_utxoaddr UA; int32_t i,num,max,ind,total,errs=0; struct iguana_outpoint *unspents; uint8_t *item; struct iguana_bundle *bp; struct iguana_utxoaddr UA; int32_t i,num,max,ind,total,errs=0;
if ( coin->utxoaddrtable == 0 ) if ( coin->utxoaddrtable == 0 )
{ {
printf("no utxoaddrtable to validate?\n"); printf("no utxoaddrtable to validate?\n");
@ -1421,6 +1428,9 @@ void iguana_utxoaddrs_purge(struct iguana_info *coin)
HASH_ITER(hh,coin->utxoaddrs,utxoaddr,tmp) HASH_ITER(hh,coin->utxoaddrs,utxoaddr,tmp)
{ {
if ( utxoaddr != 0 ) if ( utxoaddr != 0 )
utxoaddr->RTcredits = utxoaddr->RTdebits = 0; {
utxoaddr->histbalance = 0;
// utxoaddr->RTcredits = utxoaddr->RTdebits = 0;
}
} }
} }

61
iguana/iguana_volatiles.c

@ -15,6 +15,7 @@
#include "iguana777.h" #include "iguana777.h"
#ifdef DEPRECATED_HHUTXO
struct iguana_hhutxo *iguana_hhutxofind(struct iguana_info *coin,uint64_t uval) struct iguana_hhutxo *iguana_hhutxofind(struct iguana_info *coin,uint64_t uval)
{ {
struct iguana_hhutxo *hhutxo; struct iguana_hhutxo *hhutxo;
@ -103,10 +104,11 @@ int32_t iguana_utxoupdate(struct iguana_info *coin,int16_t spent_hdrsi,uint32_t
}*/ }*/
return(0); return(0);
} }
#endif
struct iguana_utxo iguana_utxofind(struct iguana_info *coin,int16_t spent_hdrsi,uint32_t spent_unspentind,int32_t *RTspendflagp,int32_t lockflag) struct iguana_utxo iguana_RTutxofind(struct iguana_info *coin,struct iguana_outpoint spentpt,int32_t *RTspendflagp,int32_t lockflag)
{ {
uint64_t val; struct iguana_hhutxo *hhutxo; struct iguana_utxo utxo; struct iguana_ramchain *ramchain; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata; uint64_t val; struct iguana_utxo utxo; struct iguana_ramchain *ramchain; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata;
*RTspendflagp = 0; *RTspendflagp = 0;
memset(&utxo,0,sizeof(utxo)); memset(&utxo,0,sizeof(utxo));
if ( coin->disableUTXO != 0 ) if ( coin->disableUTXO != 0 )
@ -114,66 +116,55 @@ struct iguana_utxo iguana_utxofind(struct iguana_info *coin,int16_t spent_hdrsi,
printf("skip utxofind when disabled\n"); printf("skip utxofind when disabled\n");
return(utxo); return(utxo);
} }
if ( (bp= coin->bundles[spent_hdrsi]) == 0 ) if ( (bp= coin->bundles[spentpt.hdrsi]) == 0 )
return(utxo); return(utxo);
ramchain = &bp->ramchain;//(bp == coin->current) ? &coin->RTramchain : &bp->ramchain; ramchain = &bp->ramchain;//(bp == coin->current) ? &coin->RTramchain : &bp->ramchain;
if ( (rdata= ramchain->H.data) == 0 ) if ( (rdata= ramchain->H.data) == 0 )
return(utxo); return(utxo);
//flag = (coin->RTheight > 0); val = ((uint64_t)spentpt.hdrsi << 32) | spentpt.unspentind;
//if ( flag != 0 ) if ( spentpt.unspentind > 0 && spentpt.unspentind < rdata->numunspents )
// portable_mutex_lock(&coin->RTmutex);
val = ((uint64_t)spent_hdrsi << 32) | spent_unspentind;
if ( spent_unspentind > 0 && spent_unspentind < rdata->numunspents )
{ {
if ( ramchain->Uextras != 0 ) if ( ramchain->Uextras != 0 )
{ {
utxo = ramchain->Uextras[spent_unspentind]; utxo = ramchain->Uextras[spentpt.unspentind];
if ( lockflag != 0 ) if ( lockflag != 0 )
{ {
if ( (hhutxo= iguana_hhutxofind(coin,val)) == 0 ) /*if ( (hhutxo= iguana_hhutxofind(coin,val)) == 0 )
{ {
/*uval = ((uint64_t)spent_hdrsi << 32) | spent_unspentind;
if ( (hhutxo= iguana_hhutxofind(coin,uval)) != 0 && hhutxo->u.spentflag != 0 )
{
printf("iguana_hhutxofind warning: hhutxo.%p spentflag.%d\n",hhutxo,hhutxo->u.spentflag);
memset(&utxo,0,sizeof(utxo));
//if ( flag != 0 )
// portable_mutex_unlock(&coin->RTmutex);
return(utxo);
}*/
hhutxo = calloc(1,sizeof(*hhutxo)); hhutxo = calloc(1,sizeof(*hhutxo));
hhutxo->uval = val; hhutxo->uval = val;
HASH_ADD_KEYPTR(hh,coin->utxotable,&hhutxo->uval,sizeof(hhutxo->uval),hhutxo); HASH_ADD_KEYPTR(hh,coin->utxotable,&hhutxo->uval,sizeof(hhutxo->uval),hhutxo);
} }*/
printf("iguana_utxofind: need to change to new RT lock method\n");
} }
} }
if ( ramchain->Uextras == 0 || utxo.spentflag == 0 ) if ( ramchain->Uextras == 0 || utxo.spentflag == 0 )
{ {
//printf("check hhutxo [%d] u%u %p\n",spent_hdrsi,spent_unspentind,iguana_hhutxofind(coin,((uint64_t)202<<32)|3909240)); /*if ( (hhutxo= iguana_hhutxofind(coin,val)) != 0 )
if ( (hhutxo= iguana_hhutxofind(coin,val)) != 0 )
{ {
if ( lockflag != 0 ) if ( lockflag != 0 )
{ {
if ( hhutxo->u.lockedflag == 0 ) if ( hhutxo->u.lockedflag == 0 )
hhutxo->u.lockedflag = 1; hhutxo->u.lockedflag = 1;
else printf("iguana_hhutxofind warning: locking already locked [%d].%u\n",spent_hdrsi,spent_unspentind); else printf("iguana_hhutxofind warning: locking already locked [%d].%u\n",spentpt.hdrsi,spentpt.unspentind);
} else hhutxo->u.lockedflag = 0; } else hhutxo->u.lockedflag = 0;
utxo = hhutxo->u; utxo = hhutxo->u;
if ( utxo.spentflag != 0 || utxo.lockedflag != 0 ) if ( utxo.spentflag != 0 || utxo.lockedflag != 0 )
*RTspendflagp = 1; *RTspendflagp = 1;
} }*/
printf("iguana_utxofind: need to change to new RT method\n");
} }
} }
else else
{ {
printf("illegal unspentind.%u vs %u hdrs.%d\n",spent_unspentind,rdata->numunspents,spent_hdrsi); printf("illegal unspentind.%u vs %u hdrs.%d\n",spentpt.unspentind,rdata->numunspents,spentpt.hdrsi);
} }
//if ( flag != 0 ) //if ( flag != 0 )
// portable_mutex_unlock(&coin->RTmutex); // portable_mutex_unlock(&coin->RTmutex);
return(utxo); return(utxo);
} }
int32_t iguana_spentflag(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *RTspendp,int32_t *spentheightp,struct iguana_ramchain *ramchain,int16_t spent_hdrsi,uint32_t spent_unspentind,int32_t height,int32_t minconf,int32_t maxconf,uint64_t amount) int32_t iguana_RTspentflag(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *RTspendp,int32_t *spentheightp,struct iguana_ramchain *ramchain,struct iguana_outpoint spentpt,int32_t height,int32_t minconf,int32_t maxconf,uint64_t amount)
{ {
uint32_t numunspents; int32_t RTspentflag; struct iguana_utxo utxo; uint64_t confs,RTspend = 0; uint32_t numunspents; int32_t RTspentflag; struct iguana_utxo utxo; uint64_t confs,RTspend = 0;
struct iguana_ramchaindata *rdata; struct iguana_ramchaindata *rdata;
@ -186,12 +177,12 @@ int32_t iguana_spentflag(struct supernet_info *myinfo,struct iguana_info *coin,i
if ( (rdata= ramchain->H.data) == 0 ) if ( (rdata= ramchain->H.data) == 0 )
return(0); return(0);
numunspents = rdata->numunspents; numunspents = rdata->numunspents;
utxo = iguana_utxofind(coin,spent_hdrsi,spent_unspentind,&RTspentflag,0); utxo = iguana_RTutxofind(coin,spentpt,&RTspentflag,0);
if ( RTspentflag != 0 ) if ( RTspentflag != 0 )
*RTspendp = (amount == 0) ? coin->txfee : amount; *RTspendp = (amount == 0) ? coin->txfee : amount;
if ( utxo.spentflag != 0 && utxo.fromheight == 0 ) if ( utxo.spentflag != 0 && utxo.fromheight == 0 )
{ {
printf("illegal unspentind.%u vs %u hdrs.%d zero fromheight?\n",spent_unspentind,numunspents,spent_hdrsi); printf("illegal unspentind.%u vs %u hdrs.%d zero fromheight?\n",spentpt.unspentind,numunspents,spentpt.hdrsi);
return(-1); return(-1);
} }
//printf("[%d] u%u %.8f, spentheight.%d vs height.%d spentflag.%d\n",spent_hdrsi,spent_unspentind,dstr(amount),utxo.fromheight,height,utxo.spentflag); //printf("[%d] u%u %.8f, spentheight.%d vs height.%d spentflag.%d\n",spent_hdrsi,spent_unspentind,dstr(amount),utxo.fromheight,height,utxo.spentflag);
@ -210,7 +201,7 @@ int32_t iguana_spentflag(struct supernet_info *myinfo,struct iguana_info *coin,i
int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struct iguana_ramchain *spentchain,int16_t spent_hdrsi,uint32_t spent_unspentind,uint32_t spent_pkind,uint64_t spent_value,uint32_t spendind,uint32_t fromheight) int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struct iguana_ramchain *spentchain,int16_t spent_hdrsi,uint32_t spent_unspentind,uint32_t spent_pkind,uint64_t spent_value,uint32_t spendind,uint32_t fromheight)
{ {
struct iguana_account *A2; struct iguana_unspent *spentU; struct iguana_pkhash *spentP; struct iguana_ramchaindata *rdata; struct iguana_utxo *utxo; struct iguana_ramchaindata *rdata; struct iguana_utxo *utxo; struct iguana_account *A2; // struct iguana_unspent *spentU; struct iguana_pkhash *spentP;
if ( coin->disableUTXO != 0 ) if ( coin->disableUTXO != 0 )
{ {
printf("skip volatileupdate when disabled\n"); printf("skip volatileupdate when disabled\n");
@ -254,16 +245,18 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc
else // do the equivalent of historical, ie mark as spent, linked list, balance else // do the equivalent of historical, ie mark as spent, linked list, balance
{ {
//double startmillis = OS_milliseconds(); static double totalmillis; static int32_t utxon; //double startmillis = OS_milliseconds(); static double totalmillis; static int32_t utxon;
spentP = RAMCHAIN_PTR(rdata,Poffset); printf("hhutxo deprecated\n");
exit(-1);
/*spentP = RAMCHAIN_PTR(rdata,Poffset);
spentU = RAMCHAIN_PTR(rdata,Uoffset); spentU = RAMCHAIN_PTR(rdata,Uoffset);
if ( iguana_utxoupdate(coin,spent_hdrsi,spent_unspentind,spent_pkind,spent_value,spendind,fromheight,spentP[spent_pkind].rmd160) == 0 ) if ( iguana_utxoupdate(coin,spent_hdrsi,spent_unspentind,spent_pkind,spent_value,spendind,fromheight,spentP[spent_pkind].rmd160) == 0 )
{ {
/*totalmillis += (OS_milliseconds() - startmillis); //totalmillis += (OS_milliseconds() - startmillis);
if ( (++utxon % 100000) == 0 ) // if ( (++utxon % 100000) == 0 )
printf("ave utxo[%d] %.2f micros total %.2f seconds\n",utxon,(1000. * totalmillis)/utxon,totalmillis/1000.);*/ // printf("ave utxo[%d] %.2f micros total %.2f seconds\n",utxon,(1000. * totalmillis)/utxon,totalmillis/1000.);
//portable_mutex_unlock(&coin->RTmutex); //portable_mutex_unlock(&coin->RTmutex);
return(0); return(0);
} }*/
} }
//portable_mutex_unlock(&coin->RTmutex); //portable_mutex_unlock(&coin->RTmutex);
printf("end iguana_volatileupdate.%d: [%d] spent.(u%u %.8f pkind.%d) double spend? at ht.%d [%d] spendind.%d (%p %p)\n",incremental,spent_hdrsi,spent_unspentind,dstr(spent_value),spent_pkind,fromheight,fromheight/coin->chain->bundlesize,spendind,spentchain->Uextras,spentchain->A2); printf("end iguana_volatileupdate.%d: [%d] spent.(u%u %.8f pkind.%d) double spend? at ht.%d [%d] spendind.%d (%p %p)\n",incremental,spent_hdrsi,spent_unspentind,dstr(spent_value),spent_pkind,fromheight,fromheight/coin->chain->bundlesize,spendind,spentchain->Uextras,spentchain->A2);

10
iguana/iguana_wallet.c

@ -884,7 +884,7 @@ int64_t iguana_waccountbalance(struct supernet_info *myinfo,struct iguana_info *
if ( minconf == 0 ) if ( minconf == 0 )
minconf = 1; minconf = 1;
rmdarray = iguana_rmdarray(myinfo,coin,&numrmds,iguana_getaddressesbyaccount(myinfo,coin,wacct->account),0); rmdarray = iguana_rmdarray(myinfo,coin,&numrmds,iguana_getaddressesbyaccount(myinfo,coin,wacct->account),0);
balance = iguana_unspents(myinfo,coin,0,minconf,(1 << 30),rmdarray,numrmds,lastheight,0,&numunspents,0); balance = iguana_RTunspents(myinfo,coin,0,minconf,(1 << 30),rmdarray,numrmds,lastheight,0,&numunspents,0);
if ( rmdarray != 0 ) if ( rmdarray != 0 )
free(rmdarray); free(rmdarray);
return(balance); return(balance);
@ -908,13 +908,13 @@ int64_t oldiguana_waccountbalance(struct supernet_info *myinfo,struct iguana_inf
cJSON *iguana_privkeysjson(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins) cJSON *iguana_privkeysjson(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins)
{ {
int32_t i,j,n,numinputs; uint32_t spent_unspentind; int16_t spent_hdrsi; struct iguana_waddress *waddr; struct iguana_waccount *wacct; char *addresses,*address,coinaddr[64]; cJSON *privkeys = cJSON_CreateArray(); int32_t i,j,n,numinputs; struct iguana_waddress *waddr; struct iguana_outpoint spentpt; struct iguana_waccount *wacct; char *addresses,*address,coinaddr[64]; cJSON *privkeys = cJSON_CreateArray();
if ( (numinputs= cJSON_GetArraySize(vins)) > 0 ) if ( (numinputs= cJSON_GetArraySize(vins)) > 0 )
{ {
addresses = calloc(numinputs,64); addresses = calloc(numinputs,64);
for (i=n=0; i<numinputs; i++) for (i=n=0; i<numinputs; i++)
{ {
if ( (address= iguana_RTinputaddress(myinfo,coin,coinaddr,&spent_hdrsi,&spent_unspentind,jitem(vins,i))) != 0 ) if ( (address= iguana_RTinputaddress(myinfo,coin,coinaddr,&spentpt,jitem(vins,i))) != 0 )
{ {
for (j=0; j<n; j++) for (j=0; j<n; j++)
{ {
@ -943,7 +943,7 @@ int64_t iguana_addressreceived(struct supernet_info *myinfo,struct iguana_info *
int64_t balance = 0; cJSON *unspentsjson,*balancejson,*item; int32_t i,n; char *balancestr; int64_t balance = 0; cJSON *unspentsjson,*balancejson,*item; int32_t i,n; char *balancestr;
if ( (balancestr= iguana_balance(IGUANA_CALLARGS,coin->symbol,coinaddr,-1,minconf)) != 0 ) if ( (balancestr= iguana_balance(IGUANA_CALLARGS,coin->symbol,coinaddr,-1,minconf)) != 0 )
{ {
//printf("balancestr.(%s) (%s)\n",balancestr,coinaddr); printf("balancestr.(%s) (%s)\n",balancestr,coinaddr);
if ( (balancejson= cJSON_Parse(balancestr)) != 0 ) if ( (balancejson= cJSON_Parse(balancestr)) != 0 )
{ {
balance = jdouble(balancejson,"balance") * SATOSHIDEN; balance = jdouble(balancejson,"balance") * SATOSHIDEN;
@ -1436,7 +1436,7 @@ STRING_AND_THREEINTS(bitcoinrpc,getbalance,account,minconf,includeempty,lastheig
//if ( strcmp(account,"*") != 0 ) //if ( strcmp(account,"*") != 0 )
rmdarray = iguana_rmdarray(myinfo,coin,&numrmds,iguana_getaddressesbyaccount(myinfo,coin,account),0); rmdarray = iguana_rmdarray(myinfo,coin,&numrmds,iguana_getaddressesbyaccount(myinfo,coin,account),0);
numunspents = 0; numunspents = 0;
balance = iguana_unspents(myinfo,coin,0,minconf,(1 << 30),rmdarray,numrmds,lastheight,0,&numunspents,remoteaddr); balance = iguana_RTunspents(myinfo,coin,0,minconf,(1 << 30),rmdarray,numrmds,lastheight,0,&numunspents,remoteaddr);
if ( rmdarray != 0 ) if ( rmdarray != 0 )
free(rmdarray); free(rmdarray);
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();

2
iguana/main.c

@ -551,7 +551,7 @@ void iguana_appletests(struct supernet_info *myinfo)
bitcoin_sharedsecret(myinfo->ctx,hash2,pubkey,33); bitcoin_sharedsecret(myinfo->ctx,hash2,pubkey,33);
printf("secp256k1 elapsed %.3f for %d iterations\n",OS_milliseconds() - startmillis,i); printf("secp256k1 elapsed %.3f for %d iterations\n",OS_milliseconds() - startmillis,i);
getchar();**/ getchar();**/
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"protover\":70002,\"RELAY\":1,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"protover\":70002,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 )
{ {
free(str); free(str);
if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"portp2p\":8333,\"RELAY\":0,\"VALIDATE\":0,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":8,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"portp2p\":8333,\"RELAY\":0,\"VALIDATE\":0,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":8,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 )

12
iguana/ramchain_api.c

@ -27,9 +27,7 @@ STRING_ARG(iguana,initfastfind,activecoin)
TWO_STRINGS_AND_TWO_DOUBLES(iguana,balance,activecoin,address,lastheightd,minconfd) TWO_STRINGS_AND_TWO_DOUBLES(iguana,balance,activecoin,address,lastheightd,minconfd)
{ {
//int32_t lastheight,minconf,maxconf=SATOSHIDEN; int64_t total=0; uint8_t rmd160[20],pubkey33[33],addrtype; int32_t lastheight,minconf,maxconf=SATOSHIDEN; int64_t total=0; uint8_t rmd160[20],pubkey33[33],addrtype; struct iguana_pkhash *P; cJSON *array,*retjson = cJSON_CreateObject();
//struct iguana_pkhash *P;
int32_t minconf,lastheight; cJSON *retjson = cJSON_CreateObject();
if ( activecoin != 0 && activecoin[0] != 0 ) if ( activecoin != 0 && activecoin[0] != 0 )
coin = iguana_coinfind(activecoin); coin = iguana_coinfind(activecoin);
if ( coin != 0 ) if ( coin != 0 )
@ -43,8 +41,8 @@ TWO_STRINGS_AND_TWO_DOUBLES(iguana,balance,activecoin,address,lastheightd,mincon
jaddstr(retjson,"error","illegal address"); jaddstr(retjson,"error","illegal address");
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
jaddnum(retjson,"balance",iguana_RTbalance(coin,address)); jadd64bits(retjson,"RTbalance",iguana_RTbalance(coin,address));
/*if ( bitcoin_addr2rmd160(&addrtype,rmd160,address) < 0 ) if ( bitcoin_addr2rmd160(&addrtype,rmd160,address) < 0 )
{ {
jaddstr(retjson,"error","cant convert address"); jaddstr(retjson,"error","cant convert address");
return(jprint(retjson,1)); return(jprint(retjson,1));
@ -55,10 +53,10 @@ TWO_STRINGS_AND_TWO_DOUBLES(iguana,balance,activecoin,address,lastheightd,mincon
//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 ) if ( lastheight == 0 )
lastheight = IGUANA_MAXHEIGHT; lastheight = IGUANA_MAXHEIGHT;
iguana_pkhasharray(myinfo,coin,array,minconf,maxconf,&total,P,coin->bundlescount,rmd160,address,pubkey33,lastheight,0,0,0,remoteaddr); iguana_RTpkhasharray(myinfo,coin,array,minconf,maxconf,&total,P,coin->bundlescount,rmd160,address,pubkey33,lastheight,0,0,0,remoteaddr);
free(P); free(P);
jadd(retjson,"unspents",array); jadd(retjson,"unspents",array);
jaddnum(retjson,"balance",dstr(total));*/ jaddnum(retjson,"balance",dstr(total));
if ( lastheight > 0 ) if ( lastheight > 0 )
jaddnum(retjson,"RTheight",coin->RTheight); jaddnum(retjson,"RTheight",coin->RTheight);
} }

36
includes/iguana_funcs.h

@ -316,10 +316,10 @@ int32_t bitcoin_addr2rmd160(uint8_t *addrtypep,uint8_t rmd160[20],char *coinaddr
char *issue_startForging(struct supernet_info *myinfo,char *secret); char *issue_startForging(struct supernet_info *myinfo,char *secret);
struct bitcoin_unspent *iguana_unspentsget(struct supernet_info *myinfo,struct iguana_info *coin,char **retstrp,double *balancep,int32_t *numunspentsp,double minconfirms,char *address); struct bitcoin_unspent *iguana_unspentsget(struct supernet_info *myinfo,struct iguana_info *coin,char **retstrp,double *balancep,int32_t *numunspentsp,double minconfirms,char *address);
void iguana_chainparms(struct iguana_chain *chain,cJSON *argjson); void iguana_chainparms(struct iguana_chain *chain,cJSON *argjson);
int32_t iguana_pkhasharray(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,int64_t *totalp,struct iguana_pkhash *P,int32_t max,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t lastheight,int64_t *unspents,int32_t *numunspentsp,int32_t maxunspents,char *remoteaddr); int32_t iguana_RTpkhasharray(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,int64_t *totalp,struct iguana_pkhash *P,int32_t max,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t lastheight,struct iguana_outpoint *unspents,int32_t *numunspentsp,int32_t maxunspents,char *remoteaddr);
long iguana_spentsfile(struct iguana_info *coin,int32_t n); long iguana_spentsfile(struct iguana_info *coin,int32_t n);
uint8_t *iguana_rmdarray(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *numrmdsp,cJSON *array,int32_t firsti); uint8_t *iguana_rmdarray(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *numrmdsp,cJSON *array,int32_t firsti);
int64_t iguana_unspents(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,uint8_t *rmdarray,int32_t numrmds,int32_t lastheight,int64_t *unspents,int32_t *numunspentsp,char *remoteaddr); int64_t iguana_RTunspents(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,uint8_t *rmdarray,int32_t numrmds,int32_t lastheight,struct iguana_outpoint *unspents,int32_t *numunspentsp,char *remoteaddr);
uint8_t *iguana_walletrmds(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *numrmdsp); uint8_t *iguana_walletrmds(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *numrmdsp);
char *iguana_bundleaddrs(struct iguana_info *coin,int32_t hdrsi); char *iguana_bundleaddrs(struct iguana_info *coin,int32_t hdrsi);
uint32_t iguana_sparseaddpk(uint8_t *bits,int32_t width,uint32_t tablesize,uint8_t rmd160[20],struct iguana_pkhash *P,uint32_t pkind,struct iguana_ramchain *ramchain); uint32_t iguana_sparseaddpk(uint8_t *bits,int32_t width,uint32_t tablesize,uint8_t rmd160[20],struct iguana_pkhash *P,uint32_t pkind,struct iguana_ramchain *ramchain);
@ -411,19 +411,21 @@ int32_t iguana_unspentindfind(struct supernet_info *myinfo,struct iguana_info *c
int32_t iguana_RTunspentindfind(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,uint8_t *spendscript,int32_t *scriptlenp,uint64_t *valuep,int32_t *heightp,bits256 txid,int32_t vout,int32_t lasthdrsi,int32_t mempool); int32_t iguana_RTunspentindfind(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,uint8_t *spendscript,int32_t *scriptlenp,uint64_t *valuep,int32_t *heightp,bits256 txid,int32_t vout,int32_t lasthdrsi,int32_t mempool);
int32_t iguana_addressvalidate(struct iguana_info *coin,uint8_t *addrtypep,char *address); int32_t iguana_addressvalidate(struct iguana_info *coin,uint8_t *addrtypep,char *address);
int32_t bitcoin_sign(void *ctx,char *symbol,uint8_t *sig,bits256 txhash2,bits256 privkey,int32_t recoverflag); int32_t bitcoin_sign(void *ctx,char *symbol,uint8_t *sig,bits256 txhash2,bits256 privkey,int32_t recoverflag);
struct iguana_utxo iguana_utxofind(struct iguana_info *coin,struct iguana_outpoint spentpt,int32_t *RTspendflagp,int32_t lockflag);
bits256 iguana_str2priv(struct supernet_info *myinfo,struct iguana_info *coin,char *str); bits256 iguana_str2priv(struct supernet_info *myinfo,struct iguana_info *coin,char *str);
int32_t iguana_spentflag(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *RTspendp,int32_t *spentheightp,struct iguana_ramchain *ramchain,int16_t spent_hdrsi,uint32_t spent_unspentind,int32_t height,int32_t minconf,int32_t maxconf,uint64_t amount); int32_t iguana_RTspentflag(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *RTspendp,int32_t *spentheightp,struct iguana_ramchain *ramchain,struct iguana_outpoint spentpt,int32_t height,int32_t minconf,int32_t maxconf,uint64_t amount);
int32_t iguana_RTspentflag(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *RTspendp,int32_t *spentheightp,struct iguana_ramchain *ramchain,int16_t spent_hdrsi,uint32_t spent_unspentind,int32_t height,int32_t minconf,int32_t maxconf,uint64_t amount); int32_t iguana_RTspentflag(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *RTspendp,int32_t *spentheightp,struct iguana_ramchain *ramchain,struct iguana_outpoint spentpt,int32_t height,int32_t minconf,int32_t maxconf,uint64_t amount);
int32_t iguana_voutscript(struct iguana_info *coin,struct iguana_bundle *bp,uint8_t *scriptspace,char *asmstr,struct iguana_unspent *u,struct iguana_pkhash *p,int32_t txi); int32_t iguana_voutscript(struct iguana_info *coin,struct iguana_bundle *bp,uint8_t *scriptspace,char *asmstr,struct iguana_unspent *u,struct iguana_pkhash *p,int32_t txi);
cJSON *iguana_unspentjson(struct supernet_info *myinfo,struct iguana_info *coin,int32_t hdrsi,uint32_t unspentind,struct iguana_txid *T,struct iguana_unspent *up,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t spentheight,char *remoteaddr); struct iguana_RTaddr *iguana_RTaddrfind(struct iguana_info *coin,uint8_t *rmd160,char *coinaddr);
cJSON *iguana_RTunspentjson(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint outpt,bits256 txid,int32_t vout,int64_t value,struct iguana_unspent *up,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t spentheight,char *remoteaddr);
int32_t bitcoin_standardspend(uint8_t *script,int32_t n,uint8_t rmd160[20]); int32_t bitcoin_standardspend(uint8_t *script,int32_t n,uint8_t rmd160[20]);
struct iguana_waddress *iguana_waddresssearch(struct supernet_info *myinfo,struct iguana_waccount **wacctp,char *coinaddr); struct iguana_waddress *iguana_waddresssearch(struct supernet_info *myinfo,struct iguana_waccount **wacctp,char *coinaddr);
cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *argarray,int32_t minconf,int32_t maxconf,char *remoteaddr); cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *argarray,int32_t minconf,int32_t maxconf,char *remoteaddr);
void calc_shares(struct supernet_info *myinfo,uint8_t *shares,uint8_t *secret,int32_t size,int32_t width,int32_t M,int32_t N,uint8_t *sharenrs,uint8_t *space,int32_t spacesize); void calc_shares(struct supernet_info *myinfo,uint8_t *shares,uint8_t *secret,int32_t size,int32_t width,int32_t M,int32_t N,uint8_t *sharenrs,uint8_t *space,int32_t spacesize);
struct basilisk_spend *basilisk_addspend(struct supernet_info *myinfo,char *symbol,bits256 txid,uint16_t vout,int32_t addflag); struct basilisk_spend *basilisk_addspend(struct supernet_info *myinfo,char *symbol,bits256 txid,uint16_t vout,int32_t addflag);
int64_t RTgettxout(struct iguana_info *coin,int32_t *height,int32_t *scriptlen,uint8_t *script,uint8_t *rmd160,char *coinaddr,bits256 txid,int32_t vout,int32_t mempool); int64_t _RTgettxout(struct iguana_info *coin,int32_t *height,int32_t *scriptlen,uint8_t *script,uint8_t *rmd160,char *coinaddr,bits256 txid,int32_t vout,int32_t mempool);
int32_t iguana_RTunspentfind(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,uint8_t *spendscript,uint16_t hdrsi,uint32_t unspentind,int64_t value); int32_t _iguana_RTunspentfind(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,uint8_t *spendscript,struct iguana_outpoint outpt,int64_t value);
int32_t basilisk_unspentfind(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,uint8_t *spendscript,int16_t hdrsi,uint32_t unspentind,int64_t value); int32_t basilisk_unspentfind(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,uint8_t *spendscript,struct iguana_outpoint outpt,int64_t value);
int64_t iguana_addressreceived(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *json,char *remoteaddr,cJSON *txids,cJSON *vouts,cJSON *unspents,cJSON *spends,char *coinaddr,int32_t minconf,int32_t firstheight); int64_t iguana_addressreceived(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *json,char *remoteaddr,cJSON *txids,cJSON *vouts,cJSON *unspents,cJSON *spends,char *coinaddr,int32_t minconf,int32_t firstheight);
cJSON *iguana_walletjson(struct supernet_info *myinfo); 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 iguana_payloadupdate(struct supernet_info *myinfo,struct iguana_info *coin,char *retstr,struct iguana_waddress *waddr,char *account);
@ -440,7 +442,7 @@ int32_t bitcoin_validaddress(struct iguana_info *coin,char *coinaddr);
int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struct iguana_ramchain *spentchain,int16_t spent_hdrsi,uint32_t spent_unspentind,uint32_t spent_pkind,uint64_t spent_value,uint32_t spendind,uint32_t fromheight); int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struct iguana_ramchain *spentchain,int16_t spent_hdrsi,uint32_t spent_unspentind,uint32_t spent_pkind,uint64_t spent_value,uint32_t spendind,uint32_t fromheight);
void iguana_utxoaddrs_purge(struct iguana_info *coin); void iguana_utxoaddrs_purge(struct iguana_info *coin);
int32_t iguana_utxoupdate(struct iguana_info *coin,int16_t spent_hdrsi,uint32_t spent_unspentind,uint32_t spent_pkind,uint64_t spent_value,uint32_t spendind,uint32_t fromheight,uint8_t *rmd160); int32_t iguana_utxoupdate(struct iguana_info *coin,int16_t spent_hdrsi,uint32_t spent_unspentind,uint32_t spent_pkind,uint64_t spent_value,uint32_t spendind,uint32_t fromheight,uint8_t *rmd160);
int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *totalp,int64_t *unspents,int32_t max,int64_t required,int32_t minconf,cJSON *addresses,char *remoteaddr); int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *totalp,struct iguana_outpoint *unspents,int32_t max,int64_t required,int32_t minconf,cJSON *addresses,char *remoteaddr);
int64_t iguana_unspentset(struct supernet_info *myinfo,struct iguana_info *coin); int64_t iguana_unspentset(struct supernet_info *myinfo,struct iguana_info *coin);
int32_t iguana_txidfastfind(struct iguana_info *coin,int32_t *heightp,bits256 txid,int32_t lasthdrsi); int32_t iguana_txidfastfind(struct iguana_info *coin,int32_t *heightp,bits256 txid,int32_t lasthdrsi);
uint8_t iguana_addrtype(struct iguana_info *coin,uint8_t script_type); uint8_t iguana_addrtype(struct iguana_info *coin,uint8_t script_type);
@ -451,13 +453,13 @@ bits256 bitcoin_randkey(void *ctx);
int32_t bitcoin_recoververify(void *ctx,char *symbol,uint8_t *sig64,bits256 messagehash2,uint8_t *pubkey); int32_t bitcoin_recoververify(void *ctx,char *symbol,uint8_t *sig64,bits256 messagehash2,uint8_t *pubkey);
int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t script[IGUANA_MAXSCRIPTSIZE],cJSON *scriptobj,int32_t interpret,int64_t nLockTime,struct vin_info *V); int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t script[IGUANA_MAXSCRIPTSIZE],cJSON *scriptobj,int32_t interpret,int64_t nLockTime,struct vin_info *V);
cJSON *iguana_spendasm(struct iguana_info *coin,uint8_t *spendscript,int32_t spendlen); cJSON *iguana_spendasm(struct iguana_info *coin,uint8_t *spendscript,int32_t spendlen);
int64_t iguana_unspentavail(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t hdrsi_unspendind,int32_t minconf,int32_t maxconf); int64_t iguana_unspentavail(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint outpt,int32_t minconf,int32_t maxconf);
struct iguana_utxo iguana_RTutxofind(struct iguana_info *coin,int16_t spent_hdrsi,uint32_t spent_unspentind,int32_t *RTspendflagp,int32_t lockflag); struct iguana_utxo iguana_RTutxofind(struct iguana_info *coin,struct iguana_outpoint spentpt,int32_t *RTspendflagp,int32_t lockflag);
int32_t iguana_signrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,int32_t height,struct iguana_msgtx *msgtx,char **signedtxp,bits256 *signedtxidp,struct vin_info *V,int32_t numinputs,char *rawtx,cJSON *vins,cJSON *privkeys); int32_t iguana_signrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,int32_t height,struct iguana_msgtx *msgtx,char **signedtxp,bits256 *signedtxidp,struct vin_info *V,int32_t numinputs,char *rawtx,cJSON *vins,cJSON *privkeys);
cJSON *iguana_privkeysjson(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins); cJSON *iguana_privkeysjson(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins);
char *iguana_RTinputaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int16_t *spent_hdrsip,uint32_t *unspentindp,cJSON *vinobj); char *iguana_RTinputaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,struct iguana_outpoint *spentptp,cJSON *vinobj);
struct iguana_waddress *iguana_getaccountaddress(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *json,char *remoteaddr,char *coinaddr,char *account); struct iguana_waddress *iguana_getaccountaddress(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *json,char *remoteaddr,char *coinaddr,char *account);
int32_t iguana_RTuvaltxid(struct supernet_info *myinfo,bits256 *txidp,struct iguana_info *coin,int16_t hdrsi,uint32_t unspentind); int32_t iguana_RTuvaltxid(struct supernet_info *myinfo,bits256 *txidp,struct iguana_info *coin,struct iguana_outpoint outpt);
struct instantdex_accept *instantdex_quotefind(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,bits256 encodedhash); struct instantdex_accept *instantdex_quotefind(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,bits256 encodedhash);
int32_t instantdex_quoterequest(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t *serialized,int32_t maxlen,struct iguana_peer *addr,bits256 encodedhash); int32_t instantdex_quoterequest(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t *serialized,int32_t maxlen,struct iguana_peer *addr,bits256 encodedhash);
int32_t instantdex_peerhas_clear(struct iguana_info *coin,struct iguana_peer *addr); int32_t instantdex_peerhas_clear(struct iguana_info *coin,struct iguana_peer *addr);
@ -467,7 +469,7 @@ cJSON *iguana_getaddressesbyaccount(struct supernet_info *myinfo,struct iguana_i
int32_t iguana_interpreter(struct iguana_info *coin,cJSON *logarray,int64_t nLockTime,struct vin_info *V,int32_t numvins); int32_t iguana_interpreter(struct iguana_info *coin,cJSON *logarray,int64_t nLockTime,struct vin_info *V,int32_t numvins);
int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t *serialized,int32_t maxsize,struct iguana_msgvin *vin,cJSON *vinobj,struct vin_info *V); int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t *serialized,int32_t maxsize,struct iguana_msgvin *vin,cJSON *vinobj,struct vin_info *V);
//int64_t iguana_availunspents(struct supernet_info *myinfo,uint64_t **unspentsp,int32_t *nump,struct iguana_info *coin,int32_t minconf,char *account,void *ptr,int32_t maxsize); //int64_t iguana_availunspents(struct supernet_info *myinfo,uint64_t **unspentsp,int32_t *nump,struct iguana_info *coin,int32_t minconf,char *account,void *ptr,int32_t maxsize);
char *iguana_signunspents(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *signedtxidp,int32_t *completedp,cJSON *txobj,uint64_t satoshis,char *changeaddr,uint64_t txfee,uint64_t *unspents,int32_t num); char *iguana_signunspents(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *signedtxidp,int32_t *completedp,cJSON *txobj,uint64_t satoshis,char *changeaddr,uint64_t txfee,struct iguana_outpoint *unspents,int32_t num);
bits256 iguana_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx); bits256 iguana_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx);
int32_t iguana_inv2packet(uint8_t *serialized,int32_t maxsize,int32_t type,bits256 *hashes,int32_t n); int32_t iguana_inv2packet(uint8_t *serialized,int32_t maxsize,int32_t type,bits256 *hashes,int32_t n);
int32_t instantdex_inv2data(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,struct exchange_info *exchange); int32_t instantdex_inv2data(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,struct exchange_info *exchange);
@ -482,8 +484,8 @@ char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJS
int64_t datachain_update(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *coin,uint32_t timestamp,struct iguana_bundle *bp,uint8_t rmd160[20],int64_t crypto777_payment,uint8_t type,int32_t height,uint64_t hdrsi_unspentind,int64_t burned,uint32_t fileid,uint64_t scriptpos,int32_t scriptlen,bits256 txid,int32_t vout); int64_t datachain_update(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *coin,uint32_t timestamp,struct iguana_bundle *bp,uint8_t rmd160[20],int64_t crypto777_payment,uint8_t type,int32_t height,uint64_t hdrsi_unspentind,int64_t burned,uint32_t fileid,uint64_t scriptpos,int32_t scriptlen,bits256 txid,int32_t vout);
void datachain_update_spend(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *coin,uint32_t timestamp,struct iguana_bundle *bp,int32_t height,bits256 txid,int32_t vout,uint8_t rmd160[20],int64_t value); void datachain_update_spend(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *coin,uint32_t timestamp,struct iguana_bundle *bp,int32_t height,bits256 txid,int32_t vout,uint8_t rmd160[20],int64_t value);
cJSON *bitcoin_data2json(struct iguana_info *coin,int32_t height,bits256 *txidp,struct iguana_msgtx *msgtx,uint8_t *extraspace,int32_t extralen,uint8_t *serialized,int32_t len,cJSON *vins,int32_t suppress_pubkeys); cJSON *bitcoin_data2json(struct iguana_info *coin,int32_t height,bits256 *txidp,struct iguana_msgtx *msgtx,uint8_t *extraspace,int32_t extralen,uint8_t *serialized,int32_t len,cJSON *vins,int32_t suppress_pubkeys);
int32_t iguana_unspentind2txid(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *spentheightp,bits256 *txidp,int32_t *voutp,int16_t hdrsi,uint32_t unspentind); int32_t iguana_unspentind2txid(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *spentheightp,bits256 *txidp,int32_t *voutp,struct iguana_outpoint outpt);
int32_t iguana_RTunspent_check(struct supernet_info *myinfo,struct iguana_info *coin,uint16_t hdrsi,uint32_t unspentind); int32_t iguana_RTunspent_check(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint outpt);
char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj); char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj);
char *iguana_signrawtx(struct supernet_info *myinfo,struct iguana_info *coin,int32_t height,bits256 *signedtxidp,int32_t *completedp,cJSON *vins,char *rawtx,cJSON *privkey,struct vin_info *V); char *iguana_signrawtx(struct supernet_info *myinfo,struct iguana_info *coin,int32_t height,bits256 *signedtxidp,int32_t *completedp,cJSON *vins,char *rawtx,cJSON *privkey,struct vin_info *V);
@ -547,7 +549,7 @@ int32_t iguana_scriptdata(struct iguana_info *coin,uint8_t *scriptspace,long fil
struct iguana_peer *basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *btcd,uint32_t ipbits); struct iguana_peer *basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *btcd,uint32_t ipbits);
int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20]); int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20]);
int32_t iguana_RTramchaindata(struct supernet_info *myinfo,struct iguana_info *coin,struct OS_memspace *TXDATA,struct OS_memspace *HASHMEM,int64_t polarity,struct iguana_block *block,struct iguana_msgtx *txarray,int32_t txn_count); int32_t iguana_RTramchaindata(struct supernet_info *myinfo,struct iguana_info *coin,struct OS_memspace *TXDATA,struct OS_memspace *HASHMEM,int64_t polarity,struct iguana_block *block,struct iguana_msgtx *txarray,int32_t txn_count);
struct iguana_RTtxid *iguana_RTtxid(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,int32_t txi,int32_t txn_count,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp); struct iguana_RTtxid *iguana_RTtxid_create(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,int32_t txi,int32_t txn_count,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp);
void iguana_RTspend(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_RTtxid *RTptr,struct iguana_block *block,int64_t polarity,uint8_t *script,int32_t scriptlen,bits256 txid,int32_t vini,bits256 prev_hash,int32_t prev_vout); void iguana_RTspend(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_RTtxid *RTptr,struct iguana_block *block,int64_t polarity,uint8_t *script,int32_t scriptlen,bits256 txid,int32_t vini,bits256 prev_hash,int32_t prev_vout);
void iguana_RTunspent(struct iguana_info *coin,struct iguana_RTtxid *RTptr,struct iguana_block *block,int64_t polarity,char *coinaddr,uint8_t *rmd160,int32_t type,uint8_t *script,int32_t scriptlen,bits256 txid,int32_t vout,int64_t value); void iguana_RTunspent(struct iguana_info *coin,struct iguana_RTtxid *RTptr,struct iguana_block *block,int64_t polarity,char *coinaddr,uint8_t *rmd160,int32_t type,uint8_t *script,int32_t scriptlen,bits256 txid,int32_t vout,int64_t value);

21
includes/iguana_structs.h

@ -249,11 +249,13 @@ struct iguana_pkhash { uint8_t rmd160[20]; uint32_t pkind; } __attribute__((pack
// dynamic // dynamic
struct iguana_account { int64_t total; uint32_t lastunspentind; } __attribute__((packed)); struct iguana_account { int64_t total; uint32_t lastunspentind; } __attribute__((packed));
struct iguana_utxo { uint32_t fromheight:31,lockedflag:1,prevunspentind:31,spentflag:1,spendind; } __attribute__((packed));
struct iguana_hhaccount { UT_hash_handle hh; uint64_t pval; struct iguana_account a; } __attribute__((packed)); struct iguana_hhaccount { UT_hash_handle hh; uint64_t pval; struct iguana_account a; } __attribute__((packed));
struct iguana_hhutxo { UT_hash_handle hh; uint64_t uval; struct iguana_utxo u; } __attribute__((packed)); struct iguana_utxo { uint32_t fromheight:31,lockedflag:1,prevunspentind:31,spentflag:1,spendind; } __attribute__((packed));
struct iguana_utxoaddr { UT_hash_handle hh; int64_t histbalance,RTcredits,RTdebits; uint32_t pkind:31,searchedhist:1; uint16_t hdrsi; uint8_t rmd160[20]; } __attribute__((packed)); #ifdef DEPRECATED_HHUTXO
struct iguana_hhutxo { UT_hash_handle hh; uint64_t uval; struct iguana_utxo u; } __attribute__((packed));
#endif
struct iguana_utxoaddr { UT_hash_handle hh; int64_t histbalance; uint32_t pkind:31,searchedhist:1; uint16_t hdrsi; uint8_t rmd160[20]; } __attribute__((packed));
// GLOBAL one zero to non-zero write (unless reorg) // GLOBAL one zero to non-zero write (unless reorg)
struct iguana_spendvector { uint64_t value; uint32_t pkind,unspentind; int32_t fromheight; uint16_t hdrsi:15,tmpflag:1; } __attribute__((packed)); // unspentind struct iguana_spendvector { uint64_t value; uint32_t pkind,unspentind; int32_t fromheight; uint16_t hdrsi:15,tmpflag:1; } __attribute__((packed)); // unspentind
@ -390,9 +392,11 @@ struct iguana_RTunspent
{ {
uint8_t rmd160[20]; uint8_t rmd160[20];
int64_t value; int64_t value;
int16_t scriptlen; int32_t vout,height;
struct iguana_RTtxid *parent;
struct iguana_RTspend *spend; struct iguana_RTspend *spend;
struct iguana_RTunspent *prevunspent; struct iguana_RTunspent *prevunspent;
int16_t scriptlen;
uint8_t spentflag,validflag; uint8_t spentflag,validflag;
uint8_t script[]; uint8_t script[];
}; };
@ -410,7 +414,7 @@ struct iguana_RTtxid
{ {
UT_hash_handle hh; struct iguana_info *coin; struct iguana_block *block; UT_hash_handle hh; struct iguana_info *coin; struct iguana_block *block;
bits256 txid; bits256 txid;
int32_t txi,txn_count,numvouts,numvins; int32_t height,txi,txn_count,numvouts,numvins;
uint32_t locktime,version,timestamp; uint32_t locktime,version,timestamp;
struct iguana_RTunspent **unspents; struct iguana_RTunspent **unspents;
struct iguana_RTspend *spends[]; struct iguana_RTspend *spends[];
@ -452,7 +456,10 @@ struct iguana_info
uint64_t bloomsearches,bloomhits,bloomfalse,collisions,txfee_perkb,txfee; uint64_t bloomsearches,bloomhits,bloomfalse,collisions,txfee_perkb,txfee;
uint8_t *blockspace; int32_t blockspacesize; struct OS_memspace blockMEM; uint8_t *blockspace; int32_t blockspacesize; struct OS_memspace blockMEM;
bits256 APIblockhash,APItxid; char *APIblockstr; bits256 APIblockhash,APItxid; char *APIblockstr;
struct iguana_hhutxo *utxotable; struct iguana_hhaccount *accountstable; char lastdispstr[2048]; #ifdef DEPRECATED_HHUTXO
struct iguana_hhutxo *utxotable; struct iguana_hhaccount *accountstable;
#endif
char lastdispstr[2048];
double txidfind_totalmillis,txidfind_num,spendtxid_totalmillis,spendtxid_num; double txidfind_totalmillis,txidfind_num,spendtxid_totalmillis,spendtxid_num;
struct iguana_monitorinfo monitoring[256]; struct iguana_monitorinfo monitoring[256];
struct datachain_info dPoW; struct datachain_info dPoW;
@ -492,6 +499,8 @@ struct bitcoin_spend
struct bitcoin_unspent inputs[]; struct bitcoin_unspent inputs[];
}; };
struct iguana_outpoint { void *ptr; int64_t value; uint32_t unspentind:31,isptr:1; int16_t hdrsi; };
struct exchange_quote { uint64_t satoshis,orderid,offerNXT,exchangebits; double price,volume; uint32_t timestamp,val; }; struct exchange_quote { uint64_t satoshis,orderid,offerNXT,exchangebits; double price,volume; uint32_t timestamp,val; };
struct _gfshare_ctx struct _gfshare_ctx

Loading…
Cancel
Save