Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
3f3529cded
  1. 30
      iguana/iguana_unspents.c
  2. 16
      iguana/iguana_volatiles.c

30
iguana/iguana_unspents.c

@ -538,9 +538,23 @@ uint8_t *iguana_rmdarray(struct supernet_info *myinfo,struct iguana_info *coin,i
return(rmdarray);
}
int32_t iguana_unspent_check(struct supernet_info *myinfo,struct iguana_info *coin,uint16_t hdrsi,uint32_t unspentind)
{
bits256 txid; int32_t vout,spentheight;
memset(&txid,0,sizeof(txid));
if ( iguana_unspentind2txid(myinfo,coin,&spentheight,&txid,&vout,hdrsi,unspentind) == 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));
return(1);
} else return(0);
} else return(-1);
}
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)
{
int64_t total,sum = 0; int32_t i,n,j,r,numunspents,numaddrs; uint8_t addrtype,pubkey[65],rmd160[20]; char *coinaddr,str[65]; struct iguana_waddress *waddr; struct iguana_waccount *wacct; struct basilisk_unspent *bu;
int64_t total,sum = 0; uint32_t unspentind; int32_t i,n,j,r,hdrsi,numunspents,numaddrs; uint8_t addrtype,pubkey[65],rmd160[20]; char *coinaddr,str[65]; struct iguana_waddress *waddr; struct iguana_waccount *wacct; struct basilisk_unspent *bu;
*totalp = 0;
if ( (numaddrs= cJSON_GetArraySize(addresses)) == 0 )
{
@ -562,9 +576,17 @@ int32_t iguana_unspentslists(struct supernet_info *myinfo,struct iguana_info *co
iguana_pkhasharray(myinfo,coin,0,minconf,coin->longestchain,&total,0,coin->bundlescount,rmd160,coinaddr,pubkey,coin->blocks.hwmchain.height - minconf,unspents,&n,max-1000,remoteaddr);
if ( n > 0 )
{
sum += total;
unspents += (n << 1);
numunspents += n;
for (j=0; j<n; j++)
{
hdrsi = (int32_t)(*unspents >> 32);
unspentind = (int32_t)*unspents;
if ( iguana_unspent_check(myinfo,coin,hdrsi,unspentind) == 0 )
{
sum += unspents[1];
unspents += 2;
numunspents++;
}
}
}
}
else

16
iguana/iguana_volatiles.c

@ -140,8 +140,8 @@ struct iguana_utxo iguana_utxofind(struct iguana_info *coin,int16_t spent_hdrsi,
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 vout,RTspentflag; struct iguana_utxo utxo; uint64_t confs,RTspend = 0;
struct iguana_ramchaindata *rdata; bits256 txid; char str[65];
uint32_t numunspents; int32_t RTspentflag; struct iguana_utxo utxo; uint64_t confs,RTspend = 0;
struct iguana_ramchaindata *rdata;
*spentheightp = -1;
if ( (rdata= ramchain->H.data) == 0 )
return(0);
@ -149,18 +149,6 @@ int32_t iguana_spentflag(struct supernet_info *myinfo,struct iguana_info *coin,i
utxo = iguana_utxofind(coin,spent_hdrsi,spent_unspentind,&RTspentflag,0);
if ( RTspentflag != 0 )
*RTspendp = (amount == 0) ? coin->txfee : amount;
memset(&txid,0,sizeof(txid));
if ( coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 )
{
if ( iguana_unspentind2txid(myinfo,coin,spentheightp,&txid,&vout,spent_hdrsi,spent_unspentind) == 0 && basilisk_addspend(myinfo,coin->symbol,txid,vout,0) != 0 )
{
printf("iguana_spentflag found unspentind (%u %d) %s\n",spent_hdrsi,spent_unspentind,bits256_str(str,txid));
(*RTspendp) += RTspend;
return(-1);
}
else if ( bits256_nonz(txid) != 0 )
printf("iguana_spentflag %s not in mempool\n",bits256_str(str,txid));
}
if ( utxo.spentflag != 0 && utxo.fromheight == 0 )
{
printf("illegal unspentind.%u vs %u hdrs.%d zero fromheight?\n",spent_unspentind,numunspents,spent_hdrsi);

Loading…
Cancel
Save