Browse Source

test

etomic
jl777 8 years ago
parent
commit
9cfe8a792d
  1. 1
      iguana/dpow/dpow_network.c
  2. 2
      iguana/dpow/dpow_rpc.c
  3. 30
      iguana/iguana777.c
  4. 32
      iguana/iguana_init.c
  5. 2
      iguana/tests/basilisk
  6. 17
      iguana/tests/basilisks
  7. 2
      iguana/tests/dexalladdresses
  8. 4
      iguana/tests/deximportaddress
  9. 2
      iguana/tests/dexlistunspent

1
iguana/dpow/dpow_network.c

@ -274,6 +274,7 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d
*broadcastflagp = 1;
if ( retstr == 0 )
retstr = dpow_validateaddress(myinfo,coin,(char *)&dexp->packet[datalen]);
else printf("funcA.(%s)\n",retstr);
}
else if ( dexreq.func == 'V' )
{

2
iguana/dpow/dpow_rpc.c

@ -441,6 +441,7 @@ char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,c
{
sprintf(buf,"[\"%s\", \"%s\", false]",address,address);
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"importaddress",buf);
printf("importaddress.(%s) -> (%s)\n",address,retstr);
if ( (alladdresses= dpow_alladdresses(myinfo,coin)) != 0 )
{
if ( (alljson= cJSON_Parse(alladdresses)) != 0 )
@ -478,6 +479,7 @@ char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,c
{
sprintf(buf,"[\"%s\"]",address);
sprintf(fname,"%s/alladdresses.%s",GLOBAL_CONFSDIR,coin->symbol), OS_compatible_path(fname);
printf("first importaddress.(%s) -> %s\n",fname);
if ( (fp= fopen(fname,"wb")) != 0 )
{
fwrite(buf,1,strlen(buf)+1,fp);

30
iguana/iguana777.c

@ -837,23 +837,9 @@ void iguana_helper(void *arg)
}
}
/*
To add a new dPoW'ed assetchain with DEX* API support:
1. add to komodo/src: assetchains, dpowassets, fiat-cli
2. add to end of CURRENCIES[] array in fundnotaries (iguana_notary.c)
3. create fiat/<ac_name>
4. add to NOTARYCHAINS[] array in iguana_callcoinstart
5. add to m_notary coins/<ac_name> get gen_acname from where komodod was launched, change RELAY:-1 and port to 7776 and make <ac_name>_7776 variant
6. launch from a single node with -gen, launch a second node using -addnode=<ipaddr of 1st node> but without -gen
7. from a single node, fundnotaries <ac_name> to get notaries able to dPoW
*/
void iguana_callcoinstart(struct supernet_info *myinfo,struct iguana_info *coin)
{
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", "MVP" };
struct iguana_bundle *bp; struct iguana_peer *addr; int32_t i,bundlei; bits256 zero; char dirname[512],*symbol;
struct iguana_bundle *bp; struct iguana_peer *addr; int32_t 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]);
@ -883,17 +869,8 @@ 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;
coin->notarychain = -1;
if ( coin->FULLNODE == 0 )
{
for (i=0; i<sizeof(NOTARYCHAINS)/sizeof(*NOTARYCHAINS); i++)
if ( strcmp(coin->symbol,NOTARYCHAINS[i]) == 0 )
{
printf("SET NOTARYCHAIN.%d\n",i);
coin->notarychain = i;
break;
}
}
if ( coin->FULLNODE != 0 )
coin->notarychain = -1;
addr = &coin->peers->active[IGUANA_MAXPEERS-2];
iguana_initpeer(coin,addr,(uint32_t)calc_ipbits(coin->seedipaddr));
printf("SEED_IPADDR initpeer.(%s) notarychain.%d\n",addr->ipaddr,coin->notarychain);
@ -919,7 +896,6 @@ void iguana_coinloop(void *arg)
if ( coin->didaddresses == 0 )
{
coin->didaddresses = 1;
coin->notarychain = -1;
if ( myinfo->IAMNOTARY != 0 && (alladdresses= _dex_alladdresses(myinfo,coin->symbol)) != 0 )
{
if ( (alljson= cJSON_Parse(alladdresses)) != 0 )

32
iguana/iguana_init.c

@ -15,6 +15,16 @@
#include "iguana777.h"
/*
To add a new dPoW'ed assetchain with DEX* API support:
1. add to komodo/src: assetchains, dpowassets, fiat-cli
2. add to end of NOTARY_CURRENCIES[] array in fundnotaries (iguana_notary.c)
3. create fiat/<ac_name>
4. add to m_notary coins/<ac_name> get gen_acname from where komodod was launched, change RELAY:-1 and port to 7776 and make <ac_name>_7776 variant
5. launch from a single node with -gen, launch a second node using -addnode=<ipaddr of 1st node> but without -gen
6. from a single node, fundnotaries <ac_name> to get notaries able to dPoW
*/
void iguana_initQ(queue_t *Q,char *name)
{
struct stritem *tst,*item;
@ -74,6 +84,7 @@ void iguana_initcoin(struct iguana_info *coin,cJSON *argjson)
iguana_meminit(&coin->blockMEM,"blockMEM",coin->blockspace,coin->blockspacesize,0);
iguana_initQs(coin);
coin->bindsock = -1;
coin->notarychain = -1;
OS_randombytes((unsigned char *)&coin->instance_nonce,sizeof(coin->instance_nonce));
coin->startutc = (uint32_t)time(NULL);
while ( time(NULL) == coin->startutc )
@ -516,7 +527,7 @@ void iguana_coinpurge(struct iguana_info *coin)
struct iguana_info *iguana_coinstart(struct supernet_info *myinfo,struct iguana_info *coin,int32_t initialheight,int32_t mapflags)
{
FILE *fp; char fname[512],*symbol; int32_t j,iter; long fpos; bits256 lastbundle;
FILE *fp; char fname[512],*symbol,*jsonstr; cJSON *chains; int32_t j,i,n,iter; long fpos; bits256 lastbundle;
/*if ( coin->peers == 0 )
{
printf("cant start privatechain directly\n");
@ -564,6 +575,25 @@ struct iguana_info *iguana_coinstart(struct supernet_info *myinfo,struct iguana_
}
}
}
coin->notarychain = -1;
if ( (jsonstr= dpow_notarychains(0,0,0,0)) != 0 )
{
if ( (chains= cJSON_Parse(jsonstr)) != 0 )
{
if ( (n= cJSON_GetArraySize(chains)) > 0 )
{
for (i=0; i<n; i++)
if ( strcmp(coin->symbol,jstri(chains,i)) == 0 )
{
printf("SET %s NOTARYCHAIN.%d\n",coin->symbol,i);
coin->notarychain = i;
break;
}
}
free_json(chains);
}
free(jsonstr);
}
if ( coin->notarychain >= 0 )
return(coin);
//coin->firstblock = coin->blocks.parsedblocks + 1;

2
iguana/tests/basilisk

@ -1,2 +0,0 @@
#!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"basilisk\",\"method\":\"paxfiats\"}"

17
iguana/tests/basilisks

@ -0,0 +1,17 @@
#!/bin/bash
../coins/basilisk/bet
../coins/basilisk/btc
../coins/basilisk/dex
../coins/basilisk/jumblr
../coins/basilisk/mgw
../coins/basilisk/pangea
../coins/basilisk/shark
../coins/basilisk/bots
../coins/basilisk/crypto
../coins/basilisk/hodl
../coins/basilisk/kmd
../coins/basilisk/mvp
../coins/basilisk/revs
../coins/basilisk/supernet
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"basilisk\",\"method\":\"paxfiats\"}"

2
iguana/tests/dexalladdresses

@ -1,2 +1,4 @@
#!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"alladdresses\",\"symbol\":\"BTC\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"alladdresses\",\"symbol\":\"MVP\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"alladdresses\",\"symbol\":\"USD\"}"

4
iguana/tests/deximportaddress

@ -1,2 +1,4 @@
#!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"importaddress\",\"address\":\"15R3C2ZKmak5pCc4duLY2jLtFD3o1jaeNd\",\"symbol\":\"BTC\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"importaddress\",\"address\":\"1Hgzt5xsnbfc8UTWqWKSTLRm5bEYHYBoCE\",\"symbol\":\"BTC\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"importaddress\",\"address\":\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\",\"symbol\":\"USD\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"importaddress\",\"address\":\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\",\"symbol\":\"MVP\"}"

2
iguana/tests/dexlistunspent

@ -1,2 +1,2 @@
#!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"listunspent\",\"address\":\"1E2ac2gxeFR2ir1H3vqETTperWkiXkwy99\",\"symbol\":\"BTC\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"listunspent\",\"address\":\"1Hgzt5xsnbfc8UTWqWKSTLRm5bEYHYBoCE\",\"symbol\":\"BTC\"}"

Loading…
Cancel
Save