Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
b21839acc9
  1. 2
      basilisk/basilisk_bitcoin.c
  2. 2
      gecko/gecko.c
  3. 2
      gecko/gecko_blocks.c
  4. 4
      gecko/gecko_mempool.c
  5. 10
      iguana/iguana777.c
  6. 8
      iguana/iguana_accept.c
  7. 4
      iguana/iguana_msg.c
  8. 14
      iguana/iguana_payments.c
  9. 8
      iguana/iguana_realtime.c
  10. 4
      iguana/iguana_sign.c
  11. 17
      iguana/iguana_spendvectors.c
  12. 4
      iguana/iguana_txidfind.c
  13. 45
      iguana/iguana_unspents.c
  14. 8
      iguana/iguana_volatiles.c
  15. 2
      iguana/iguana_wallet.c
  16. 15
      iguana/main.c
  17. 19
      includes/iguana_funcs.h

2
basilisk/basilisk_bitcoin.c

@ -377,7 +377,7 @@ void *basilisk_bitcoinvalue(struct basilisk_item *Lptr,struct supernet_info *myi
{
if ( (coin->VALIDATENODE != 0 || coin->RELAYNODE != 0) )//&& coinaddr != 0 && coinaddr[0] != 0 )
{
if ( iguana_unspentindfind(coin,coinaddr,0,0,&value,&height,txid,vout,coin->bundlescount,0) > 0 )
if ( iguana_unspentindfind(myinfo,coin,coinaddr,0,0,&value,&height,txid,vout,coin->bundlescount,0) > 0 )
{
//printf("bitcoinvalue found iguana\n");
Lptr->retstr = basilisk_valuestr(coin,coinaddr,value,height,txid,vout);

2
gecko/gecko.c

@ -47,7 +47,7 @@ void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struc
longesthdrsi = virt->longestchain / virt->chain->bundlesize;
if ( (bp= virt->bundles[hwmhdrsi]) != 0 )
{
iguana_RTspendvectors(virt,bp);
iguana_RTspendvectors(myinfo,virt,bp);
iguana_RTramchainalloc("RTbundle",virt,bp);
iguana_update_balances(virt);
iguana_realtime_update(myinfo,virt);

2
gecko/gecko_blocks.c

@ -158,7 +158,7 @@ int32_t gecko_hwmset(struct supernet_info *myinfo,struct iguana_info *virt,struc
if ( bp->blocks[i] != 0 && bp->blocks[i]->txvalid != 0 )
bp->numsaved++;
virt->current = bp;
iguana_RTspendvectors(virt,bp);
iguana_RTspendvectors(myinfo,virt,bp);
iguana_RTramchainalloc("RTbundle",virt,bp);
iguana_update_balances(virt);
iguana_realtime_update(myinfo,virt);

4
gecko/gecko_mempool.c

@ -237,11 +237,11 @@ char *gecko_txarrived(struct supernet_info *myinfo,struct iguana_info *virt,char
{
for (i=0; i<numvins; i++)
{
if ( (unspentind= iguana_unspentindfind(virt,0,0,0,&value,&spentheight,msg.vins[i].prev_hash,msg.vins[i].prev_vout,virt->bundlescount-1,1)) != 0 )
if ( (unspentind= iguana_unspentindfind(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;
hdrsi_unspentind = ((uint64_t)hdrsi << 32) | unspentind;
if ( iguana_unspentavail(virt,hdrsi_unspentind,minconf,maxconf) != value )
if ( iguana_unspentavail(myinfo,virt,hdrsi_unspentind,minconf,maxconf) != value )
{
printf("vin.%d already spent\n",i);
return(clonestr("{\"error\":\"gecko tx has double spend\"}"));

10
iguana/iguana777.c

@ -361,7 +361,7 @@ int32_t iguana_validated(struct iguana_info *coin)
return(n);
}
int32_t iguana_helperA(struct iguana_info *coin,struct iguana_bundle *bp,int32_t convertflag)
int32_t iguana_helperA(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,int32_t convertflag)
{
int32_t retval,num = 0;
if ( bp == 0 )
@ -373,7 +373,7 @@ int32_t iguana_helperA(struct iguana_info *coin,struct iguana_bundle *bp,int32_t
if ( strcmp("BTC",coin->symbol) == 0 || iguana_bundlevalidate(coin,bp,0) == bp->n ) //
{
retval = 0;
if ( bp->utxofinish > 1 || (retval= iguana_spendvectors(coin,bp,&bp->ramchain,0,bp->n,convertflag,0)) >= 0 )
if ( bp->utxofinish > 1 || (retval= iguana_spendvectors(myinfo,coin,bp,&bp->ramchain,0,bp->n,convertflag,0)) >= 0 )
{
if ( retval > 0 )
{
@ -447,7 +447,7 @@ void iguana_update_balances(struct iguana_info *coin)
}
}
int32_t iguana_utxogen(struct iguana_info *coin,int32_t helperid,int32_t convertflag)
int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int32_t helperid,int32_t convertflag)
{
int32_t hdrsi,n,i,max,incr,num = 0; struct iguana_bundle *bp;
if ( coin->spendvectorsaved > 1 )
@ -465,7 +465,7 @@ int32_t iguana_utxogen(struct iguana_info *coin,int32_t helperid,int32_t convert
if ( helperid < incr )
{
for (hdrsi=helperid; hdrsi<max; hdrsi+=incr)
num += iguana_helperA(coin,coin->bundles[hdrsi],convertflag);
num += iguana_helperA(myinfo,coin,coin->bundles[hdrsi],convertflag);
}
while ( (n= iguana_utxofinished(coin)) < max )
{
@ -564,7 +564,7 @@ void iguana_helper(void *arg)
HASH_ITER(hh,myinfo->allcoins,coin,tmp)
{
if ( coin->spendvectorsaved == 1 )
iguana_utxogen(coin,helperid,0);
iguana_utxogen(myinfo,coin,helperid,0);
else if ( coin->spendvectorsaved > 1 )
{
for (j=helperid; j<coin->bundlescount-1; j+=IGUANA_NUMHELPERS)

8
iguana/iguana_accept.c

@ -303,10 +303,10 @@ int32_t iguana_headerget(struct iguana_info *coin,uint8_t *serialized,int32_t ma
return(len);
}
int32_t iguana_peerhdrrequest(struct iguana_info *coin,uint8_t *serialized,int32_t maxsize,struct iguana_peer *addr,bits256 hash2)
int32_t iguana_peerhdrrequest(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t *serialized,int32_t maxsize,struct iguana_peer *addr,bits256 hash2)
{
int32_t len=0,i,flag=0,height,n,hdrsi,bundlei,bundlesize,firstvout,retval=-1; struct iguana_block *block; struct iguana_bundle *bp;
if ( (firstvout= iguana_unspentindfind(coin,0,0,0,0,&height,hash2,0,coin->bundlescount-1,0)) != 0 )
if ( (firstvout= iguana_unspentindfind(myinfo,coin,0,0,0,0,&height,hash2,0,coin->bundlescount-1,0)) != 0 )
{
bundlesize = coin->chain->bundlesize;
hdrsi = (height / bundlesize);
@ -333,7 +333,7 @@ int32_t iguana_peerhdrrequest(struct iguana_info *coin,uint8_t *serialized,int32
return(retval);
}
int32_t iguana_peergetrequest(struct iguana_info *coin,struct iguana_peer *addr,uint8_t *data,int32_t recvlen,int32_t getblock)
int32_t iguana_peergetrequest(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,uint8_t *data,int32_t recvlen,int32_t getblock)
{
int32_t i,reqvers,len,n,flag = 0; bits256 hash2;
if ( getblock != 0 )
@ -350,7 +350,7 @@ int32_t iguana_peergetrequest(struct iguana_info *coin,struct iguana_peer *addr,
{
if ( getblock != 0 && iguana_peerblockrequest(coin,addr->blockspace,IGUANA_MAXPACKETSIZE,addr,hash2,0) > 0 )
flag = 1;
else if ( getblock == 0 && iguana_peerhdrrequest(coin,addr->blockspace,IGUANA_MAXPACKETSIZE,addr,hash2) > 0 )
else if ( getblock == 0 && iguana_peerhdrrequest(myinfo,coin,addr->blockspace,IGUANA_MAXPACKETSIZE,addr,hash2) > 0 )
flag = 1;
}
}

4
iguana/iguana_msg.c

@ -863,7 +863,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
}
else
{
len = iguana_peergetrequest(coin,addr,data,recvlen,1);
len = iguana_peergetrequest(myinfo,coin,addr,data,recvlen,1);
}
}
}
@ -938,7 +938,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
} else printf("got unexpected n.%d for headers\n",n);
}
else if ( addr->headerserror == 0 )
len = iguana_peergetrequest(coin,addr,data,recvlen,0);
len = iguana_peergetrequest(myinfo,coin,addr,data,recvlen,0);
}
}
else if ( (ishost= (strcmp(H->command,"version") == 0)) || strcmp(H->command,"verack") == 0 )

14
iguana/iguana_payments.c

@ -262,7 +262,7 @@ cJSON *iguana_inputsjson(struct supernet_info *myinfo,struct iguana_info *coin,i
u = &U[unspentind];
if ( (txidind= u->txidind) > 0 && txidind < rdata->numtxids )
{
if ( iguana_unspentindfind(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) == unspentind && spendlen > 0 )
{
jaddi(vins,iguana_inputjson(T[txidind].txid,u->vout,spendscript,spendlen));
total += value;
@ -420,7 +420,7 @@ void iguana_unspentslock(struct supernet_info *myinfo,struct iguana_info *coin,c
num = cJSON_GetArraySize(vins);
for (i=0; i<num; i++)
{
if ( iguana_inputaddress(coin,coinaddr,&spent_hdrsi,&spent_unspentind,jitem(vins,i)) != 0 )
if ( iguana_inputaddress(myinfo,coin,coinaddr,&spent_hdrsi,&spent_unspentind,jitem(vins,i)) != 0 )
iguana_utxofind(coin,spent_hdrsi,spent_unspentind,&RTspentflag,1);
}
}
@ -666,7 +666,7 @@ HASH_AND_TWOINTS(bitcoinrpc,gettxout,txid,vout,mempool)
if ( coin != 0 )
{
minconf = (mempool != 0) ? 0 : 1;
if ( (unspentind= iguana_unspentindfind(coin,0,0,0,0,&height,txid,vout,coin->bundlescount-1,0)) != 0 )
if ( (unspentind= iguana_unspentindfind(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 )
{
@ -677,7 +677,7 @@ HASH_AND_TWOINTS(bitcoinrpc,gettxout,txid,vout,mempool)
P = RAMCHAIN_PTR(rdata,Poffset);
T = RAMCHAIN_PTR(rdata,Toffset);
RTspend = 0;
if ( iguana_spentflag(coin,&RTspend,&spentheight,ramchain,bp->hdrsi,unspentind,height,minconf,coin->longestchain,U[unspentind].value) == 0 )
if ( iguana_spentflag(myinfo,coin,&RTspend,&spentheight,ramchain,bp->hdrsi,unspentind,height,minconf,coin->longestchain,U[unspentind].value) == 0 )
{
jaddbits256(retjson,"bestblock",coin->blocks.hwmchain.RO.hash2);
jaddnum(retjson,"bestheight",coin->blocks.hwmchain.height);
@ -918,7 +918,7 @@ char *iguana_validaterawtx(struct supernet_info *myinfo,struct iguana_info *coin
for (i=0; i<numinputs; i++)
{
len += iguana_parsevinobj(myinfo,coin,&serialized[len],maxsize-len,&vin,jitem(vins,i),&V[i]);
if ( (V[i].unspentind= iguana_unspentindfind(coin,V[i].coinaddr,V[i].spendscript,&V[i].spendlen,&V[i].amount,&V[i].height,msgtx->vins[i].prev_hash,msgtx->vins[i].prev_vout,coin->bundlescount-1,mempool)) > 0 )
if ( (V[i].unspentind= iguana_unspentindfind(myinfo,coin,V[i].coinaddr,V[i].spendscript,&V[i].spendlen,&V[i].amount,&V[i].height,msgtx->vins[i].prev_hash,msgtx->vins[i].prev_vout,coin->bundlescount-1,mempool)) > 0 )
{
inputsum += V[i].amount;
msgtx->vins[i].spendscript = V[i].spendscript;
@ -1020,7 +1020,7 @@ cJSON *iguana_createvins(struct supernet_info *myinfo,struct iguana_info *coin,c
spendlen = (int32_t)strlen(hexstr) >> 1;
decode_hex(spendscript,spendlen,hexstr);
}
if ( (unspentind= iguana_unspentindfind(coin,coinaddr,spendscript,&spendlen,&satoshis,&height,txid,vout,coin->bundlescount-1,0)) > 0 )
if ( (unspentind= iguana_unspentindfind(myinfo,coin,coinaddr,spendscript,&spendlen,&satoshis,&height,txid,vout,coin->bundlescount-1,0)) > 0 )
{
//printf("[%d] unspentind.%d (%s) spendlen.%d %.8f\n",height/coin->chain->bundlesize,unspentind,coinaddr,spendlen,dstr(satoshis));
if ( coinaddr[0] != 0 && (waddr= iguana_waddresssearch(myinfo,&wacct,coinaddr)) != 0 )
@ -1181,7 +1181,7 @@ INT_AND_ARRAY(bitcoinrpc,lockunspent,flag,array)
{
txid = jbits256(item,"txid");
vout = jint(item,"vout");
if ( (unspentind= iguana_unspentindfind(coin,0,0,0,0,&height,txid,vout,coin->bundlescount-1,0)) != 0 )
if ( (unspentind= iguana_unspentindfind(myinfo,coin,0,0,0,0,&height,txid,vout,coin->bundlescount-1,0)) != 0 )
{
hdrsi = height / coin->chain->bundlesize;
iguana_utxofind(coin,hdrsi,unspentind,&RTspendflag,!flag);

8
iguana/iguana_realtime.c

@ -151,7 +151,7 @@ void iguana_RThdrs(struct iguana_info *coin,struct iguana_bundle *bp,int32_t num
}
}
void iguana_RTspendvectors(struct iguana_info *coin,struct iguana_bundle *bp)
void iguana_RTspendvectors(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp)
{
int32_t iterate,lasti,num,hdrsi,orignumemit; struct iguana_ramchain R; struct iguana_ramchaindata RDATA;
if ( bp->hdrsi <= 0 )
@ -166,7 +166,7 @@ void iguana_RTspendvectors(struct iguana_info *coin,struct iguana_bundle *bp)
#else
iterate = 0;
#endif
if ( iguana_spendvectors(coin,bp,&coin->RTramchain,coin->RTstarti,lasti,0,iterate) < 0 )
if ( iguana_spendvectors(myinfo,coin,bp,&coin->RTramchain,coin->RTstarti,lasti,0,iterate) < 0 )
{
printf("RTutxo error -> RTramchainfree\n");
coin->RTdatabad = 1;
@ -228,7 +228,7 @@ int32_t iguana_realtime_update(struct supernet_info *myinfo,struct iguana_info *
{
if ( (bp= coin->bundles[i]) != 0 && (i > 0 && bp->utxofinish == 0) && bp != coin->current )
{
if ( iguana_spendvectors(coin,bp,&bp->ramchain,0,bp->n,0,0) < 0 )
if ( iguana_spendvectors(myinfo,coin,bp,&bp->ramchain,0,bp->n,0,0) < 0 )
{
printf("error generating spendvectors.[%d], skipping\n",i);
return(0);
@ -346,7 +346,7 @@ int32_t iguana_realtime_update(struct supernet_info *myinfo,struct iguana_info *
//printf("RTgenesis verified\n");
if ( (coin->RTheight % coin->chain->bundlesize) > 3 )
{
iguana_RTspendvectors(coin,bp);
iguana_RTspendvectors(myinfo,coin,bp);
coin->RTgenesis = (uint32_t)time(NULL);
}
}

4
iguana/iguana_sign.c

@ -163,7 +163,7 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin
{
if ( vin->vinscript == 0 )
{
if ( (V->unspentind= iguana_unspentindfind(coin,V->coinaddr,V->spendscript,&V->spendlen,&V->amount,&V->height,vin->prev_hash,vin->prev_vout,coin->bundlescount-1,0)) > 0 )
if ( (V->unspentind= iguana_unspentindfind(myinfo,coin,V->coinaddr,V->spendscript,&V->spendlen,&V->amount,&V->height,vin->prev_hash,vin->prev_vout,coin->bundlescount-1,0)) > 0 )
{
if ( V->coinaddr[0] != 0 && (waddr= iguana_waddresssearch(myinfo,&wacct,V->coinaddr)) != 0 )
{
@ -746,7 +746,7 @@ int32_t iguana_vininfo_create(struct supernet_info *myinfo,struct iguana_info *c
finalized = 0;
if ( msgtx->vins[i].spendscript == 0 )
{
if ( (vp->unspentind= iguana_unspentindfind(coin,vp->coinaddr,vp->spendscript,&vp->spendlen,&vp->amount,&vp->height,msgtx->vins[i].prev_hash,msgtx->vins[i].prev_vout,coin->bundlescount-1,0)) > 0 )
if ( (vp->unspentind= iguana_unspentindfind(myinfo,coin,vp->coinaddr,vp->spendscript,&vp->spendlen,&vp->amount,&vp->height,msgtx->vins[i].prev_hash,msgtx->vins[i].prev_vout,coin->bundlescount-1,0)) > 0 )
{
msgtx->vins[i].spendscript = vp->spendscript;
msgtx->vins[i].spendlen = vp->spendlen;

17
iguana/iguana_spendvectors.c

@ -183,7 +183,7 @@ struct iguana_bundle *iguana_externalspent(struct iguana_info *coin,bits256 *pre
return(0);
}
struct iguana_bundle *iguana_fastexternalspent(struct iguana_info *coin,bits256 *prevhashp,uint32_t *unspentindp,struct iguana_ramchain *ramchain,int32_t spent_hdrsi,struct iguana_spend *s)
struct iguana_bundle *iguana_fastexternalspent(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *prevhashp,uint32_t *unspentindp,struct iguana_ramchain *ramchain,int32_t spent_hdrsi,struct iguana_spend *s)
{
int32_t prev_vout,height,hdrsi,unspentind; uint32_t ind;
struct iguana_txid *T; bits256 *X; bits256 prev_hash; struct iguana_ramchaindata *rdata;
@ -203,7 +203,7 @@ struct iguana_bundle *iguana_fastexternalspent(struct iguana_info *coin,bits256
X = RAMCHAIN_PTR(rdata,Xoffset);
//X = (void *)(long)((long)rdata + rdata->Xoffset);
*prevhashp = prev_hash = X[ind];
if ( (unspentind= iguana_unspentindfind(coin,0,0,0,0,&height,prev_hash,prev_vout,spent_hdrsi-1,0)) != 0 )
if ( (unspentind= iguana_unspentindfind(myinfo,coin,0,0,0,0,&height,prev_hash,prev_vout,spent_hdrsi-1,0)) != 0 )
//if ( (firstvout= iguana_txidfastfind(coin,&height,prev_hash,spent_hdrsi-1)) >= 0 )
{
/*duration = (OS_milliseconds() - startmillis);
@ -234,7 +234,7 @@ struct iguana_bundle *iguana_fastexternalspent(struct iguana_info *coin,bits256
return(0);
}
int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_ramchain *ramchain,int32_t starti,int32_t numblocks,int32_t convertflag,int32_t iterate)
int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_ramchain *ramchain,int32_t starti,int32_t numblocks,int32_t convertflag,int32_t iterate)
{
static uint64_t total,emitted;
int32_t iter,spendind,n=0,txidind,errs=0,emit=0,i,j,k; double startmillis; bits256 prevhash;
@ -248,9 +248,12 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp,st
printf("iguana_spendvectors.[%d]: no rdata.%p %d\n",bp->hdrsi,rdata,n);
return(0);
}
B = (void *)(long)((long)rdata + rdata->Boffset);
S = (void *)(long)((long)rdata + rdata->Soffset);
T = (void *)(long)((long)rdata + rdata->Toffset);
B = RAMCHAIN_PTR(rdata,Boffset);
S = RAMCHAIN_PTR(rdata,Soffset);
T = RAMCHAIN_PTR(rdata,Toffset);
//B = (void *)(long)((long)rdata + rdata->Boffset);
//S = (void *)(long)((long)rdata + rdata->Soffset);
//T = (void *)(long)((long)rdata + rdata->Toffset);
if ( ramchain->Xspendinds != 0 )
{
bp->tmpspends = ramchain->Xspendinds;
@ -307,7 +310,7 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp,st
{
if ( coin->fastfind != 0 )
{
spentbp = iguana_fastexternalspent(coin,&prevhash,&spent_unspentind,ramchain,bp->hdrsi,s);
spentbp = iguana_fastexternalspent(myinfo,coin,&prevhash,&spent_unspentind,ramchain,bp->hdrsi,s);
}
else if ( spentbp == 0 )
{

4
iguana/iguana_txidfind.c

@ -648,12 +648,12 @@ struct iguana_monitorinfo *iguana_txidmonitor(struct iguana_info *coin,bits256 t
return(0);
}
double iguana_txidstatus(struct iguana_info *coin,bits256 txid)
double iguana_txidstatus(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid)
{
int32_t height,firstvout,numranked; struct iguana_monitorinfo *ptr; char str[65];
if ( coin != 0 && coin->peers != 0 && (numranked= coin->peers->numranked) > 0 )
{
if ( (firstvout= iguana_unspentindfind(coin,0,0,0,0,&height,txid,0,coin->bundlescount-1,0)) != 0 )
if ( (firstvout= iguana_unspentindfind(myinfo,coin,0,0,0,0,&height,txid,0,coin->bundlescount-1,0)) != 0 )
{
if ( (ptr= iguana_monitorfind(coin,txid)) != 0 )
memset(ptr,0,sizeof(*ptr));

45
iguana/iguana_unspents.c

@ -20,7 +20,36 @@
#include "iguana777.h"
#include "exchanges/bitcoin.h"
int32_t iguana_unspentindfind(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_unspentind2txid(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,int16_t hdrsi,uint32_t unspentind)
{
struct iguana_ramchaindata *rdata=0; struct iguana_bundle *bp; struct iguana_unspent *U,*u; struct iguana_txid *T,*t;
*voutp = -1;
memset(txidp,0,sizeof(*txidp));
if ( hdrsi < coin->bundlescount-1 )
rdata = coin->RTramchain.H.data;
else if ( (bp= coin->bundles[hdrsi]) != 0 )
rdata = bp->ramchain.H.data;
if ( rdata != 0 && unspentind > 0 && unspentind < rdata->numunspents )
{
U = RAMCHAIN_PTR(rdata,Uoffset);
u = &U[unspentind];
if ( u->txidind > 0 && u->txidind < rdata->numtxids )
{
T = RAMCHAIN_PTR(rdata,Toffset);
t = &T[u->txidind];
if ( unspentind >= t->firstvout )
{
*txidp = t->txid;
*voutp = unspentind - t->firstvout;
return(0);
}
}
}
return(-1);
}
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;
if ( valuep != 0 )
@ -40,7 +69,7 @@ int32_t iguana_unspentindfind(struct iguana_info *coin,char *coinaddr,uint8_t *s
{
RTspend = 0;
flag++;
if ( iguana_spentflag(coin,&RTspend,&spentheight,bp == coin->current ? &coin->RTramchain : &bp->ramchain,bp->hdrsi,unspentind,0,1,coin->longestchain,U[unspentind].value) == 0 ) //
if ( iguana_spentflag(myinfo,coin,&RTspend,&spentheight,bp == coin->current ? &coin->RTramchain : &bp->ramchain,bp->hdrsi,unspentind,0,1,coin->longestchain,U[unspentind].value) == 0 ) //
{
if ( valuep != 0 )
*valuep = U[unspentind].value;
@ -70,7 +99,7 @@ int32_t iguana_unspentindfind(struct iguana_info *coin,char *coinaddr,uint8_t *s
return(unspentind);
}
char *iguana_inputaddress(struct iguana_info *coin,char *coinaddr,int16_t *spent_hdrsip,uint32_t *unspentindp,cJSON *vinobj)
char *iguana_inputaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int16_t *spent_hdrsip,uint32_t *unspentindp,cJSON *vinobj)
{
bits256 txid; int32_t vout,checkind,height;
*unspentindp = 0;
@ -81,7 +110,7 @@ char *iguana_inputaddress(struct iguana_info *coin,char *coinaddr,int16_t *spent
vout = jint(vinobj,"vout");
height = jint(vinobj,"height");
checkind = jint(vinobj,"checkind");
if ( (height != 0 && checkind != 0) || (checkind= iguana_unspentindfind(coin,coinaddr,0,0,0,&height,txid,vout,coin->bundlescount-1,0)) > 0 )
if ( (height != 0 && checkind != 0) || (checkind= iguana_unspentindfind(myinfo,coin,coinaddr,0,0,0,&height,txid,vout,coin->bundlescount-1,0)) > 0 )
{
*spent_hdrsip = (height / coin->chain->bundlesize);
*unspentindp = checkind;
@ -196,7 +225,7 @@ cJSON *iguana_unspentjson(struct supernet_info *myinfo,struct iguana_info *coin,
jaddstr(item,"scriptPubKey",scriptstr);
jaddnum(item,"amount",dstr(up->value));
jaddnum(item,"timestamp",T[up->txidind].timestamp);
if ( (checkind= iguana_unspentindfind(coin,0,0,0,0,&height,T[up->txidind].txid,up->vout,coin->bundlescount-1,0)) != 0 )
if ( (checkind= iguana_unspentindfind(myinfo,coin,0,0,0,0,&height,T[up->txidind].txid,up->vout,coin->bundlescount-1,0)) != 0 )
{
jaddnum(item,"height",height);
jaddnum(item,"confirmations",coin->blocks.hwmchain.height - height + 1);
@ -334,7 +363,7 @@ int64_t iguana_pkhashbalance(struct supernet_info *myinfo,struct iguana_info *co
if ( lastheight <= 0 || uheight < lastheight )
{
deposits += U[unspentind].value;
if ( iguana_spentflag(coin,&RTspend,&spentheight,ramchain,hdrsi,unspentind,lastheight,minconf,maxconf,U[unspentind].value) == 0 )
if ( iguana_spentflag(myinfo,coin,&RTspend,&spentheight,ramchain,hdrsi,unspentind,lastheight,minconf,maxconf,U[unspentind].value) == 0 )
{
if ( *nump < max && unspents != 0 )
{
@ -591,7 +620,7 @@ int32_t iguana_uvaltxid(struct supernet_info *myinfo,bits256 *txidp,struct iguan
return(-1);
}
int64_t iguana_unspentavail(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,uint64_t hdrsi_unspentind,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;
if ( (bp= coin->bundles[hdrsi_unspentind>>32]) == 0 )
@ -601,7 +630,7 @@ int64_t iguana_unspentavail(struct iguana_info *coin,uint64_t hdrsi_unspentind,i
ramchain = (bp == coin->current) ? &coin->RTramchain : &bp->ramchain;
if ( (rdata= ramchain->H.data) == 0 )
return(0);
if ( (spentflag= iguana_spentflag(coin,&RTspend,&spentheight,ramchain,hdrsi,unspentind,0,minconf,maxconf,0)) > 0 )
if ( (spentflag= iguana_spentflag(myinfo,coin,&RTspend,&spentheight,ramchain,hdrsi,unspentind,0,minconf,maxconf,0)) > 0 )
{
printf("[%d].u%d was already spent ht.%d\n",hdrsi,(uint32_t)unspentind,spentheight);
return(-1);

8
iguana/iguana_volatiles.c

@ -138,14 +138,16 @@ struct iguana_utxo iguana_utxofind(struct iguana_info *coin,int16_t spent_hdrsi,
return(utxo);
}
int32_t iguana_spentflag(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_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)
{
uint32_t numunspents; int32_t RTspentflag; struct iguana_utxo utxo; uint64_t confs,RTspend = 0;
struct iguana_ramchaindata *rdata;
uint32_t numunspents; int32_t vout,RTspentflag; struct iguana_utxo utxo; uint64_t confs,RTspend = 0;
struct iguana_ramchaindata *rdata; bits256 txid;
*spentheightp = -1;
if ( (rdata= ramchain->H.data) == 0 )
return(0);
numunspents = rdata->numunspents;
if ( iguana_unspentind2txid(myinfo,coin,&txid,&vout,spent_hdrsi,spent_unspentind) == 0 && basilisk_addspend(myinfo,coin->symbol,txid,vout,0) != 0 )
return(-1);
utxo = iguana_utxofind(coin,spent_hdrsi,spent_unspentind,&RTspentflag,0);
if ( RTspentflag != 0 )
*RTspendp = (amount == 0) ? coin->txfee : amount;

2
iguana/iguana_wallet.c

@ -853,7 +853,7 @@ cJSON *iguana_privkeysjson(struct supernet_info *myinfo,struct iguana_info *coin
addresses = calloc(numinputs,64);
for (i=n=0; i<numinputs; i++)
{
if ( (address= iguana_inputaddress(coin,coinaddr,&spent_hdrsi,&spent_unspentind,jitem(vins,i))) != 0 )
if ( (address= iguana_inputaddress(myinfo,coin,coinaddr,&spent_hdrsi,&spent_unspentind,jitem(vins,i))) != 0 )
{
for (j=0; j<n; j++)
{

15
iguana/main.c

@ -555,6 +555,21 @@ void iguana_commandline(struct supernet_info *myinfo,char *arg)
free(str);
}
free_json(argjson);
if ( 0 )
{
uint32_t buf[81],c;
OS_randombytes((void *)buf,sizeof(buf));
printf("(");
for (i=0; i<81; i++)
{
c = buf[i] % 27;
if ( c == 26 )
c = '9';
else c += 'a';
printf("%c",c);
}
printf(") <- IOTA random passphrase\n");
}
} else printf("error parsing.(%s)\n",(char *)argstr);
if ( argstr != arg )
free(argstr);

19
includes/iguana_funcs.h

@ -325,7 +325,7 @@ uint32_t iguana_sparseaddpk(uint8_t *bits,int32_t width,uint32_t tablesize,uint8
int32_t iguana_vinscriptparse(struct iguana_info *coin,struct vin_info *vp,uint32_t *sigsizep,uint32_t *pubkeysizep,uint32_t *p2shsizep,uint32_t *suffixp,uint8_t *vinscript,int32_t scriptlen);
void iguana_parsebuf(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_msghdr *H,uint8_t *buf,int32_t len);
int32_t _iguana_calcrmd160(struct iguana_info *coin,struct vin_info *vp);
int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_ramchain *ramchain,int32_t starti,int32_t numblocks,int32_t convertflag,int32_t iterate);
int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_ramchain *ramchain,int32_t starti,int32_t numblocks,int32_t convertflag,int32_t iterate);
int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct iguana_bundle *bp,int32_t startheight,int32_t endheight,int32_t startemit);
int32_t iguana_bundlevalidate(struct iguana_info *coin,struct iguana_bundle *bp,int32_t forceflag);
void iguana_validateQ(struct iguana_info *coin,struct iguana_bundle *bp);
@ -388,10 +388,10 @@ int32_t iguana_rwaddr(int32_t rwflag,uint8_t *serialized,struct iguana_msgaddres
struct iguana_bundle *iguana_bundleset(struct iguana_info *coin,struct iguana_block **blockp,int32_t *bundleip,struct iguana_block *origblock);
struct iguana_waddress *iguana_waddresscreate(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_waccount *wacct,char *coinaddr,char *redeemScript);
int32_t iguana_peerhdrrequest(struct iguana_info *coin,uint8_t *serialized,int32_t maxsize,struct iguana_peer *addr,bits256 hash2);
int32_t iguana_peerhdrrequest(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t *serialized,int32_t maxsize,struct iguana_peer *addr,bits256 hash2);
int32_t iguana_peeraddrrequest(struct iguana_info *coin,struct iguana_peer *addr,uint8_t *space,int32_t max);
int32_t iguana_peerdatarequest(struct iguana_info *coin,struct iguana_peer *addr,uint8_t *space,int32_t max);
int32_t iguana_peergetrequest(struct iguana_info *coin,struct iguana_peer *addr,uint8_t *data,int32_t recvlen,int32_t getblock);
int32_t iguana_peergetrequest(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,uint8_t *data,int32_t recvlen,int32_t getblock);
int32_t iguana_bundlefname(struct iguana_info *coin,struct iguana_bundle *bp,char *fname);
int32_t iguana_bundleremove(struct iguana_info *coin,int32_t hdrsi,int32_t tmpfiles);
int32_t iguana_voutsfname(struct iguana_info *coin,int32_t roflag,char *fname,int32_t slotid);
@ -404,11 +404,11 @@ void iguana_volatilesalloc(struct iguana_info *coin,struct iguana_ramchain *ramc
int32_t iguana_send_ping(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr);
int32_t iguana_process_msgrequestQ(struct supernet_info *myinfo,struct iguana_info *coin);
uint32_t iguana_fastfindinit(struct iguana_info *coin);
int32_t iguana_unspentindfind(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_unspentindfind(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 bitcoin_sign(void *ctx,char *symbol,uint8_t *sig,bits256 txhash2,bits256 privkey,int32_t recoverflag);
bits256 iguana_str2priv(struct supernet_info *myinfo,struct iguana_info *coin,char *str);
int32_t iguana_spentflag(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_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_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);
int32_t bitcoin_standardspend(uint8_t *script,int32_t n,uint8_t rmd160[20]);
@ -442,11 +442,11 @@ bits256 bitcoin_randkey(void *ctx);
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);
cJSON *iguana_spendasm(struct iguana_info *coin,uint8_t *spendscript,int32_t spendlen);
int64_t iguana_unspentavail(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,uint64_t hdrsi_unspendind,int32_t minconf,int32_t maxconf);
struct iguana_utxo iguana_utxofind(struct iguana_info *coin,int16_t spent_hdrsi,uint32_t spent_unspentind,int32_t *RTspendflagp,int32_t lockflag);
int32_t iguana_signrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,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);
char *iguana_inputaddress(struct iguana_info *coin,char *coinaddr,int16_t *spent_hdrsip,uint32_t *unspentindp,cJSON *vinobj);
char *iguana_inputaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int16_t *spent_hdrsip,uint32_t *unspentindp,cJSON *vinobj);
struct iguana_waddress *iguana_getaccountaddress(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *json,char *remoteaddr,char *coinaddr,char *account);
int32_t iguana_uvaltxid(struct supernet_info *myinfo,bits256 *txidp,struct iguana_info *coin,int16_t hdrsi,uint32_t unspentind);
struct instantdex_accept *instantdex_quotefind(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,bits256 encodedhash);
@ -472,6 +472,7 @@ 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);
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,bits256 *txidp,struct iguana_msgtx *msgtx,uint8_t *extraspace,int32_t extralen,uint8_t *serialized,int32_t len);
int32_t iguana_unspentind2txid(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,int16_t hdrsi,uint32_t unspentind);
char *iguana_signrawtx(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *signedtxidp,int32_t *completedp,cJSON *vins,char *rawtx,cJSON *privkey,struct vin_info *V);
bits256 scrypt_blockhash(const void *input);
@ -480,7 +481,7 @@ struct bitcoin_eventitem *instantdex_event(char *cmdstr,cJSON *argjson,cJSON *ne
void instantdex_eventfree(struct bitcoin_eventitem *ptr);
struct iguana_monitorinfo *iguana_txidmonitor(struct iguana_info *coin,bits256 txid);
struct iguana_monitorinfo *iguana_txidreport(struct iguana_info *coin,bits256 txid,struct iguana_peer *addr);
double iguana_txidstatus(struct iguana_info *coin,bits256 txid);
double iguana_txidstatus(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid);
void basilisk_functions(struct iguana_info *coin,int32_t protocol);
char *bitcoind_passthru(char *coinstr,char *serverport,char *userpass,char *method,char *params);
char *bitcoin_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJSON **vinsp,int64_t satoshis,char *paymentscriptstr,char *changeaddr,int64_t txfee,cJSON *addresses,int32_t minconf,uint32_t locktime);
@ -534,7 +535,7 @@ struct iguana_peer *basilisk_ensurerelay(struct supernet_info *myinfo,struct igu
int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20]);
void iguana_RTramchainalloc(char *fname,struct iguana_info *coin,struct iguana_bundle *bp);
void iguana_update_balances(struct iguana_info *coin);
void iguana_RTspendvectors(struct iguana_info *coin,struct iguana_bundle *bp);
void iguana_RTspendvectors(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp);
double instantdex_avehbla(struct supernet_info *myinfo,double retvals[4],char *base,char *rel,double basevolume);
int32_t bitcoin_revealsecret160(uint8_t *script,int32_t n,uint8_t secret160[20]);
int64_t iguana_lockval(int32_t finalized,int64_t locktime);

Loading…
Cancel
Save