Browse Source

Merge branch 'master' into release/v0.1

release/v0.1
jl777 8 years ago
parent
commit
cf7f9c1306
  1. 79
      basilisk/basilisk.c
  2. 2
      basilisk/basilisk.h
  3. 27
      basilisk/basilisk_DEX.c
  4. 108
      basilisk/basilisk_tradebot.c
  5. 3
      crypto777/OS_portable.h
  6. 4
      crypto777/bitcoind_RPC.c
  7. 2
      iguana/coins/genbtc
  8. 4
      iguana/iguana_payments.c
  9. 2
      iguana/iguana_ramchain.c
  10. 71
      iguana/iguana_unspents.c
  11. 1
      iguana/iguana_wallet.c
  12. 2
      includes/iguana_funcs.h
  13. 3
      includes/iguana_structs.h

79
basilisk/basilisk.c

@ -742,9 +742,8 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
{
if ( strcmp((char *)basilisk_services[i][0],type) == 0 )
{
if ( coin->FULLNODE != 0 || myinfo->NOTARY.RELAYID >= 0 ) // iguana node
if ( (coin != 0 && coin->FULLNODE != 0) || myinfo->NOTARY.RELAYID >= 0 ) // iguana node
{
//printf("FULL.%d RELAYID.%d NUMRELAYS.%d services %s\n",coin->FULLNODE,RELAYID,NUMRELAYS,type);
if ( (retstr= (*basilisk_services[i][1])(myinfo,type,addr,remoteaddr,basilisktag,valsobj,data,datalen,hash,from_basilisk)) != 0 )
{
//printf("from_basilisk.%d ret.(%s)\n",from_basilisk,retstr);
@ -800,13 +799,87 @@ void basilisk_p2p(void *_myinfo,void *_addr,char *senderip,uint8_t *data,int32_t
free(ptr);
}
double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk_request *issueR,struct basilisk_request *list,int32_t n)
{
int32_t i,noquoteflag=0,havequoteflag=0,myrequest=0,maxi=-1; uint64_t destamount,minamount = 0,maxamount = 0; uint32_t pendingid=0; struct basilisk_swap *active; double metric = 0.;
memset(issueR,0,sizeof(*issueR));
minamount = list[0].minamount;
//printf("need to verify null quoteid is list[0] requestid.%u quoteid.%u\n",list[0].requestid,list[0].quoteid);
if ( (active= basilisk_request_started(myinfo,list[0].requestid)) != 0 )
pendingid = active->req.quoteid;
if ( bits256_cmp(myinfo->myaddr.persistent,list[0].srchash) == 0 ) // my request
myrequest = 1;
for (i=0; i<n; i++)
{
if ( basilisk_request_cmpref(&list[0],&list[i]) != 0 )
return(-1);
if ( list[i].quoteid != 0 )
{
if ( bits256_cmp(myinfo->myaddr.persistent,list[i].desthash) == 0 ) // my quoteid
myrequest |= 2;
havequoteflag++;
if ( pendingid == 0 )
{
if ( list[i].destamount > maxamount )
{
maxamount = list[i].destamount;
maxi = i;
}
}
else if ( active != 0 && pendingid == list[i].quoteid )
{
}
} else noquoteflag++;
}
printf("myrequest.%d pendingid.%u noquoteflag.%d havequoteflag.%d maxi.%d %.8f\n",myrequest,pendingid,noquoteflag,havequoteflag,maxi,dstr(maxamount));
double retvals[4],refprice,profitmargin,aveprice,balance=0.; cJSON *retjson; char *retstr;
if ( myinfo->IAMLP != 0 && myrequest == 0 && pendingid == 0 && noquoteflag != 0 && (profitmargin= tradebot_liquidity_active(myinfo,&refprice,list[0].src,list[0].dest)) > 0. )
{
if ( (aveprice= instantdex_avehbla(myinfo,retvals,list[0].src,list[0].dest,1.3 * dstr(list[0].srcamount))) == 0. || refprice > aveprice )
aveprice = refprice;
if ( fabs(aveprice) < SMALLVAL )
return(0);
destamount = (1.0 - profitmargin) * aveprice * list[0].srcamount;
if ( (retstr= InstantDEX_available(myinfo,iguana_coinfind(list[0].dest),0,0,list[0].dest)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
balance = jdouble(retjson,"result");
free_json(retjson);
}
free(retstr);
}
printf("balance %.8f destamount %.8f aveprice %.8f minamount %.8f\n",balance,dstr(destamount),aveprice,dstr(minamount));
if ( balance > destamount && destamount > 0 && destamount >= maxamount && destamount >= minamount )
{
metric = 1.;
*issueR = list[0];
issueR->desthash = myinfo->myaddr.persistent;
issueR->destamount = destamount;
issueR->quotetime = (uint32_t)time(NULL);
}
}
else if ( myrequest != 0 && pendingid == 0 && maxi >= 0 ) // automatch best quote
{
if ( minamount != 0 && maxamount > minamount && time(NULL) > BASILISK_DEXDURATION/2 )
{
printf("automatch quoteid.%u triggered %.8f > %.8f\n",list[maxi].quoteid,dstr(maxamount),dstr(minamount));
*issueR = list[maxi];
if ( minamount > 0 )
metric = (dstr(maxamount) / dstr(minamount)) - 1.;
else metric = 1.;
}
}
return(metric);
}
void basilisk_requests_poll(struct supernet_info *myinfo)
{
char *retstr; cJSON *outerarray,*retjson; int32_t i,n; struct basilisk_request issueR; double hwm = 0.;
memset(&issueR,0,sizeof(issueR));
if ( (retstr= InstantDEX_incoming(myinfo,0,0,0,0)) != 0 )
{
printf("poll.(%s)\n",retstr);
//printf("poll.(%s)\n",retstr);
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( (outerarray= jarray(&n,retjson,"responses")) != 0 )

2
basilisk/basilisk.h

@ -120,5 +120,7 @@ struct iguana_info *basilisk_geckochain(struct supernet_info *myinfo,char *symbo
void basilisk_alicepayment(struct supernet_info *myinfo,struct iguana_info *coin,struct basilisk_rawtx *alicepayment,bits256 pubAm,bits256 pubBn);
void basilisk_rawtx_setparms(char *name,struct supernet_info *myinfo,struct basilisk_swap *swap,struct basilisk_rawtx *rawtx,struct iguana_info *coin,int32_t numconfirms,int32_t vintype,uint64_t satoshis,int32_t vouttype,uint8_t *pubkey33);
void basilisk_setmyid(struct supernet_info *myinfo);
int32_t basilisk_rwDEXquote(int32_t rwflag,uint8_t *serialized,struct basilisk_request *rp);
cJSON *basilisk_requestjson(struct basilisk_request *rp);
#endif

27
basilisk/basilisk_DEX.c

@ -100,7 +100,7 @@ int32_t basilisk_rwDEXquote(int32_t rwflag,uint8_t *serialized,struct basilisk_r
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->timestamp),&rp->timestamp); // must be 2nd
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->quoteid),&rp->quoteid);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->quotetime),&rp->quotetime);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->relaybits),&rp->relaybits);
//len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->relaybits),&rp->relaybits);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->srcamount),&rp->srcamount);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->minamount),&rp->minamount);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(rp->srchash),rp->srchash.bytes);
@ -142,12 +142,12 @@ uint32_t basilisk_request_enqueue(struct supernet_info *myinfo,struct basilisk_r
cJSON *basilisk_requestjson(struct basilisk_request *rp)
{
char ipaddr[64]; cJSON *item = cJSON_CreateObject();
if ( rp->relaybits != 0 )
cJSON *item = cJSON_CreateObject();
/*if ( rp->relaybits != 0 )
{
expand_ipbits(ipaddr,rp->relaybits);
jaddstr(item,"relay",ipaddr);
}
}*/
jaddbits256(item,"srchash",rp->srchash);
if ( bits256_nonz(rp->desthash) != 0 )
jaddbits256(item,"desthash",rp->desthash);
@ -209,6 +209,8 @@ int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits2
rp->srchash = jbits256(valsobj,"srchash");
strncpy(rp->src,src,sizeof(rp->src)-1);
strncpy(rp->dest,dest,sizeof(rp->dest)-1);
//if ( jstr(valsobj,"relay") != 0 )
// rp->relaybits = (uint32_t)calc_ipbits(jstr(valsobj,"relay"));
rp->requestid = basilisk_requestid(rp);
if ( rp->destamount != 0 && bits256_nonz(rp->desthash) != 0 )
{
@ -302,7 +304,7 @@ struct basilisk_request *_basilisk_requests_uniq(struct supernet_info *myinfo,in
break;
if ( k == m )
{
requests[m].relaybits = relay->ipbits;
//requests[m].relaybits = relay->ipbits;
requests[m++] = *rp;
}
}
@ -415,8 +417,11 @@ STRING_ARG(InstantDEX,available,source)
{
if ( myinfo->expiration != 0 )
return(bitcoinrpc_getbalance(myinfo,coin,json,remoteaddr,"*",coin->chain->minconfirms,1,1<<30));
else return(clonestr("{\"error\":\"need to unlock wallet\"}"));
} else return(clonestr("{\"error\":\"specified coin is not active\"}"));
printf("InstantDEX_available: need to unlock wallet\n");
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
}
printf("InstantDEX_available: %s is not active\n",source!=0?source:"");
return(clonestr("{\"error\":\"specified coin is not active\"}"));
}
HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr)
@ -438,12 +443,14 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr)
if ( basilisk_request_create(&R,vals,hash,juint(vals,"timestamp")) == 0 )
{
printf("R.requestid.%u vs calc %u, q.%u\n",R.requestid,basilisk_requestid(&R),R.quoteid);
if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 )
R.relaybits = myinfo->myaddr.myipbits;
//if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 )
// R.relaybits = myinfo->myaddr.myipbits;
if ( (reqjson= basilisk_requestjson(&R)) != 0 )
free_json(reqjson);
datalen = basilisk_rwDEXquote(1,serialized,&R);
printf("R.requestid.%u vs calc %u, q.%u datalen.%d\n",R.requestid,basilisk_requestid(&R),R.quoteid,datalen);
int32_t i; for (i=0; i<sizeof(R); i++)
printf("%02x",((uint8_t *)&R)[i]);
printf(" R.requestid.%u vs calc %u, q.%u datalen.%d\n",R.requestid,basilisk_requestid(&R),R.quoteid,datalen);
basilisk_rwDEXquote(0,serialized,&R);
} else printf("error creating request\n");
}

108
basilisk/basilisk_tradebot.c

@ -21,7 +21,7 @@ uint32_t basilisk_requestid(struct basilisk_request *rp)
R = *rp;
R.requestid = R.quoteid = R.quotetime = 0;
R.destamount = 0;
R.relaybits = 0;
//R.relaybits = 0;
memset(R.desthash.bytes,0,sizeof(R.desthash.bytes));
if ( 0 )
{
@ -38,7 +38,7 @@ uint32_t basilisk_quoteid(struct basilisk_request *rp)
{
struct basilisk_request R;
R = *rp;
R.requestid = R.quoteid = R.relaybits = 0;
R.requestid = R.quoteid = 0; //R.relaybits =
return(calc_crc32(0,(void *)&R,sizeof(R)));
}
@ -53,8 +53,8 @@ struct basilisk_request *basilisk_parsejson(struct basilisk_request *rp,cJSON *r
rp->destamount = j64bits(reqjson,"destamount");
requestid = juint(reqjson,"requestid");
quoteid = juint(reqjson,"quoteid");
if ( jstr(reqjson,"relay") != 0 )
rp->relaybits = (uint32_t)calc_ipbits(jstr(reqjson,"relay"));
//if ( jstr(reqjson,"relay") != 0 )
// rp->relaybits = (uint32_t)calc_ipbits(jstr(reqjson,"relay"));
rp->timestamp = juint(reqjson,"timestamp");
rp->quotetime = juint(reqjson,"quotetime");
safecopy(rp->src,jstr(reqjson,"src"),sizeof(rp->src));
@ -67,7 +67,11 @@ struct basilisk_request *basilisk_parsejson(struct basilisk_request *rp,cJSON *r
}
rp->requestid = basilisk_requestid(rp);
if ( requestid != rp->requestid )
printf("basilisk_parsejson requestid.%u != %u error\n",requestid,rp->requestid);
{
int32_t i; for (i=0; i<sizeof(*rp); i++)
printf("%02x",((uint8_t *)rp)[i]);
printf(" basilisk_parsejson.(%s) requestid.%u != %u error\n",jprint(reqjson,0),requestid,rp->requestid);
}
return(rp);
}
@ -154,95 +158,28 @@ double tradebot_liquidity_active(struct supernet_info *myinfo,double *refpricep,
return(0.);
}
double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk_request *issueR,struct basilisk_request *list,int32_t n)
{
int32_t i,noquoteflag=0,havequoteflag=0,myrequest=0,maxi=-1; uint64_t destamount,minamount = 0,maxamount = 0; uint32_t pendingid=0; struct basilisk_swap *active; double metric = 0.;
memset(issueR,0,sizeof(*issueR));
minamount = list[0].minamount;
printf("need to verify null quoteid is list[0] requestid.%u quoteid.%u\n",list[0].requestid,list[0].quoteid);
if ( (active= basilisk_request_started(myinfo,list[0].requestid)) != 0 )
pendingid = active->req.quoteid;
if ( bits256_cmp(myinfo->myaddr.persistent,list[0].srchash) == 0 ) // my request
myrequest = 1;
for (i=0; i<n; i++)
{
if ( basilisk_request_cmpref(&list[0],&list[i]) != 0 )
return(-1);
if ( list[i].quoteid != 0 )
{
if ( bits256_cmp(myinfo->myaddr.persistent,list[i].desthash) == 0 ) // my quoteid
myrequest |= 2;
havequoteflag++;
if ( pendingid == 0 )
{
if ( list[i].destamount > maxamount )
{
maxamount = list[i].destamount;
maxi = i;
}
}
else if ( active != 0 && pendingid == list[i].quoteid )
{
}
} else noquoteflag++;
}
printf("myrequest.%d pendingid.%u noquoteflag.%d havequoteflag.%d maxi.%d %.8f\n",myrequest,pendingid,noquoteflag,havequoteflag,maxi,dstr(maxamount));
double retvals[4],refprice,profitmargin,aveprice,balance=0.; cJSON *retjson; char *retstr;
if ( myinfo->IAMLP != 0 && myrequest == 0 && pendingid == 0 && noquoteflag != 0 && (profitmargin= tradebot_liquidity_active(myinfo,&refprice,list[0].src,list[0].dest)) > 0. )
{
if ( (aveprice= instantdex_avehbla(myinfo,retvals,list[0].src,list[0].dest,1.3 * dstr(list[0].srcamount))) == 0. || refprice > aveprice )
aveprice = refprice;
if ( fabs(aveprice) < SMALLVAL )
return(0);
destamount = (1.0 - profitmargin) * aveprice * list[0].srcamount;
if ( (retstr= InstantDEX_available(myinfo,iguana_coinfind(list[0].dest),0,0,list[0].dest)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
balance = jdouble(retjson,"result");
free_json(retjson);
}
free(retstr);
}
printf("balance %.8f destamount %.8f aveprice %.8f minamount %.8f\n",balance,dstr(destamount),aveprice,dstr(minamount));
if ( balance > destamount && destamount > 0 && destamount >= maxamount && destamount >= minamount )
{
metric = 1.;
*issueR = list[0];
issueR->desthash = myinfo->myaddr.persistent;
issueR->destamount = destamount;
issueR->quotetime = (uint32_t)time(NULL);
}
}
else if ( myrequest != 0 && pendingid == 0 && maxi >= 0 ) // automatch best quote
{
if ( minamount != 0 && maxamount > minamount && time(NULL) > BASILISK_DEXDURATION/2 )
{
printf("automatch quoteid.%u triggered %.8f > %.8f\n",list[maxi].quoteid,dstr(maxamount),dstr(minamount));
*issueR = list[maxi];
if ( minamount > 0 )
metric = (dstr(maxamount) / dstr(minamount)) - 1.;
else metric = 1.;
}
}
return(metric);
}
double basilisk_process_results(struct supernet_info *myinfo,struct basilisk_request *issueR,cJSON *retjson,double hwm)
{
cJSON *array,*item; int32_t i,n,m,nonz; struct basilisk_request tmpR,R,refR,list[BASILISK_MAXRELAYS]; double metric=0.;
cJSON *array,*item; uint8_t *hexdata,*allocptr,hexspace[8192]; char *hexstr; int32_t i,hexlen,n,m,nonz; struct basilisk_request tmpR,R,refR,list[BASILISK_MAXRELAYS]; double metric=0.;
memset(&refR,0,sizeof(refR));
printf("process.(%s)\n",jprint(retjson,0));
//printf("process.(%s)\n",jprint(retjson,0));
if ( (array= jarray(&n,retjson,"messages")) != 0 )
{
for (i=nonz=m=0; i<n; i++)
{
item = jitem(array,i);
if ( jobj(item,"error") != 0 )
if ( jobj(item,"error") == 0 )
{
if ( (hexstr= jstr(item,"data")) != 0 )
{
if ( (hexdata= get_dataptr(0,&allocptr,&hexlen,hexspace,sizeof(hexspace),hexstr)) != 0 )
{
basilisk_rwDEXquote(0,hexdata,&R);
//printf("[%d].(%s)\n",i,jprint(basilisk_requestjson(&R),1));
}
} else basilisk_parsejson(&R,item);
if ( nonz != 0 )
{
basilisk_parsejson(&R,item);
if ( refR.requestid == R.requestid )
list[m++] = R;
else
@ -258,7 +195,10 @@ printf("process.(%s)\n",jprint(retjson,0));
}
nonz++;
if ( m < sizeof(list)/sizeof(*list) )
basilisk_parsejson(&list[m++],item);
{
//basilisk_parsejson(&list[m++],item);
list[m++] = R;
}
}
}
//printf("process_results n.%d m.%d nonz.%d\n",n,m,nonz);

3
crypto777/OS_portable.h

@ -17,6 +17,9 @@
// iguana_OS has functions that invoke system calls. Whenever possible stdio and similar functions are use and most functions are fully portable and in this file. For things that require OS specific, the call is routed to iguana_OS_portable_* Usually, all but one OS can be handled with the same code, so iguana_OS_portable.c has most of this shared logic and an #ifdef iguana_OS_nonportable.c
#ifdef __APPLE__
#define LIQUIDITY_PROVIDER 1
#endif
#ifdef NATIVE_WINDOWS
//#define uint64_t unsigned __int64

4
crypto777/bitcoind_RPC.c

@ -15,10 +15,6 @@
#include "OS_portable.h"
#ifdef __APPLE__
#define LIQUIDITY_PROVIDER 1
#endif
#if LIQUIDITY_PROVIDER
#ifdef _WIN32
#include <curl.h>

2
iguana/coins/genbtc

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333}"
curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333,\"minconfirms\":1}"

4
iguana/iguana_payments.c

@ -502,8 +502,10 @@ char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *
{
senttxid = iguana_sendrawtransaction(myinfo,coin,signedtx);
if ( bits256_cmp(senttxid,signedtxid) == 0 )
{
jaddstr(retjson,"sendrawtransaction","success");
else jaddbits256(retjson,"senderror",senttxid);
iguana_unspents_mark(myinfo,coin,vins);
} else jaddbits256(retjson,"senderror",senttxid);
}
free_json(vins);
free(signedtx);

2
iguana/iguana_ramchain.c

@ -2324,7 +2324,7 @@ struct iguana_ramchain *iguana_bundleload(struct supernet_info *myinfo,struct ig
}
if ( prev2 != 0 && prev != 0 && strcmp(coin->symbol,"BTCD") == 0 && bp->bundleheight > 20000 && prev != 0 && iguana_targetbits(coin,block,prev,prev2,1,coin->chain->targetspacing,coin->chain->targettimespan) != block->RO.bits )
{
printf("nbits target error %x != %x ht.%d\n",iguana_targetbits(coin,block,prev,prev2,1,coin->chain->targetspacing,coin->chain->targettimespan),block->RO.bits,block->height);
printf("warning: nbits target mismatch %x != %x ht.%d, this is normal during parallel sync\n",iguana_targetbits(coin,block,prev,prev2,1,coin->chain->targetspacing,coin->chain->targettimespan),block->RO.bits,block->height);
} //else printf(">>>>>>>>>> matched nbits %x ht.%d\n",block->RO.bits,block->height);
if ( bp->bundleheight+i == coin->blocks.hwmchain.height+1 )
{

71
iguana/iguana_unspents.c

@ -831,24 +831,65 @@ int32_t iguana_staker_sort(struct iguana_info *coin,bits256 *hash2p,uint8_t *ref
return((int32_t)sortbuf[1].uints[5]);
}
int32_t iguana_markedunspents_find(struct iguana_info *coin,int32_t *firstslotp,bits256 txid,int32_t vout)
{
int32_t i;
*firstslotp = -1;
if ( bits256_nonz(txid) != 0 && vout >= 0 )
{
txid.ushorts[0] = vout; // small chance of collision ok due to small timeframe
for (i=0; i<sizeof(coin->markedunspents)/sizeof(*coin->markedunspents); i++)
{
if ( *firstslotp < 0 && bits256_nonz(coin->markedunspents[i]) == 0 )
*firstslotp = i;
if ( bits256_cmp(txid,coin->markedunspents[i]) == 0 )
return(i);
}
}
if ( *firstslotp < 0 )
{
for (i=0; i<sizeof(coin->markedunspents)/sizeof(*coin->markedunspents); i++)
if ( bits256_nonz(coin->markedunspents[i]) == 0 )
{
*firstslotp = i;
break;
}
}
if ( *firstslotp < 0 )
*firstslotp = (rand() % (sizeof(coin->markedunspents)/sizeof(*coin->markedunspents)));
return(-1);
}
void iguana_unspents_mark(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins)
{
int32_t i,n,firstslot; int16_t vout; cJSON *item; bits256 txid;
if ( (n= cJSON_GetArraySize(vins)) > 0 )
{
for (i=0; i<n; i++)
{
item = jitem(vins,i);
txid = jbits256(item,"txid");
vout = jint(item,"vout");
if ( bits256_nonz(txid) != 0 && vout >= 0 )
{
if ( iguana_markedunspents_find(coin,&firstslot,txid,vout) < 0 )
{
if ( firstslot >= 0 )
{
char str[65]; printf("slot.[%d] <- %s/v%d\n",firstslot,bits256_str(str,txid),vout);
coin->markedunspents[firstslot] = txid;
}
}
}
}
}
}
int32_t iguana_RTunspent_check(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint outpt)
{
bits256 txid; int32_t vout,spentheight;
memset(&txid,0,sizeof(txid));
if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 )
return(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);
//return(iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,ramchain,outpt,height,minconf,coin->longestchain,U[unspentind].value));
/*if ( basilisk_addspend(myinfo,coin->symbol,txid,vout,0) != 0 )
{
char str[65]; printf("iguana_unspent_check found unspentind (%u %d) %s\n",outpt.hdrsi,outpt.unspentind,bits256_str(str,txid));
return(1);
} else return(0);*/
int32_t firstslot;
if ( iguana_markedunspents_find(coin,&firstslot,outpt.txid,outpt.vout) < 0 )
return(0);
}
printf("iguana_unspent_check: couldnt find (%d %d)\n",outpt.hdrsi,outpt.unspentind);
return(-1);
}

1
iguana/iguana_wallet.c

@ -1658,6 +1658,7 @@ STRING_AND_THREEINTS(bitcoinrpc,getbalance,account,minconf,includeempty,lastheig
if ( rmdarray != 0 )
free(rmdarray);
retjson = cJSON_CreateObject();
printf("%s balance %.8f\n",coin->symbol,dstr(balance));
jaddnum(retjson,"result",dstr(balance));
return(jprint(retjson,1));
}

2
includes/iguana_funcs.h

@ -451,6 +451,8 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc
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_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t *totalp,struct iguana_outpoint *unspents,int32_t max,uint64_t required,int32_t minconf,cJSON *addresses,char *remoteaddr);
double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk_request *issueR,struct basilisk_request *list,int32_t n);
void iguana_unspents_mark(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins);
int32_t iguana_immediate(struct iguana_info *coin,int32_t immedmillis);
int32_t iguana_fastfindreset(struct iguana_info *coin);
int64_t iguana_unspentset(struct supernet_info *myinfo,struct iguana_info *coin);

3
includes/iguana_structs.h

@ -506,6 +506,7 @@ struct iguana_info
uint64_t histbalance,RTcredits,RTdebits;
void *utxoaddrfileptr; long utxoaddrfilesize;
uint32_t utxoaddrlastcount,*utxoaddroffsets,lastunspentsupdate; uint8_t *utxoaddrtable; bits256 utxoaddrhash;
bits256 markedunspents[1024];
struct iguana_block *RTblocks[65536]; uint8_t *RTrawdata[65536]; int32_t RTrecvlens[65536],RTnumtx[65536];
struct iguana_RTtxid *RTdataset; struct iguana_RTaddr *RTaddrs;
};
@ -553,7 +554,7 @@ struct basilisk_request
char src[8],dest[8];
//char volatile_start,message[43];
uint64_t destamount;
uint32_t relaybits;
//uint32_t relaybits;
}; // __attribute__((packed))
struct basilisk_relaystatus

Loading…
Cancel
Save