|
|
@ -121,59 +121,6 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
|
|
|
|
struct iguana_pkhash *iguana_pkhashfind(struct iguana_info *coin,struct iguana_ramchain **ramchainp,int64_t *balancep,uint32_t *lastunspentindp,struct iguana_pkhash *p,uint8_t rmd160[20],int32_t firsti,int32_t endi) |
|
|
|
{ |
|
|
|
uint8_t *PKbits; struct iguana_pkhash *P; uint32_t pkind,i; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; struct iguana_account *ACCTS; |
|
|
|
*balancep = 0; |
|
|
|
*ramchainp = 0; |
|
|
|
*lastunspentindp = 0; |
|
|
|
for (i=firsti; i<coin->bundlescount&&i<=endi; i++) |
|
|
|
{ |
|
|
|
if ( (bp= coin->bundles[i]) != 0 ) |
|
|
|
{ |
|
|
|
ramchain = &bp->ramchain; |
|
|
|
if ( ramchain->H.data != 0 ) |
|
|
|
{ |
|
|
|
PKbits = (void *)(long)((long)ramchain->H.data + ramchain->H.data->PKoffset); |
|
|
|
P = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Poffset); |
|
|
|
ACCTS = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Aoffset); |
|
|
|
if ( (pkind= iguana_sparseaddpk(PKbits,ramchain->H.data->pksparsebits,ramchain->H.data->numpksparse,rmd160,P,0)) > 0 && pkind < ramchain->H.data->numpkinds ) |
|
|
|
{ |
|
|
|
*ramchainp = ramchain; |
|
|
|
*balancep = ACCTS[pkind].total; |
|
|
|
*lastunspentindp = ACCTS[pkind].lastunspentind; |
|
|
|
*p = P[pkind]; |
|
|
|
return(p); |
|
|
|
} //else printf("not found pkind.%d vs num.%d\n",pkind,ramchain->H.data->numpkinds);
|
|
|
|
} else printf("%s.[%d] error null ramchain->H.data\n",coin->symbol,i); |
|
|
|
} |
|
|
|
} |
|
|
|
return(0); |
|
|
|
} |
|
|
|
|
|
|
|
char *iguana_bundleaddrs(struct iguana_info *coin,int32_t hdrsi) |
|
|
|
{ |
|
|
|
uint8_t *PKbits; struct iguana_pkhash *P; uint32_t pkind; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; cJSON *retjson; char rmdstr[41]; |
|
|
|
if ( (bp= coin->bundles[hdrsi]) != 0 ) |
|
|
|
{ |
|
|
|
ramchain = &bp->ramchain; |
|
|
|
if ( ramchain->H.data != 0 ) |
|
|
|
{ |
|
|
|
retjson = cJSON_CreateArray(); |
|
|
|
PKbits = (void *)(long)((long)ramchain->H.data + ramchain->H.data->PKoffset); |
|
|
|
P = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Poffset); |
|
|
|
for (pkind=0; pkind<ramchain->H.data->numpkinds; pkind++,P++) |
|
|
|
{ |
|
|
|
init_hexbytes_noT(rmdstr,P->rmd160,20); |
|
|
|
jaddistr(retjson,rmdstr); |
|
|
|
} |
|
|
|
return(jprint(retjson,1)); |
|
|
|
} |
|
|
|
//iguana_bundleQ(coin,bp,bp->n);
|
|
|
|
return(clonestr("{\"error\":\"no bundle data\"}")); |
|
|
|
} return(clonestr("{\"error\":\"no bundle\"}")); |
|
|
|
} |
|
|
|
|
|
|
|
struct iguana_bundle *iguana_externalspent(struct iguana_info *coin,bits256 *prevhashp,uint32_t *unspentindp,struct iguana_ramchain *ramchain,int32_t spend_hdrsi,struct iguana_spend *s) |
|
|
|
{ |
|
|
|
int32_t prev_vout,height,hdrsi; uint32_t sequenceid,unspentind; char str[65]; |
|
|
@ -249,10 +196,78 @@ cJSON *iguana_unspentjson(struct iguana_info *coin,int32_t hdrsi,uint32_t unspen |
|
|
|
return(item); |
|
|
|
} |
|
|
|
|
|
|
|
struct iguana_pkhash *iguana_pkhashfind(struct iguana_info *coin,struct iguana_ramchain **ramchainp,int64_t *balancep,uint32_t *lastunspentindp,struct iguana_pkhash *p,uint8_t rmd160[20],int32_t firsti,int32_t endi) |
|
|
|
{ |
|
|
|
uint8_t *PKbits; struct iguana_pkhash *P; uint32_t pkind,i; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; struct iguana_account *ACCTS; |
|
|
|
*balancep = 0; |
|
|
|
*ramchainp = 0; |
|
|
|
*lastunspentindp = 0; |
|
|
|
for (i=firsti; i<coin->bundlescount&&i<=endi; i++) |
|
|
|
{ |
|
|
|
if ( (bp= coin->bundles[i]) != 0 ) |
|
|
|
{ |
|
|
|
if ( bp->isRT != 0 && coin->RTramchain_busy != 0 ) |
|
|
|
{ |
|
|
|
printf("iguana_pkhashfind: unexpected access when RTramchain_busy\n"); |
|
|
|
return(0); |
|
|
|
} |
|
|
|
ramchain = (bp->isRT != 0) ? &bp->ramchain : &coin->RTramchain; |
|
|
|
if ( ramchain->H.data != 0 ) |
|
|
|
{ |
|
|
|
PKbits = (void *)(long)((long)ramchain->H.data + ramchain->H.data->PKoffset); |
|
|
|
P = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Poffset); |
|
|
|
ACCTS = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Aoffset); |
|
|
|
if ( (pkind= iguana_sparseaddpk(PKbits,ramchain->H.data->pksparsebits,ramchain->H.data->numpksparse,rmd160,P,0)) > 0 && pkind < ramchain->H.data->numpkinds ) |
|
|
|
{ |
|
|
|
*ramchainp = ramchain; |
|
|
|
*balancep = ACCTS[pkind].total; |
|
|
|
*lastunspentindp = ACCTS[pkind].lastunspentind; |
|
|
|
*p = P[pkind]; |
|
|
|
return(p); |
|
|
|
} //else printf("not found pkind.%d vs num.%d\n",pkind,ramchain->H.data->numpkinds);
|
|
|
|
} else printf("%s.[%d] error null ramchain->H.data\n",coin->symbol,i); |
|
|
|
} |
|
|
|
} |
|
|
|
return(0); |
|
|
|
} |
|
|
|
|
|
|
|
char *iguana_bundleaddrs(struct iguana_info *coin,int32_t hdrsi) |
|
|
|
{ |
|
|
|
uint8_t *PKbits; struct iguana_pkhash *P; uint32_t pkind; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; cJSON *retjson; char rmdstr[41]; |
|
|
|
if ( (bp= coin->bundles[hdrsi]) != 0 ) |
|
|
|
{ |
|
|
|
if ( bp->isRT != 0 && coin->RTramchain_busy != 0 ) |
|
|
|
{ |
|
|
|
printf("iguana_bundleaddrs: unexpected access when RTramchain_busy\n"); |
|
|
|
return(0); |
|
|
|
} |
|
|
|
ramchain = (bp->isRT != 0) ? &bp->ramchain : &coin->RTramchain; |
|
|
|
if ( ramchain->H.data != 0 ) |
|
|
|
{ |
|
|
|
retjson = cJSON_CreateArray(); |
|
|
|
PKbits = (void *)(long)((long)ramchain->H.data + ramchain->H.data->PKoffset); |
|
|
|
P = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Poffset); |
|
|
|
for (pkind=0; pkind<ramchain->H.data->numpkinds; pkind++,P++) |
|
|
|
{ |
|
|
|
init_hexbytes_noT(rmdstr,P->rmd160,20); |
|
|
|
jaddistr(retjson,rmdstr); |
|
|
|
} |
|
|
|
return(jprint(retjson,1)); |
|
|
|
} |
|
|
|
//iguana_bundleQ(coin,bp,bp->n);
|
|
|
|
return(clonestr("{\"error\":\"no bundle data\"}")); |
|
|
|
} return(clonestr("{\"error\":\"no bundle\"}")); |
|
|
|
} |
|
|
|
|
|
|
|
int64_t iguana_pkhashbalance(struct iguana_info *coin,cJSON *array,int64_t *spentp,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) |
|
|
|
{ |
|
|
|
struct iguana_unspent *U; uint32_t unspentind; int64_t balance = 0; struct iguana_txid *T; |
|
|
|
*spentp = *nump = 0; |
|
|
|
if ( ramchain == &coin->RTramchain && coin->RTramchain_busy != 0 ) |
|
|
|
{ |
|
|
|
printf("iguana_pkhashbalance: unexpected access when RTramchain_busy\n"); |
|
|
|
return(0); |
|
|
|
} |
|
|
|
if ( ramchain->Uextras == 0 ) |
|
|
|
{ |
|
|
|
printf("iguana_pkhashbalance: unexpected null spents\n"); |
|
|
@ -279,6 +294,11 @@ int64_t iguana_pkhashbalance(struct iguana_info *coin,cJSON *array,int64_t *spen |
|
|
|
int32_t iguana_pkhasharray(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 i,n,m; int64_t spent,balance,netbalance,total; uint32_t lastunspentind; struct iguana_ramchain *ramchain; |
|
|
|
if ( coin->RTramchain_busy != 0 ) |
|
|
|
{ |
|
|
|
printf("iguana_pkhasharray: unexpected access when RTramchain_busy\n"); |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
for (total=i=n=0; i<max && i<coin->bundlescount; i++) |
|
|
|
{ |
|
|
|
if ( iguana_pkhashfind(coin,&ramchain,&balance,&lastunspentind,&P[n],rmd160,i,i) != 0 ) |
|
|
@ -304,6 +324,11 @@ int32_t iguana_pkhasharray(struct iguana_info *coin,cJSON *array,int32_t minconf |
|
|
|
void iguana_unspents(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,uint8_t *rmdarray,int32_t numrmds) |
|
|
|
{ |
|
|
|
int64_t total,sum=0; struct iguana_pkhash *P; uint8_t *addrtypes,*pubkeys; int32_t i,flag = 0; char coinaddr[64]; |
|
|
|
if ( coin->RTramchain_busy != 0 ) |
|
|
|
{ |
|
|
|
printf("iguana_pkhasharray: unexpected access when RTramchain_busy\n"); |
|
|
|
return; |
|
|
|
} |
|
|
|
if ( rmdarray == 0 ) |
|
|
|
rmdarray = iguana_walletrmds(myinfo,coin,&numrmds), flag++; |
|
|
|
addrtypes = &rmdarray[numrmds * 20], pubkeys = &rmdarray[numrmds * 21]; |
|
|
@ -321,27 +346,6 @@ void iguana_unspents(struct supernet_info *myinfo,struct iguana_info *coin,cJSON |
|
|
|
free(rmdarray); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t *iguana_rmdarray(struct iguana_info *coin,int32_t *numrmdsp,cJSON *array,int32_t firsti) |
|
|
|
{ |
|
|
|
int32_t i,n,j=0; char *coinaddr; uint8_t *addrtypes,*rmdarray = 0; |
|
|
|
*numrmdsp = 0; |
|
|
|
if ( array != 0 && (n= cJSON_GetArraySize(array)) > 0 ) |
|
|
|
{ |
|
|
|
*numrmdsp = n - firsti; |
|
|
|
rmdarray = calloc(1,(n-firsti) * 21); |
|
|
|
addrtypes = &rmdarray[(n-firsti) * 20]; |
|
|
|
for (i=firsti; i<n; i++) |
|
|
|
{ |
|
|
|
if ( (coinaddr= jstr(jitem(array,i),0)) != 0 ) |
|
|
|
{ |
|
|
|
bitcoin_addr2rmd160(&addrtypes[j],&rmdarray[20 * j],coinaddr); |
|
|
|
j++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return(rmdarray); |
|
|
|
} |
|
|
|
|
|
|
|
int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp) |
|
|
|
{ |
|
|
|
static uint64_t total,emitted; |
|
|
@ -1120,9 +1124,10 @@ int32_t iguana_balanceflush(struct iguana_info *coin,int32_t refhdrsi,int32_t pu |
|
|
|
printf("error mapping bundle.[%d]\n",hdrsi); |
|
|
|
} |
|
|
|
char str[65]; printf("BALANCES WRITTEN for %d bundles %s\n",coin->balanceswritten,bits256_str(str,coin->balancehash)); |
|
|
|
exit(-1); |
|
|
|
coin->balanceswritten = iguana_volatileinit(coin); |
|
|
|
iguana_RTramchainfree(coin); |
|
|
|
iguana_coinpurge(coin); |
|
|
|
//exit(-1);
|
|
|
|
//coin->balanceswritten = iguana_volatileinit(coin);
|
|
|
|
//iguana_RTramchainfree(coin);
|
|
|
|
return(coin->balanceswritten); |
|
|
|
} |
|
|
|
|
|
|
|