Browse Source

test

etomic
jl777 8 years ago
parent
commit
23febb4ffe
  1. 2
      basilisk/basilisk.c
  2. 6
      basilisk/basilisk_DEX.c
  3. 2
      basilisk/basilisk_bitcoin.c
  4. 2
      basilisk/basilisk_tradebot.c
  5. 2
      iguana/dPoW.h
  6. 2
      iguana/dpow/dpow_network.c
  7. 2
      iguana/dpow/dpow_prices.c
  8. 28
      iguana/dpow/dpow_rpc.c
  9. 26
      iguana/iguana777.c
  10. 2
      iguana/iguana_init.c
  11. 7
      iguana/iguana_payments.c
  12. 5
      iguana/iguana_unspents.c
  13. 13
      iguana/iguana_wallet.c
  14. 1
      includes/iguana_structs.h

2
basilisk/basilisk.c

@ -954,7 +954,7 @@ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr)
timeoutmillis = BASILISK_TIMEOUT;
if ( coin != 0 )
{
if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 )
if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 || coin->notarychain >= 0 )
{
if ( (ptr= basilisk_bitcoinbalances(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 )
{

6
basilisk/basilisk_DEX.c

@ -502,21 +502,25 @@ THREE_STRINGS_AND_DOUBLE(tradebot,aveprice,comment,base,rel,basevolume)
ZERO_ARGS(InstantDEX,allcoins)
{
struct iguana_info *tmp; cJSON *basilisk,*virtual,*full,*retjson = cJSON_CreateObject();
struct iguana_info *tmp; cJSON *notarychains,*basilisk,*virtual,*full,*retjson = cJSON_CreateObject();
full = cJSON_CreateArray();
basilisk = cJSON_CreateArray();
virtual = cJSON_CreateArray();
notarychains = cJSON_CreateArray();
HASH_ITER(hh,myinfo->allcoins,coin,tmp)
{
if ( coin->virtualchain != 0 )
jaddistr(virtual,coin->symbol);
if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 )
jaddistr(full,coin->symbol);
else if ( coin->notarychain >= 0 )
jaddistr(notarychains,coin->symbol);
else jaddistr(basilisk,coin->symbol);
}
jadd(retjson,"basilisk",basilisk);
jadd(retjson,"full",full);
jadd(retjson,"virtual",virtual);
jadd(retjson,"notarychains",notarychains);
return(jprint(retjson,1));
}

2
basilisk/basilisk_bitcoin.c

@ -447,7 +447,7 @@ void *basilisk_getinfo(struct basilisk_item *Lptr,struct supernet_info *myinfo,s
return(clonestr("{\"error\":\"null valsobj\"}"));
if ( (myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0) && strcmp(coin->symbol,"RELAY") != 0 )
return(0);
if ( coin->VALIDATENODE > 0 || coin->FULLNODE > 0 )
if ( coin->VALIDATENODE > 0 || coin->FULLNODE > 0 || coin->notarychain >= 0 )
{
infojson = iguana_getinfo(myinfo,coin);
Lptr->retstr = jprint(infojson,1);

2
basilisk/basilisk_tradebot.c

@ -410,7 +410,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk
}
} else noquoteflag++;
}
printf("%s -> %s myrequest.%d pendingid.%u noquoteflag.%d havequoteflag.%d maxi.%d %.8f\n",list[0].src,list[0].dest,myrequest,pendingid,noquoteflag,havequoteflag,maxi,dstr(maxamount));
//printf("%s -> %s myrequest.%d pendingid.%u noquoteflag.%d havequoteflag.%d maxi.%d %.8f\n",list[0].src,list[0].dest,myrequest,pendingid,noquoteflag,havequoteflag,maxi,dstr(maxamount));
double retvals[4],refprice,profitmargin,aveprice; 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. )
{

2
iguana/dPoW.h

@ -154,7 +154,7 @@ bits256 dpow_getblockhash(struct supernet_info *myinfo,struct iguana_info *coin,
bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *coin);
char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx);
cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout);
char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address);
char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address,int32_t forceflag);
char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address);
cJSON *dpow_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
cJSON *dpow_listtransactions(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip);

2
iguana/dpow/dpow_network.c

@ -270,7 +270,7 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d
}
else if ( dexreq.func == 'A' )
{
retstr = dpow_importaddress(myinfo,coin,(char *)&dexp->packet[datalen]);
retstr = dpow_importaddress(myinfo,coin,(char *)&dexp->packet[datalen],0);
*broadcastflagp = 1;
if ( retstr == 0 )
retstr = dpow_validateaddress(myinfo,coin,(char *)&dexp->packet[datalen]);

2
iguana/dpow/dpow_prices.c

@ -1462,7 +1462,7 @@ void PAX_update(struct PAX_data *dp,double *btcusdp,double *kmdbtcp)
}
else
{
for (iter=0; iter<2; iter++)
for (iter=1; iter<2; iter++)
{
kmdhist = url_json(iter == 0 ? url : url2);
//{"date":1406160000,"high":0.01,"low":0.00125,"open":0.01,"close":0.001375,"volume":1.50179994,"quoteVolume":903.58818412,"weightedAverage":0.00166204},

28
iguana/dpow/dpow_rpc.c

@ -434,7 +434,7 @@ char *dpow_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin)
return(retstr);
}
char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address)
char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address,int32_t forceflag)
{
char buf[1024],*retstr,*alladdresses,*outstr,fname[1024]; cJSON *alljson; int32_t i,n; FILE *fp;
if ( coin->FULLNODE < 0 )
@ -447,21 +447,27 @@ char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,c
{
if ( is_cJSON_Array(alljson) != 0 && (n= cJSON_GetArraySize(alljson)) > 0 )
{
for (i=0; i<n; i++)
if ( strcmp(address,jstri(alljson,i)) == 0 )
break;
if ( forceflag == 0 )
{
for (i=0; i<n; i++)
if ( strcmp(address,jstri(alljson,i)) == 0 )
break;
} else i = n = 0;
if ( i == n )
{
jaddistr(alljson,address);
outstr = jprint(alljson,0);
sprintf(fname,"%s/alladdresses.%s",GLOBAL_CONFSDIR,coin->symbol), OS_compatible_path(fname);
if ( (fp= fopen(fname,"wb")) != 0 )
if ( forceflag == 0 )
{
fwrite(outstr,1,strlen(outstr)+1,fp);
fclose(fp);
printf("importaddress.(%s) -> alladdresses.%s\n",address,coin->symbol);
outstr = jprint(alljson,0);
sprintf(fname,"%s/alladdresses.%s",GLOBAL_CONFSDIR,coin->symbol), OS_compatible_path(fname);
if ( (fp= fopen(fname,"wb")) != 0 )
{
fwrite(outstr,1,strlen(outstr)+1,fp);
fclose(fp);
printf("importaddress.(%s) -> alladdresses.%s\n",address,coin->symbol);
}
free(outstr);
}
free(outstr);
}
}
free_json(alljson);

26
iguana/iguana777.c

@ -839,7 +839,10 @@ void iguana_helper(void *arg)
void iguana_callcoinstart(struct supernet_info *myinfo,struct iguana_info *coin)
{
struct iguana_bundle *bp; struct iguana_peer *addr; int32_t bundlei; bits256 zero; char dirname[512],*symbol;
char NOTARYCHAINS[][16] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", // major currencies
"CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK",
"KMD", "BTC", "REVS", "SUPERNET", "DEX", "PANGEA", "JUMBLR", "BET", "CRYPTO", "HODL", "SHARK", "BOTS", "MGW" };
struct iguana_bundle *bp; struct iguana_peer *addr; int32_t i,bundlei; bits256 zero; char dirname[512],*symbol;
iguana_rwiAddrind(coin,0,0,0);
//for (i=0; i<sizeof(*coin->chain); i++)
// printf("%02x",((uint8_t *)coin->chain)[i]);
@ -869,10 +872,23 @@ void iguana_callcoinstart(struct supernet_info *myinfo,struct iguana_info *coin)
memset(zero.bytes,0,sizeof(zero));
if ( (bp= iguana_bundlecreate(coin,&bundlei,0,*(bits256 *)coin->chain->genesis_hashdata,zero,1)) != 0 )
bp->bundleheight = 0;
if ( coin->FULLNODE == 0 )
{
coin->notarychain = -1;
for (i=0; i<sizeof(NOTARYCHAINS)/sizeof(*NOTARYCHAINS); i++)
if ( strcmp(coin->symbol,NOTARYCHAINS[i]) == 0 )
{
coin->notarychain = i;
break;
}
}
addr = &coin->peers->active[IGUANA_MAXPEERS-2];
iguana_initpeer(coin,addr,(uint32_t)calc_ipbits(coin->seedipaddr));
printf("SEED_IPADDR initpeer.(%s)\n",addr->ipaddr);
iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD);
printf("SEED_IPADDR initpeer.(%s) notarychain.%d\n",addr->ipaddr,coin->notarychain);
if ( coin->notarychain < 0 )
{
iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD);
}
}
void iguana_coinloop(void *arg)
@ -890,7 +906,7 @@ void iguana_coinloop(void *arg)
if ( is_cJSON_Array(alljson) != 0 && (n= cJSON_GetArraySize(alljson)) > 0 )
{
for (i=0; i<n; i++)
if ( (retstr= dpow_importaddress(myinfo,coin,jstri(alljson,i))) != 0 )
if ( (retstr= dpow_importaddress(myinfo,coin,jstri(alljson,i),i<n-1)) != 0 )
free(retstr);
}
free_json(alljson);
@ -905,7 +921,7 @@ void iguana_coinloop(void *arg)
{
if ( (coin= coins[i]) != 0 )
{
if ( coin->FULLNODE < 0 )
if ( coin->FULLNODE < 0 || coin->notarychain >= 0 )
continue;
/*if ( strcmp(coin->symbol,"RELAY") == 0 )
{

2
iguana/iguana_init.c

@ -564,6 +564,8 @@ struct iguana_info *iguana_coinstart(struct supernet_info *myinfo,struct iguana_
}
}
}
if ( coin->notarychain >= 0 )
return(coin);
//coin->firstblock = coin->blocks.parsedblocks + 1;
iguana_genesis(myinfo,coin,coin->chain);
int32_t bundlei = -2;

7
iguana/iguana_payments.c

@ -293,9 +293,12 @@ bits256 iguana_sendrawtransaction(struct supernet_info *myinfo,struct iguana_inf
serialized = calloc(1,sizeof(struct iguana_msghdr) + len);
decode_hex(&serialized[sizeof(struct iguana_msghdr)],len,signedtx);
txid = bits256_doublesha256(0,&serialized[sizeof(struct iguana_msghdr)],len);
if ( coin->FULLNODE < 0 )
if ( coin->FULLNODE < 0 || coin->notarychain >= 0 )
{
if ( (str= dpow_sendrawtransaction(myinfo,coin,signedtx)) != 0 )
if ( coin->FULLNODE < 0 || coin->notarychain >= 0 )
str = dpow_sendrawtransaction(myinfo,coin,signedtx);
else str = _dex_sendrawtransaction(myinfo,coin->symbol,signedtx);
if ( str != 0 )
{
if ( is_hexstr(str,0) == sizeof(checktxid)*2 )
{

5
iguana/iguana_unspents.c

@ -585,6 +585,7 @@ int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info *
return(deposits - spent);
}
// jl777: todo support notarychain iterate listunspent
int32_t iguana_RTpkhasharray(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,uint64_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 includespent)
{
int32_t i,n,m,numunspents; uint64_t spent,deposits,netbalance,total; struct iguana_outpoint lastpt; struct iguana_pkhash *p,_p; struct iguana_ramchain *ramchain; struct iguana_bundle *bp;
@ -1071,7 +1072,7 @@ int32_t iguana_unspentfindjson(cJSON *destarray,cJSON *item)
cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *argarray,int32_t minconf,int32_t maxconf,char *remoteaddr,int32_t includespends)
{
uint64_t total = 0; int32_t i,j,m,n,numrmds,numunspents=0; char *coinaddr,*retstr; uint8_t *rmdarray; cJSON *vals,*unspents,*item,*array,*retjson,*retarray; bits256 hash;
if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 )
if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 || coin->notarychain >= 0 )
{
retjson = cJSON_CreateArray();
rmdarray = iguana_rmdarray(myinfo,coin,&numrmds,argarray,0);
@ -1168,7 +1169,7 @@ int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *
}
memset(pubkey,0,sizeof(pubkey));
//remains = required * 1.1 + coin->txfee;
if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 )
if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 || coin->notarychain >= 0 )
{
for (i=numunspents=0; i<numaddrs; i++)
{

13
iguana/iguana_wallet.c

@ -1098,9 +1098,18 @@ double _max100(double val)
cJSON *iguana_getinfo(struct supernet_info *myinfo,struct iguana_info *coin)
{
int32_t i; struct iguana_peer *addr; cJSON *array,*retjson = cJSON_CreateObject();
int32_t i; char *retstr; struct iguana_peer *addr; cJSON *array,*retjson = cJSON_CreateObject();
if ( coin != 0 )
{
if ( coin->notarychain >= 0 )
{
if ( (retstr= _dex_getinfo(myinfo,coin->symbol)) != 0 )
{
retjson = cJSON_Parse(retstr);
free(retstr);
return(retjson);
} else return(cJSON_Parse("{\"error\":\"null return\"}"));
}
jaddstr(retjson,"result","success");
jaddnum(retjson,"protocolversion",PROTOCOL_VERSION);
jaddnum(retjson,"kbfee",dstr(coin->txfee_perkb));
@ -1146,7 +1155,7 @@ ZERO_ARGS(bitcoinrpc,getinfo)
struct basilisk_item Lptr,*ptr; int32_t incr,i,j,m,n,longest; cJSON *valsobj,*getinfoobj=0,*array,*item,*fullnodes;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 )
if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 || coin->notarychain >= 0 )
return(jprint(iguana_getinfo(myinfo,coin),1));
else
{

1
includes/iguana_structs.h

@ -517,6 +517,7 @@ struct iguana_info
char lastdispstr[2048];
double txidfind_totalmillis,txidfind_num,spendtxid_totalmillis,spendtxid_num;
struct iguana_monitorinfo monitoring[256];
int32_t notarychain;
struct datachain_info dPoW;
struct iguana_zblock newblock; char *newblockstr;
int32_t relay_RTheights[BASILISK_MAXRELAYS];

Loading…
Cancel
Save