Browse Source

vs compat

release/v0.1
jl777 8 years ago
parent
commit
458173a8a6
  1. 14
      basilisk/basilisk.c
  2. 2
      basilisk/basilisk_bitcoin.c
  3. 1
      basilisk/basilisk_ping.c
  4. 7
      basilisk/basilisk_tradebot.c
  5. 79
      crypto777/OS_nonportable.c
  6. 2
      crypto777/OS_portable.h
  7. 8
      crypto777/OS_time.c
  8. 4
      crypto777/curve25519.c
  9. 6
      crypto777/iguana_utils.c
  10. 1
      crypto777/jpeg/jconfig.h
  11. 1
      crypto777/jpeg/jmemsys.h
  12. 2
      iguana/coins/genbtcd
  13. 6
      iguana/iguana777.c
  14. 18
      iguana/iguana777.h
  15. 2
      iguana/iguana_blocks.c
  16. 10
      iguana/iguana_bundles.c
  17. 5
      iguana/iguana_exchanges.c
  18. 2
      iguana/iguana_init.c
  19. 2
      iguana/iguana_msg.c
  20. 2
      iguana/iguana_payments.c
  21. 8
      iguana/iguana_peers.c
  22. 7
      iguana/iguana_ramchain.c
  23. 2
      iguana/iguana_realtime.c
  24. 2
      iguana/iguana_recv.c
  25. 2
      iguana/iguana_rpc.c
  26. 3
      iguana/iguana_scripts.c
  27. 2
      iguana/iguana_tradebots.c
  28. 2
      iguana/iguana_txidfind.c
  29. 4
      iguana/iguana_volatiles.c
  30. 8
      iguana/iguana_wallet.c
  31. 18
      iguana/mini-gmp.c
  32. 3
      iguana/secp256k1/include/secp256k1.h
  33. 8
      iguana/secp256k1/src/util.h
  34. 2
      includes/iguana_apideclares.h
  35. 4
      includes/iguana_defines.h
  36. 70
      includes/iguana_structs.h
  37. 2
      m_onetime
  38. 2
      pnacl_main.h

14
basilisk/basilisk.c

@ -48,7 +48,7 @@ uint32_t basilisk_calcnonce(struct supernet_info *myinfo,uint8_t *data,int32_t d
break;
}
iguana_rwnum(0,(void *)hash.uints,sizeof(basilisktag),&basilisktag);
iguana_rwnum(1,&data[-sizeof(basilisktag)],sizeof(basilisktag),&basilisktag);
iguana_rwnum(1,&data[-(int32_t)sizeof(basilisktag)],sizeof(basilisktag),&basilisktag);
char str[65],str2[65]; printf("found hash after numiters.%d %s vs %s basilisktag.%u\n",numiters,bits256_str(str,threshold),bits256_str(str2,hash2),basilisktag);
return(basilisktag);
}
@ -95,7 +95,7 @@ uint8_t *get_dataptr(int32_t hdroffset,uint8_t **ptrp,int32_t *datalenp,uint8_t
uint8_t *basilisk_jsondata(int32_t extraoffset,uint8_t **ptrp,uint8_t *space,int32_t spacesize,int32_t *datalenp,char *symbol,cJSON *sendjson,uint32_t basilisktag)
{
char *sendstr,*hexstr=0; uint8_t *data,hexspace[4096],*allocptr=0,*hexdata; int32_t datalen,hexlen=0;
char *sendstr,*hexstr=0; uint8_t *data,hexspace[4096],*allocptr=0,*hexdata=0; int32_t datalen,hexlen=0;
if ( jobj(sendjson,"symbol") == 0 )
jaddstr(sendjson,"symbol",symbol);
if ( (hexstr= jstr(sendjson,"data")) != 0 )
@ -118,7 +118,7 @@ uint8_t *basilisk_jsondata(int32_t extraoffset,uint8_t **ptrp,uint8_t *space,int
memcpy(data,sendstr,datalen);
//printf("jsondata.(%s) + hexlen.%d\n",sendstr,hexlen);
free(sendstr);
if ( hexlen > 0 )
if ( hexlen > 0 && hexdata != 0 )
{
//int32_t i; for (i=0; i<hexlen; i++)
// printf("%02x",hexdata[i]);
@ -172,13 +172,13 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
}
}
alreadysent = calloc(IGUANA_MAXPEERS * IGUANA_MAXCOINS,sizeof(*alreadysent));
iguana_rwnum(1,&data[-sizeof(*basilisktagp)],sizeof(*basilisktagp),basilisktagp);
iguana_rwnum(1,&data[-(int32_t)sizeof(*basilisktagp)],sizeof(*basilisktagp),basilisktagp);
if ( *basilisktagp == 0 )
{
if ( nBits != 0 )
*basilisktagp = basilisk_calcnonce(myinfo,data,datalen,nBits);
else *basilisktagp = rand();
iguana_rwnum(1,&data[-sizeof(*basilisktagp)],sizeof(*basilisktagp),basilisktagp);
iguana_rwnum(1,&data[-(int32_t)sizeof(*basilisktagp)],sizeof(*basilisktagp),basilisktagp);
}
data -= sizeof(*basilisktagp), datalen += sizeof(*basilisktagp);
memset(cmd,0,sizeof(cmd));
@ -237,7 +237,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
memset(privkey.bytes,0,sizeof(privkey));
if ( (cipher= SuperNET_ciphercalc(&ptr,&cipherlen,&privkey,&addr->pubkey,data,datalen,space,sizeof(space))) != 0 )
{
if ( (val= iguana_queue_send(addr,delaymillis,&cipher[-sizeof(struct iguana_msghdr)],cmd,cipherlen)) >= cipherlen )
if ( (val= iguana_queue_send(addr,delaymillis,&cipher[-(int32_t)sizeof(struct iguana_msghdr)],cmd,cipherlen)) >= cipherlen )
alreadysent[n++] = (uint32_t)addr->ipbits;
if ( ptr != 0 )
free(ptr);
@ -246,7 +246,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
else
{
cmd[6] = 'E', cmd[7] = 'T';
if ( (val= iguana_queue_send(addr,delaymillis,&data[-sizeof(struct iguana_msghdr)],cmd,datalen)) >= datalen )
if ( (val= iguana_queue_send(addr,delaymillis,&data[-(int32_t)sizeof(struct iguana_msghdr)],cmd,datalen)) >= datalen )
{
alreadysent[n++] = (uint32_t)addr->ipbits;
if ( n >= IGUANA_MAXPEERS*IGUANA_MAXCOINS )

2
basilisk/basilisk_bitcoin.c

@ -382,7 +382,7 @@ double basilisk_bitcoin_valuemetric(struct supernet_info *myinfo,struct basilisk
void *basilisk_bitcoinvalue(struct basilisk_item *Lptr,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj)
{
int32_t i,height,vout,numsent; struct basilisk_item *ptr; char coinaddr[64],str[64]; struct basilisk_value *v; uint64_t value = 0; bits256 txid; struct iguana_outpoint outpt;
int32_t i,height,vout,numsent; struct basilisk_item *ptr; char coinaddr[64],str[65]; struct basilisk_value *v; uint64_t value = 0; bits256 txid; struct iguana_outpoint outpt;
if ( RELAYID >= 0 )
return(0);
txid = jbits256(valsobj,"txid");

1
basilisk/basilisk_ping.c

@ -231,6 +231,7 @@ void basilisk_ping_process(struct supernet_info *myinfo,struct iguana_peer *addr
//len += basilisk_ping_processvirts(myinfo,btcd,addr,&data[len],datalen - len);
for (i=0; i<numrelays; i++)
{
rp = &RELAYS[i];
if ( len > datalen )
break;
if ( (n= basilisk_ping_processrelay(myinfo,&data[len],datalen-len,rp,i)) < 0 )

7
basilisk/basilisk_tradebot.c

@ -229,6 +229,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk
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.;
memset(&refR,0,sizeof(refR));
if ( (array= jarray(&n,retjson,"result")) != 0 )
{
for (i=nonz=m=0; i<n; i++)
@ -244,7 +245,11 @@ double basilisk_process_results(struct supernet_info *myinfo,struct basilisk_req
else
{
if ( (metric= basilisk_request_listprocess(myinfo,&tmpR,list,m)) > hwm )
*issueR = tmpR, hwm = metric;
{
*issueR = tmpR;
hwm = metric;
refR = tmpR;
}
m = 0;
}
}

79
crypto777/OS_nonportable.c

@ -47,6 +47,85 @@ void *OS_nonportable_tmpalloc(char *dirname,char *name,struct OS_memspace *mem,l
#include <tlhelp32.h>
#include <time.h>
#include <intrin.h>
static uint32_t __inline __builtin_clzll(uint64_t x) {
unsigned long r = 0;
_BitScanReverse64(&r, x);
return (63-r);
}
void usleep(int32_t micros)
{
if ( micros < 1000 )
Sleep(1);
else Sleep(micros / 1000);
}
int
mkstemp (template)
char *template;
{
static const char letters[]
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
static gcc_uint64_t value;
#ifdef HAVE_GETTIMEOFDAY
struct timeval tv;
#endif
char *XXXXXX;
size_t len;
int count;
len = strlen (template);
if ((int) len < 6
|| strncmp (&template[len - 6], "XXXXXX", 6))
{
return -1;
}
XXXXXX = &template[len - 6];
#ifdef HAVE_GETTIMEOFDAY
/* Get some more or less random data. */
gettimeofday (&tv, NULL);
value += ((gcc_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
#else
value += getpid ();
#endif
for (count = 0; count < TMP_MAX; ++count)
{
gcc_uint64_t v = value;
int fd;
/* Fill in the random bits. */
XXXXXX[0] = letters[v % 62];
v /= 62;
XXXXXX[1] = letters[v % 62];
v /= 62;
XXXXXX[2] = letters[v % 62];
v /= 62;
XXXXXX[3] = letters[v % 62];
v /= 62;
XXXXXX[4] = letters[v % 62];
v /= 62;
XXXXXX[5] = letters[v % 62];
fd = open (template, O_RDWR|O_CREAT|O_EXCL|O_BINARY, 0600);
if (fd >= 0)
/* The file does not exist. */
return fd;
/* This is a random value. It is only necessary that the next
TMP_MAX values generated by adding 7777 to VALUE are different
with (module 2^32). */
value += 7777;
}
/* We return the null string if we can't find a unique file name. */
template[0] = '\0';
return -1;
}
#include "../OSlibs/win/mman.h"

2
crypto777/OS_portable.h

@ -36,7 +36,9 @@
#include "../OSlibs/win/mman.h"
#include "../OSlibs/win/pthread.h"
#ifndef NATIVE_WINDOWS
#define EADDRINUSE WSAEADDRINUSE
#endif
#else
//#include <sys/poll.h>

8
crypto777/OS_time.c

@ -56,7 +56,7 @@ struct tm *gmtime_r(const time_t *timep,struct tm *result)
/*typedef struct timeval {
long tv_sec;
long tv_usec;
} timeval;
} timeval;*/
int gettimeofday(struct timeval * tp, struct timezone * tzp)
{
@ -75,7 +75,7 @@ int gettimeofday(struct timeval * tp, struct timezone * tzp)
tp->tv_sec = (long) ((time - EPOCH) / 10000000L);
tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
return 0;
}*/
}
#endif
double OS_portable_milliseconds()
@ -536,7 +536,7 @@ uint32_t OS_conv_datenum(int32_t datenum,int32_t hour,int32_t minute,int32_t sec
}
return(0);
}
else
/*else
{
#ifdef __PNACL
return(0);
@ -547,7 +547,7 @@ uint32_t OS_conv_datenum(int32_t datenum,int32_t hour,int32_t minute,int32_t sec
t.tm_hour = hour, t.tm_min = minute, t.tm_sec = second;
return((uint32_t)timegm(&t));
#endif
}
}*/
}
int32_t OS_conv_unixtime(struct tai *tp,int32_t *secondsp,time_t timestamp) // gmtime -> datenum + number of seconds

4
crypto777/curve25519.c

@ -38,7 +38,7 @@ static inline void fdifference_backwards(uint64_t *out,const uint64_t *in)
out[i] = in[i] + two54m8 - out[i];
}
inline void store_limb(uint8_t *out,uint64_t in)
void store_limb(uint8_t *out,uint64_t in)
{
int32_t i;
for (i=0; i<8; i++,in>>=8)
@ -119,7 +119,7 @@ bits320 fmul(const bits320 in2,const bits320 in)
return(out);
}
inline bits320 fsquare_times(const bits320 in,uint64_t count)
bits320 fsquare_times(const bits320 in,uint64_t count)
{
uint128_t t[5]; uint64_t r0,r1,r2,r3,r4,c,d0,d1,d2,d4,d419; bits320 out;
r0 = in.ulongs[0], r1 = in.ulongs[1], r2 = in.ulongs[2], r3 = in.ulongs[3], r4 = in.ulongs[4];

6
crypto777/iguana_utils.c

@ -1079,7 +1079,7 @@ void calc_md2str(char *hexstr,uint8_t *buf,uint8_t *msg,int32_t len)
bits128 x;
calc_md2(hexstr,buf,msg,len);
decode_hex(buf,sizeof(x),hexstr);
memcpy(buf,x.bytes,sizeof(x));
//memcpy(buf,x.bytes,sizeof(x));
}
void calc_md4str(char *hexstr,uint8_t *buf,uint8_t *msg,int32_t len)
@ -1087,7 +1087,7 @@ void calc_md4str(char *hexstr,uint8_t *buf,uint8_t *msg,int32_t len)
bits128 x;
calc_md4(hexstr,buf,msg,len);
decode_hex(buf,sizeof(x),hexstr);
memcpy(buf,x.bytes,sizeof(x));
//memcpy(buf,x.bytes,sizeof(x));
}
void calc_md5str(char *hexstr,uint8_t *buf,uint8_t *msg,int32_t len)
@ -1095,7 +1095,7 @@ void calc_md5str(char *hexstr,uint8_t *buf,uint8_t *msg,int32_t len)
bits128 x;
calc_md5(hexstr,msg,len);
decode_hex(buf,sizeof(x),hexstr);
memcpy(buf,x.bytes,sizeof(x));
//memcpy(buf,x.bytes,sizeof(x));
}
void calc_crc32str(char *hexstr,uint8_t *buf,uint8_t *msg,int32_t len)

1
crypto777/jpeg/jconfig.h

@ -20,6 +20,7 @@
/* Define "boolean" as unsigned char, not int, on Windows systems. */
#ifdef _WIN32
#define USE_MSDOS_MEMMGR
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
typedef unsigned char boolean;
#endif

1
crypto777/jpeg/jmemsys.h

@ -154,6 +154,7 @@ typedef struct backing_store_struct {
/* For the MS-DOS manager (jmemdos.c), we need: */
handle_union handle; /* reference to backing-store storage object */
char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */
short temp_file;
#else
#ifdef USE_MAC_MEMMGR
/* For the Mac manager (jmemmac.c), we need: */

2
iguana/coins/genbtcd

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"poll\":50,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"startpend\":512,\"endpend\":512,\"services\":129,\"maxpeers\":64,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":14631,\"rpc\":14632}"
curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"poll\":50,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"startpend\":16,\"endpend\":16,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":14631,\"rpc\":14632}"

6
iguana/iguana777.c

@ -164,7 +164,7 @@ int32_t iguana_peermetrics(struct supernet_info *myinfo,struct iguana_info *coin
{
coin->peers->topmetrics[i] = sortbuf[i*2];
ind = (int32_t)sortbuf[i*2 +1];
coin->peers->ranked[i] = &coin->peers->active[ind];
coin->peers->ranked[i] = addr = &coin->peers->active[ind];
if ( sortbuf[i*2] > SMALLVAL && (double)i/n > .8 && (time(NULL) - addr->ready) > 77 )
slowest = coin->peers->ranked[i];
//printf("(%.5f %s) ",sortbuf[i*2],coin->peers->ranked[i]->ipaddr);
@ -691,7 +691,7 @@ void iguana_helper(void *arg)
allcurrent = 0;
//printf("h.%d [%d] bundleQ size.%d lag.%ld\n",helperid,bp->hdrsi,queue_size(&bundlesQ),time(NULL) - bp->nexttime);
coin->numbundlesQ--;
if ( coin->started != 0 && (bp->nexttime == 0 || time(NULL) > bp->nexttime) && coin->active != 0 )
if ( coin->started != 0 && (bp->nexttime == 0 || time(NULL) >= bp->nexttime) && coin->active != 0 )
{
flag += iguana_bundleiters(myinfo,ptr->coin,&MEM,MEMB,bp,ptr->timelimit,IGUANA_DEFAULTLAG);
}
@ -957,7 +957,7 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,
if ( coin->MAXMEM == 0 )
coin->MAXMEM = IGUANA_DEFAULTRAM;
coin->MAXMEM *= (1024L * 1024 * 1024);
coin->enableCACHE = 0;//(strcmp("BTCD",coin->symbol) == 0);
coin->enableCACHE = (strcmp("BTCD",coin->symbol) == 0);
if ( jobj(json,"cache") != 0 )
coin->enableCACHE = juint(json,"cache");
if ( (coin->polltimeout= juint(json,"poll")) <= 0 )

18
iguana/iguana777.h

@ -16,11 +16,19 @@
#ifndef iguana777_net_h
#define iguana777_net_h
#if defined(_WIN32) || defined(_WIN64)
#define WIN32
#endif
#if (defined(_WIN32) || defined(__WIN32__)) && \
!defined(WIN32) && !defined(__SYMBIAN32__)
#define WIN32
#endif
#ifdef WIN32
#define __MINGW
#define _CRT_SECURE_NO_WARNINGS
#else
#ifndef __MINGW
#include <arpa/inet.h>
@ -43,11 +51,7 @@ struct exchange_info;
#include "../includes/iguana_defines.h"
#include "../includes/iguana_types.h"
#include "../includes/iguana_structs.h"
#include "../includes/iguana_funcs.h"
#include "../includes/iguana_globals.h"
#include "../basilisk/basilisk.h"
#include "../gecko/gecko.h"
struct supernet_address
{
@ -89,4 +93,8 @@ struct supernet_info
struct message_info msgids[8192];
};
#include "../includes/iguana_funcs.h"
#include "../includes/iguana_globals.h"
#include "../gecko/gecko.h"
#endif

2
iguana/iguana_blocks.c

@ -423,7 +423,7 @@ int32_t iguana_blockunmain(struct iguana_info *coin,struct iguana_block *block)
int32_t iguana_walkchain(struct iguana_info *coin,int32_t skipflag)
{
char str[65]; int32_t height,hdrsi,bundlei,n = 0; struct iguana_bundle *bp; struct iguana_block *block;
char str[65]; int32_t height,hdrsi,bundlei,n = 0; struct iguana_bundle *bp; struct iguana_block *block=0;
height = coin->blocks.hwmchain.height;
while ( 1 ) //(block= iguana_blockfind("main",coin,iguana_blockhash(coin,height))) != 0 )
{

10
iguana/iguana_bundles.c

@ -638,6 +638,8 @@ int32_t iguana_bundleissuemissing(struct supernet_info *myinfo,struct iguana_inf
lag = 60;
else if ( lag < 30 )
lag = 30;
if ( strcmp(coin->symbol,"BTC") != 0 )
lag /= 10;
if ( (num= coin->peers->numranked) == 0 )
iguana_updatemetrics(myinfo,coin);
if ( (num= coin->peers->numranked) != 0 )
@ -653,7 +655,7 @@ int32_t iguana_bundleissuemissing(struct supernet_info *myinfo,struct iguana_inf
lasti = firsti = -1;
for (i=nonz=0; i<bp->n; i++)
{
if ( (block= bp->blocks[i]) != 0 && block->txvalid != 0 )
if ( (block= bp->blocks[i]) != 0 && block->txvalid != 0 && block->mainchain != 0 )
continue;
//if ( GETBIT(bp->haveblock,i) != 0 )
// continue;
@ -666,7 +668,7 @@ int32_t iguana_bundleissuemissing(struct supernet_info *myinfo,struct iguana_inf
iguana_bundleblock(coin,&hash2,bp,i);
if ( bits256_nonz(hash2) != 0 )
{
if ( 0 && (addr= coin->peers->ranked[rand() % max]) != 0 && addr->usock >= 0 && addr->dead == 0 )
if ( 1 && (addr= coin->peers->ranked[rand() % max]) != 0 && addr->usock >= 0 && addr->dead == 0 )
{
if ( 0 && bp == coin->current )
printf("iguana_bundleissuemissing.[%d:%d]\n",bp->hdrsi,i);
@ -684,7 +686,7 @@ int32_t iguana_bundleissuemissing(struct supernet_info *myinfo,struct iguana_inf
} //else printf("[z%d] ",i);
} //else printf("%d ",now - (bp->issued[i]+lag));
}
if ( firsti >= 0 && bp == coin->current )
if ( firsti >= 0 )//&& bp == coin->current )
{
//printf("[%d] first missing.%d of %d\n",bp->hdrsi,firsti,nonz);
iguana_bundleblock(coin,&hash2,bp,firsti);
@ -861,7 +863,7 @@ int32_t iguana_bundleready(struct supernet_info *myinfo,struct iguana_info *coin
int32_t iguana_bundlehdr(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,int32_t starti)
{
int32_t i,dist,counter=0; char str[64];
int32_t i,dist,counter=0; char str[65];
if ( 0 && bp->isRT == 0 && (bp->hdrsi == coin->bundlescount-1 || bp == coin->current) )
printf("hdr ITERATE.%d bundle.%d vs %d: h.%d n.%d r.%d s.%d c.%d finished.%d spec.%p[%d]\n",bp->hdrsi,bp->bundleheight,coin->longestchain-coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->numcached,bp->emitfinish,bp->speculative,bp->numspec);
dist = 30 + (coin->current != 0 ? bp->hdrsi - coin->current->hdrsi : 0);

5
iguana/iguana_exchanges.c

@ -1072,6 +1072,8 @@ struct exchange_info *exchange_create(char *exchangestr,cJSON *argjson)
exchange->exchangeid = exchangeid;
safecopy(exchange->name,exchangestr,sizeof(exchange->name));
exchange->exchangebits = stringbits(exchange->name);
if ( argjson != 0 )
{
if ( (exchange->pollgap= juint(argjson,"pollgap")) < EXCHANGES777_MINPOLLGAP )
exchange->pollgap = EXCHANGES777_MINPOLLGAP;
if ( (key= jstr(argjson,"apikey")) != 0 || (key= jstr(argjson,"key")) != 0 )
@ -1084,6 +1086,7 @@ struct exchange_info *exchange_create(char *exchangestr,cJSON *argjson)
safecopy(exchange->tradepassword,tradepassword,sizeof(exchange->tradepassword));
if ( (exchange->commission= jdouble(argjson,"commission")) > 0. )
exchange->commission *= .01;
}
printf("ADDEXCHANGE.(%s) [%s, %s, %s] commission %.3f%% -> exchangeid.%d\n",exchangestr,exchange->apikey,exchange->userid,exchange->apisecret,exchange->commission * 100.,exchangeid);
Exchanges[exchangeid] = exchange;
//instantdex_FSMinit();
@ -1132,7 +1135,7 @@ void exchanges777_init(struct supernet_info *myinfo,cJSON *exchanges,int32_t sle
{
if ( strcmp(Exchange_funcs[i]->name,"PAX") == 0 || strcmp(Exchange_funcs[i]->name,"truefx") == 0 || strcmp(Exchange_funcs[i]->name,"fxcm") == 0 || strcmp(Exchange_funcs[i]->name,"instaforx") == 0 )
continue;
if ( ((exchange= exchanges777_find(Exchange_funcs[i]->name)) == 0 && (exchange= exchange_create(Exchange_funcs[i]->name,item)) != 0) || (exchange= exchanges777_info(Exchange_funcs[i]->name,sleepflag,argjson,0)) != 0 )
if ( ((exchange= exchanges777_find(Exchange_funcs[i]->name)) == 0 && (exchange= exchange_create(Exchange_funcs[i]->name,0)) != 0) || (exchange= exchanges777_info(Exchange_funcs[i]->name,sleepflag,argjson,0)) != 0 )
myinfo->tradingexchanges[myinfo->numexchanges++] = exchange;
}
free_json(argjson);

2
iguana/iguana_init.c

@ -292,7 +292,7 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3
//printf("parse line.(%s) maxpeers.%d\n",line,coin->MAXPEERS);
if ( iter == 0 )
{
if ( m < 32 || (m < coin->MAXPEERS/2 && strcmp("BTCD",coin->symbol) != 0) )//&& m < 77.7 )
if ( m < 32 || m < coin->MAXPEERS/2 )//&& m < 77.7 )
{
if ( 0 && m == 0 )
{

2
iguana/iguana_msg.c

@ -652,6 +652,8 @@ int32_t iguana_rwtx(struct supernet_info *myinfo,uint8_t zcash,int32_t rwflag,st
}
if ( rwflag != 0 )
{
memset(joinsplitpubkey,0,sizeof(joinsplitpubkey)); // for now
memset(joinsplitsig,0,sizeof(joinsplitsig)); // set to actuals
memcpy(&serialized[len],joinsplitpubkey,33), len += 33;
memcpy(&serialized[len],joinsplitsig,64), len += 64;
}

2
iguana/iguana_payments.c

@ -902,7 +902,7 @@ HASH_AND_INT(bitcoinrpc,getrawtransaction,txid,verbose)
free(txbytes);
if ( txobj != 0 )
{
iguana_txdetails(myinfo,coin,txobj,txid,-2,height);
iguana_txdetails(myinfo,coin,txobj,checktxid,-2,height);
return(jprint(txobj,1));
}
}

8
iguana/iguana_peers.c

@ -361,10 +361,14 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port)
}
saddr.sin_family = AF_INET;
saddr.sin_port = htons(port);
#ifdef WIN32
saddr.sin_addr.s_addr = (uint32_t)calc_ipbits("127.0.0.1");
#else
memcpy(&saddr.sin_addr.s_addr,hostent->h_addr_list[0],hostent->h_length);
expand_ipbits(checkipaddr,saddr.sin_addr.s_addr);
if ( strcmp(ipaddr,checkipaddr) != 0 )
printf("bindflag.%d iguana_socket mismatch (%s) -> (%s)?\n",bindflag,checkipaddr,ipaddr);
#endif
if ( (sock= socket(AF_INET,SOCK_STREAM,0)) < 0 )
{
if ( errno != ETIMEDOUT )
@ -716,7 +720,7 @@ void iguana_startconnection(void *arg)
printf("avoid self-loopback\n");
return;
}
//printf("startconnection.(%s) pending.%u usock.%d addrind.%d\n",addr->ipaddr,addr->pending,addr->usock,addr->addrind);
printf(">>>>>>>> startconnection.(%s) pending.%u usock.%d addrind.%d\n",addr->ipaddr,addr->pending,addr->usock,addr->addrind);
addr->pending = (uint32_t)time(NULL);
if ( (port= (uint16_t)(addr->ipbits >> 32)) == 0 )
port = coin->chain->portp2p;
@ -725,7 +729,7 @@ void iguana_startconnection(void *arg)
if ( addr->usock < 0 || (coin->peers != 0 && coin->peers->shuttingdown != 0) )
{
strcpy(ipaddr,addr->ipaddr);
//printf("%s refused PEER KILLED. slot.%d for %s:%d usock.%d\n",coin->symbol,addr->addrind,ipaddr,coin->chain->portp2p,addr->usock);
printf("%s refused PEER KILLED. slot.%d for %s:%d usock.%d\n",coin->symbol,addr->addrind,ipaddr,coin->chain->portp2p,addr->usock);
iguana_iAkill(coin,addr,1);
}
else

7
iguana/iguana_ramchain.c

@ -163,6 +163,7 @@ int32_t iguana_peerfile_exists(struct iguana_info *coin,struct iguana_peer *addr
#define RAMCHAIN_DESTARG dest,destB,destT,destU,destS,destP,destA,destX,destUx,destSx,destTXbits,destPKbits,destKspace
#define RAMCHAIN_DESTPTRS dest,&destB,&destT,&destU,&destS,&destP,&destA,&destX,&destUx,&destSx,&destTXbits,&destPKbits,&destKspace
#define RAMCHAIN_DESTDECLARE struct iguana_blockRO *destB; struct iguana_txid *destT; struct iguana_unspent20 *destU; struct iguana_spend256 *destS; struct iguana_pkhash *destP; struct iguana_account *destA; bits256 *destX; struct iguana_unspent *destUx; struct iguana_spend *destSx; uint8_t *destTXbits,*destPKbits,*destKspace;
#define RAMCHAIN_DESTZEROES destB = 0, destUx = 0, destSx = 0, destP = 0, destA = 0, destX = 0, destKspace = destTXbits = destPKbits = 0, destU = 0, destS = 0, destT = 0
uint32_t iguana_ramchain_addtxid(struct iguana_info *coin,RAMCHAIN_FUNC,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp,int16_t bundlei)
{
@ -1374,7 +1375,7 @@ int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramcha
struct iguana_ramchain *_iguana_ramchain_map(struct iguana_info *coin,char *fname,struct iguana_bundle *bp,int32_t numblocks,struct iguana_ramchain *ramchain,struct OS_memspace *hashmem,uint32_t ipbits,bits256 hash2,bits256 prevhash2,int32_t bundlei,long fpos,int32_t allocextras,int32_t expanded,uint8_t zcash)
{
RAMCHAIN_DECLARE; int32_t valid,iter,i,checki,hdrsi; long filesize; void *ptr; char str[65],str2[65],dirstr[64]; struct iguana_block *block; struct iguana_zblockRO zRO; struct iguana_ramchaindata *rdata;
RAMCHAIN_DECLARE; int32_t valid,iter,i,checki,hdrsi; long filesize; void *ptr; char str[65],str2[65],dirstr[65]; struct iguana_block *block; struct iguana_zblockRO zRO; struct iguana_ramchaindata *rdata;
/*if ( ramchain->expanded != 0 && (ramchain->sigsfileptr == 0 || ramchain->sigsfilesize == 0) )
{
sprintf(sigsfname,"sigs/%s/%s",coin->symbol,bits256_str(str,hash2));
@ -1630,7 +1631,7 @@ int32_t iguana_ramchain_cmp(struct iguana_ramchain *A,struct iguana_ramchain *B,
int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_ramchain *dest,struct iguana_ramchain *ramchain,struct iguana_bundle *bp,int16_t bundlei)
{
RAMCHAIN_DECLARE; RAMCHAIN_DESTDECLARE;
RAMCHAIN_DECLARE; RAMCHAIN_DESTDECLARE; RAMCHAIN_DESTZEROES;
int32_t j,hdrsi,prevout,scriptlen; uint32_t timestamp=0,unspentind,sequenceid,destspendind=0,desttxidind=0; uint16_t fileid; uint64_t scriptpos; int64_t crypto777_payment = 0;
bits256 prevhash; uint64_t value; uint8_t type; struct iguana_unspent *u;
struct iguana_txid *tx; struct iguana_ramchaindata *rdata; uint8_t rmd160[20];
@ -2369,7 +2370,7 @@ struct iguana_ramchain *iguana_bundleload(struct supernet_info *myinfo,struct ig
int64_t iguana_ramchainopen(char *fname,struct iguana_info *coin,struct iguana_ramchain *ramchain,struct OS_memspace *mem,struct OS_memspace *hashmem,int32_t bundleheight,bits256 hash2)
{
RAMCHAIN_DECLARE; RAMCHAIN_ZEROES; int32_t i,numblocks = coin->chain->bundlesize; uint32_t numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata; int64_t hashsize,allocsize;
RAMCHAIN_DECLARE; RAMCHAIN_ZEROES; int32_t i,numblocks = coin->chain->bundlesize; uint32_t numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata=0; int64_t hashsize,allocsize;
//B = 0, Ux = 0, Sx = 0, P = 0, A = 0, X = 0, Kspace = TXbits = PKbits = 0, U = 0, S = 0, T = 0;
mem->alignflag = sizeof(uint32_t);
hashmem->alignflag = sizeof(uint32_t);

2
iguana/iguana_realtime.c

@ -1127,7 +1127,7 @@ int32_t iguana_RTblocksub(struct supernet_info *myinfo,struct iguana_info *coin,
void iguana_RTnewblock(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_block *block)
{
int32_t i,n,height,hdrsi,bundlei; struct iguana_block *addblock,*subblock; struct iguana_bundle *bp;
int32_t i,n,height,hdrsi,bundlei; struct iguana_block *addblock=0,*subblock=0; struct iguana_bundle *bp;
if ( block->height < coin->firstRTheight || block->height >= coin->firstRTheight+sizeof(coin->RTblocks)/sizeof(*coin->RTblocks) )
{
if ( coin->firstRTheight > 0 )

2
iguana/iguana_recv.c

@ -1591,7 +1591,7 @@ int32_t iguana_reqhdrs(struct iguana_info *coin)
if ( (bp= coin->bundles[i]) != 0 && (bp == coin->current || bp->hdrsi == coin->blocks.hwmchain.height/coin->chain->bundlesize || i == coin->bundlescount-1 || bp->numhashes < bp->n) )
{
if ( bp == coin->current )
lag = 13;
lag = 3;
else lag = 17;
if ( time(NULL) > bp->issuetime+lag )
{

2
iguana/iguana_rpc.c

@ -23,7 +23,7 @@
char *sglue(GLUEARGS,char *agent,char *method)
{
char *retstr,*rpcretstr,*walletstr,checkstr[64],dcheckstr[64]; cJSON *retjson,*tmpjson,*result,*error,*wallet; int32_t i,j,len; int64_t val; double dval;
char *retstr,*rpcretstr,*walletstr,checkstr[65],dcheckstr[65]; cJSON *retjson,*tmpjson,*result,*error,*wallet; int32_t i,j,len; int64_t val; double dval;
if ( json == 0 )
json = cJSON_CreateObject();
//printf("sglue.(%s)\n",jprint(json,0));

3
iguana/iguana_scripts.c

@ -287,7 +287,7 @@ int32_t iguana_scriptgen(struct iguana_info *coin,int32_t *Mp,int32_t *nump,char
int32_t _iguana_calcrmd160(struct iguana_info *coin,struct vin_info *vp)
{
static uint8_t zero_rmd160[20];
char hexstr[8192]; uint8_t sha256[32],*script,type; int32_t i,n,m,plen;
char hexstr[8192]; uint8_t *script,type; int32_t i,n,m,plen;
vp->N = 1;
vp->M = 1;
type = IGUANA_SCRIPT_STRANGE;
@ -301,7 +301,6 @@ int32_t _iguana_calcrmd160(struct iguana_info *coin,struct vin_info *vp)
//vcalc_sha256(0,sha256,vp->spendscript,vp->spendlen); // e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
//calc_rmd160(0,zero_rmd160,sha256,sizeof(sha256)); // b472a266d0bd89c13706a4132ccfb16f7c3b9fcb
init_hexbytes_noT(hexstr,zero_rmd160,20);
char str[65]; printf("iguana_calcrmd160 zero len %s -> %s\n",bits256_str(str,*(bits256 *)sha256),hexstr);
}
memcpy(vp->rmd160,zero_rmd160,sizeof(zero_rmd160));
return(IGUANA_SCRIPT_NULL);

2
iguana/iguana_tradebots.c

@ -38,7 +38,7 @@ struct tradebot_info
cJSON *tradebot_json(struct supernet_info *myinfo,struct exchange_info *exchange,struct tradebot_info *bot)
{
char str[64]; int32_t i,numpending; double pendsum,pendvolume,vol; cJSON *json,*array,*item;
char str[65]; int32_t i,numpending; double pendsum,pendvolume,vol; cJSON *json,*array,*item;
json = cJSON_CreateObject();
jaddstr(json,"exchange",exchange->name);
jaddstr(json,"started",utc_str(str,bot->started));

2
iguana/iguana_txidfind.c

@ -81,7 +81,7 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
x |= (*ptr & masks[modval]) >> modval;
}
if ( x != 0 )
printf("%s ",bits256_str(str,*(bits256 *)(refdata + x*refsize))), n++;
printf("%s ",bits256_str(str,*(bits256 *)((long)refdata + x*refsize))), n++;
}
printf("tableentries.%d\n",n);
}

4
iguana/iguana_volatiles.c

@ -416,9 +416,9 @@ void iguana_volatilespurge(struct iguana_info *coin,struct iguana_ramchain *ramc
if ( ramchain != 0 )
{
//printf("volatilespurge.[%d] (%p %p) %p %p\n",ramchain->height/coin->chain->bundlesize,ramchain->A2,ramchain->Uextras,ramchain->debitsfileptr,ramchain->lastspendsfileptr);
if ( ramchain->allocatedA2 != 0 && ramchain->A2 != 0 && ramchain->A2 != ramchain->debitsfileptr+sizeof(bits256)*2+sizeof(int32_t) )
if ( ramchain->allocatedA2 != 0 && ramchain->A2 != 0 && (long)ramchain->A2 != (long)ramchain->debitsfileptr+sizeof(bits256)*2+sizeof(int32_t) )
free(ramchain->A2);
if ( ramchain->allocatedU2 != 0 && ramchain->Uextras != 0 && ramchain->Uextras != ramchain->lastspendsfileptr+sizeof(bits256)*2+sizeof(int32_t) )
if ( ramchain->allocatedU2 != 0 && ramchain->Uextras != 0 && (long)ramchain->Uextras != (long)ramchain->lastspendsfileptr+sizeof(bits256)*2+sizeof(int32_t) )
free(ramchain->Uextras);
ramchain->A2 = 0;
ramchain->Uextras = 0;

8
iguana/iguana_wallet.c

@ -264,7 +264,7 @@ struct iguana_waddress *iguana_waccountswitch(struct supernet_info *myinfo,struc
uint8_t *iguana_walletrmds(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *numrmdsp)
{
int32_t iter,n,m; struct iguana_waccount *acct,*tmp; uint8_t *pubkeys,*addrtypes,*rmdarray = 0; struct iguana_waddress *waddr,*tmp2;
int32_t iter,n,m; struct iguana_waccount *acct,*tmp; uint8_t *pubkeys=0,*addrtypes=0,*rmdarray = 0; struct iguana_waddress *waddr,*tmp2;
for (iter=n=m=0; iter<2; iter++)
{
HASH_ITER(hh,myinfo->wallet,acct,tmp)
@ -273,7 +273,7 @@ uint8_t *iguana_walletrmds(struct supernet_info *myinfo,struct iguana_info *coin
{
if ( iter == 0 )
n++;
else if ( m < n )
else if ( addrtypes != 0 && pubkeys != 0 && m < n )
{
addrtypes[m] = waddr->addrtype;
memcpy(&rmdarray[m * 20],waddr->rmd160,20);
@ -533,7 +533,7 @@ cJSON *iguana_payloadmerge(cJSON *loginjson,cJSON *importjson)
cJSON *iguana_walletadd(struct supernet_info *myinfo,struct iguana_waddress **waddrp,struct iguana_info *coin,char *retstr,char *account,struct iguana_waddress *refwaddr,int32_t setcurrent,char *redeemScript)
{
cJSON *retjson=0; struct iguana_waccount *wacct; struct iguana_waddress *waddr;
cJSON *retjson=0; struct iguana_waccount *wacct; struct iguana_waddress *waddr=0;
if ( (wacct= iguana_waccountfind(myinfo,account)) == 0 )
wacct = iguana_waccountcreate(myinfo,account);
if ( wacct != 0 )
@ -614,7 +614,7 @@ char *iguana_walletfields(struct iguana_info *coin,int32_t *p2shflagp,char *wifs
int32_t iguana_walletemit(struct supernet_info *myinfo,char *fname,struct iguana_info *coin,cJSON *array)
{
cJSON *item,*child; char str[64],wifstr[128],*account,coinaddr[64],*privstr; int32_t i,n,p2shflag; FILE *fp;
cJSON *item,*child; char str[65],wifstr[128],*account,coinaddr[64],*privstr; int32_t i,n,p2shflag; FILE *fp;
if ( (fp= fopen(fname,"wb")) == 0 )
return(-1);
n = cJSON_GetArraySize(array);

18
iguana/mini-gmp.c

@ -64,7 +64,7 @@ see https://www.gnu.org/licenses/. */
#define GMP_ULONG_HIGHBIT ((uint64_t) 1 << (GMP_ULONG_BITS - 1))
#define GMP_ABS(x) ((x) >= 0 ? (x) : -(x))
#define GMP_NEG_CAST(T,x) (-((T)((x) + 1) - 1))
#define GMP_NEG_CAST(T,x) (-(int64_t)((T)((x) + 1) - 1))
#define GMP_MIN(a, b) ((a) < (b) ? (a) : (b))
#define GMP_MAX(a, b) ((a) > (b) ? (a) : (b))
@ -90,8 +90,8 @@ see https://www.gnu.org/licenses/. */
#define gmp_ctz(count, x) do { \
mp_limb_t __ctz_x = (x); \
uint32_t __ctz_c = 0; \
gmp_clz (__ctz_c, __ctz_x & - __ctz_x); \
(count) = GMP_LIMB_BITS - 1 - __ctz_c; \
gmp_clz (__ctz_c, __ctz_x & - (int64_t)__ctz_x); \
(count) = GMP_LIMB_BITS - 1 - (int64_t)__ctz_c; \
} while (0)
#define gmp_add_ssaaaa(sh, sl, ah, al, bh, bl) \
@ -141,7 +141,7 @@ see https://www.gnu.org/licenses/. */
gmp_umul_ppmm (_qh, _ql, (nh), (di)); \
gmp_add_ssaaaa (_qh, _ql, _qh, _ql, (nh) + 1, (nl)); \
_r = (nl) - _qh * (d); \
_mask = -(mp_limb_t) (_r > _ql); /* both > and >= are OK */ \
_mask = -(_r > _ql); /* both > and >= are OK */ \
_qh += _mask; \
_r += _mask & (d); \
if (_r >= (d)) \
@ -168,7 +168,7 @@ see https://www.gnu.org/licenses/. */
(q)++; \
\
/* Conditionally adjust q and the remainders */ \
_mask = - (mp_limb_t) ((r1) >= _q0); \
_mask = -((r1) >= _q0); \
(q) += _mask; \
gmp_add_ssaaaa ((r1), (r0), (r1), (r0), _mask & (d1), _mask & (d0)); \
if ((r1) >= (d1)) \
@ -3517,7 +3517,7 @@ static void mpn_div_qr_2_preinv (mp_ptr qp, mp_ptr rp, mp_srcptr np, mp_size_t n
uint32_t shift;
mp_size_t i;
mp_limb_t d1, d0, di, r1, r0;
mp_ptr tp;
mp_ptr tp=0;
assert (nn >= 2);
shift = inv->shift;
@ -3553,7 +3553,7 @@ static void mpn_div_qr_2_preinv (mp_ptr qp, mp_ptr rp, mp_srcptr np, mp_size_t n
assert ((r0 << (GMP_LIMB_BITS - shift)) == 0);
r0 = (r0 >> shift) | (r1 << (GMP_LIMB_BITS - shift));
r1 >>= shift;
if ( tp != 0 )
free (tp);
}
@ -4232,9 +4232,9 @@ static mp_limb_t mpn_div_qr_1 (mp_ptr qp, mp_srcptr np, mp_size_t nn, mp_limb_t
mpn_copyi (qp, np, nn);
else
{
uint32_t shift;
uint64_t shift;
gmp_ctz (shift, d);
mpn_rshift (qp, np, nn, shift);
mpn_rshift (qp, np, nn, (uint32_t)shift);
}
}
return r;

3
iguana/secp256k1/include/secp256k1.h

@ -5,6 +5,9 @@
extern "C" {
# endif
#undef HAVE_BUILTIN_EXPECT
#undef HAVE_BUILTIN_CLZLL
#include <stddef.h>
/* These rules specify the order of arguments in API calls:

8
iguana/secp256k1/src/util.h

@ -36,11 +36,15 @@ static SECP256K1_INLINE void secp256k1_callback_call(const secp256k1_callback *
} while(0)
#endif
#ifndef WIN32
#ifdef HAVE_BUILTIN_EXPECT
#define EXPECT(x,c) __builtin_expect((x),(c))
#else
#define EXPECT(x,c) (x)
#endif
#else
#define EXPECT(x,c) (x)
#endif
#ifdef DETERMINISTIC
#define CHECK(cond) do { \
@ -90,12 +94,16 @@ SECP256K1_INLINE static int secp256k1_clz64_var(uint64_t x) {
if (!x) {
return 64;
}
#ifndef WIN32
# if defined(HAVE_BUILTIN_CLZLL)
ret = __builtin_clzll(x);
# else
/*FIXME: debruijn fallback. */
for (ret = 0; ((x & (1ULL << 63)) == 0); x <<= 1, ret++);
# endif
#else
for (ret = 0; ((x & (1ULL << 63)) == 0); x <<= 1, ret++);
#endif
return ret;
}

2
includes/iguana_apideclares.h

@ -195,6 +195,7 @@ TWO_STRINGS(tradebot,pause,exchange,botid);
TWO_STRINGS(tradebot,stop,exchange,botid);
TWO_STRINGS(tradebot,resume,exchange,botid);
#ifndef WIN32
HASH_ARG(pangea,call,tablehash);
HASH_AND_INT(pangea,raise,tablehash,numchips);
HASH_AND_INT(pangea,bet,tablehash,numchips);
@ -210,6 +211,7 @@ ZERO_ARGS(pangea,lobby);
HASH_AND_STRING(pangea,join,tablehash,handle);
HASH_AND_INT(pangea,buyin,tablehash,numchips);
HASH_ARG(pangea,start,tablehash);
#endif
ZERO_ARGS(SuperNET,help);
STRING_ARG(SuperNET,utime2utc,utime);

4
includes/iguana_defines.h

@ -112,11 +112,11 @@ extern int32_t IGUANA_NUMHELPERS;
#define PNACL_message printf
#endif
#ifndef WIN32
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0x4000 // Do not generate SIGPIPE
#endif
#if defined(_WIN32) || defined(_WIN64)
#else
#define MSG_NOSIGNAL 0
#endif

70
includes/iguana_structs.h

@ -16,6 +16,12 @@
#ifndef H_IGUANASTRUCTS_H
#define H_IGUANASTRUCTS_H
#ifdef __WIN32
#define PACKEDSTRUCT
#else
#define PACKEDSTRUCT __attribute__((packed))
#endif
struct iguana_thread
{
struct queueitem DL;
@ -53,7 +59,7 @@ struct iguana_chain
uint16_t targetspacing,targettimespan; uint32_t nBits,normal_txversion,locktime_txversion;
};
struct iguana_msgaddress { uint32_t nTime; uint64_t nServices; uint8_t ip[16]; uint16_t port; };// __attribute__((packed));
struct iguana_msgaddress { uint32_t nTime; uint64_t nServices; uint8_t ip[16]; uint16_t port; }PACKEDSTRUCT;
struct iguana_msgversion
{
@ -65,7 +71,7 @@ struct iguana_msgversion
char strSubVer[80];
uint32_t nStartingHeight;
uint8_t relayflag;
};// __attribute__((packed));
}PACKEDSTRUCT;
struct iguana_msgalert // warning, many varints/variable length fields, struct is 1:1
{
@ -91,14 +97,14 @@ struct iguana_VPNversion
char strSubVer[80];
uint32_t nStartingHeight;
uint32_t iVer,v_Network_id; uint16_t wPort; uint8_t bIsGui; uint16_t wCtPort,wPrPort;
};// __attribute__((packed));
}PACKEDSTRUCT;
struct iguana_msgblockhdr
{
uint32_t version;
bits256 prev_block,merkle_root;
uint32_t timestamp,bits,nonce;
};// __attribute__((packed));
}PACKEDSTRUCT;
#define ZKSNARK_PROOF_SIZE 584
#define ZCASH_SOLUTION_ELEMENTS 32
@ -109,25 +115,25 @@ struct iguana_msgblockhdr_zcash
uint8_t numelements;
uint32_t solution[ZCASH_SOLUTION_ELEMENTS];
//bits256 reserved; // only here if auxpow is set
};// __attribute__((packed));
}PACKEDSTRUCT;
struct iguana_msgmerkle
{
uint32_t branch_length;
bits256 branch_hash[4096];
uint32_t branch_side_mask;
};// __attribute__((packed));
}PACKEDSTRUCT;
struct iguana_msgblock
{
struct iguana_msgblockhdr H; // double hashed for blockhash
struct iguana_msgblockhdr_zcash zH;
uint32_t txn_count;
};// __attribute__((packed));
}PACKEDSTRUCT;
struct iguana_msgvin { bits256 prev_hash; uint8_t *vinscript,*userdata,*spendscript,*redeemscript; uint32_t prev_vout,sequence; uint16_t scriptlen,p2shlen,userdatalen,spendlen; };// __attribute__((packed));
struct iguana_msgvin { bits256 prev_hash; uint8_t *vinscript,*userdata,*spendscript,*redeemscript; uint32_t prev_vout,sequence; uint16_t scriptlen,p2shlen,userdatalen,spendlen; }PACKEDSTRUCT;
struct iguana_msgvout { uint64_t value; uint32_t pk_scriptlen; uint8_t *pk_script; };// __attribute__((packed));
struct iguana_msgvout { uint64_t value; uint32_t pk_scriptlen; uint8_t *pk_script; }PACKEDSTRUCT;
struct iguana_msgtx
{
@ -138,7 +144,7 @@ struct iguana_msgtx
int32_t allocsize,timestamp,numinputs,numoutputs;
int64_t inputsum,outputsum,txfee;
uint8_t *serialized;
};// __attribute__((packed));
}PACKEDSTRUCT;
struct iguana_msgjoinsplit
{
@ -147,7 +153,7 @@ struct iguana_msgjoinsplit
uint8_t ciphertexts[2][217];
bits256 randomseed,vmacs[2];
uint8_t zkproof[ZKSNARK_PROOF_SIZE-1];
};// __attribute__((packed));
}PACKEDSTRUCT;
struct iguana_packet { struct queueitem DL; struct iguana_peer *addr; struct tai embargo; int32_t datalen,getdatablock; uint8_t serialized[]; };
@ -155,7 +161,7 @@ struct msgcounts { uint32_t version,verack,getaddr,addr,inv,getdata,notfound,get
struct iguana_fileitem { bits256 hash2; struct iguana_txdatabits txdatabits; };
struct iguana_kvitem { UT_hash_handle hh; uint8_t keyvalue[]; };// __attribute__((packed));
struct iguana_kvitem { UT_hash_handle hh; uint8_t keyvalue[]; }PACKEDSTRUCT;
struct iguana_iAddr
{
@ -173,15 +179,15 @@ struct iguana_blockRO
uint32_t timestamp,nonce,bits,version;
uint32_t firsttxidind,firstvin,firstvout,firstpkind,firstexternalind,recvlen:24,tbd:8;
uint16_t txn_count,numvouts,numvins,allocsize;
};// __attribute__((packed));
}PACKEDSTRUCT;
struct iguana_zcashRO { bits256 bignonce; uint32_t solution[ZCASH_SOLUTION_ELEMENTS]; };// __attribute__((packed));
struct iguana_zcashRO { bits256 bignonce; uint32_t solution[ZCASH_SOLUTION_ELEMENTS]; }PACKEDSTRUCT;
struct iguana_zblockRO
{
struct iguana_blockRO RO;
struct iguana_zcashRO zRO;
};// __attribute__((packed));
}PACKEDSTRUCT;
#define iguana_blockfields double PoW; \
int32_t height,fpos; uint32_t fpipbits,issued,lag:18,sigsvalid:1,protected:1,peerid:12; \
@ -193,13 +199,13 @@ struct iguana_block
{
iguana_blockfields;
struct iguana_zcashRO zRO[];
};// __attribute__((packed));
}PACKEDSTRUCT;
struct iguana_zblock // mu
{
iguana_blockfields;
struct iguana_zcashRO zRO;
};// __attribute__((packed));
}PACKEDSTRUCT;
#define IGUANA_LHASH_BLOCKS 0
#define IGUANA_LHASH_TXIDS 1 //
@ -218,7 +224,7 @@ struct iguana_counts
uint32_t firsttxidind,firstunspentind,firstspendind,firstpkind;
uint64_t credits,debits;
struct iguana_block block;
};// __attribute__((packed));
}PACKEDSTRUCT;
struct iguana_blocks
{
@ -233,34 +239,34 @@ struct iguana_ledger
{
struct iguana_counts snapshot;
//struct iguana_account accounts[];
};// __attribute__((packed));
}PACKEDSTRUCT;
// ramchain temp file structures
struct iguana_unspent20 { uint64_t value; uint32_t scriptpos,txidind:28,type:4; uint16_t scriptlen,fileid; uint8_t rmd160[20]; };// __attribute__((packed));
struct iguana_spend256 { bits256 prevhash2; uint64_t scriptpos:48,vinscriptlen:16; uint32_t sequenceid; int16_t prevout; uint16_t spendind,fileid; };// __attribute__((packed));
struct iguana_unspent20 { uint64_t value; uint32_t scriptpos,txidind:28,type:4; uint16_t scriptlen,fileid; uint8_t rmd160[20]; }PACKEDSTRUCT;
struct iguana_spend256 { bits256 prevhash2; uint64_t scriptpos:48,vinscriptlen:16; uint32_t sequenceid; int16_t prevout; uint16_t spendind,fileid; }PACKEDSTRUCT;
// permanent readonly structs
struct iguana_txid { bits256 txid; uint64_t txidind:29,firstvout:28,firstvin:28,bundlei:11,locktime:32,version:32,timestamp:32,extraoffset:32; uint16_t numvouts,numvins; };// __attribute__((packed));
struct iguana_txid { bits256 txid; uint64_t txidind:29,firstvout:28,firstvin:28,bundlei:11,locktime:32,version:32,timestamp:32,extraoffset:32; uint16_t numvouts,numvins; }PACKEDSTRUCT;
struct iguana_unspent { uint64_t value; uint32_t txidind,pkind,prevunspentind,scriptpos; uint16_t scriptlen,hdrsi; uint16_t fileid:11,type:5; int16_t vout; };// __attribute__((packed));
struct iguana_unspent { uint64_t value; uint32_t txidind,pkind,prevunspentind,scriptpos; uint16_t scriptlen,hdrsi; uint16_t fileid:11,type:5; int16_t vout; }PACKEDSTRUCT;
struct iguana_spend { uint64_t scriptpos:48,scriptlen:16; uint32_t spendtxidind,sequenceid; int16_t prevout; uint16_t fileid:15,external:1; };// __attribute__((packed)); // numsigs:4,numpubkeys:4,p2sh:1,sighash:4
struct iguana_spend { uint64_t scriptpos:48,scriptlen:16; uint32_t spendtxidind,sequenceid; int16_t prevout; uint16_t fileid:15,external:1; }PACKEDSTRUCT; // numsigs:4,numpubkeys:4,p2sh:1,sighash:4
struct iguana_pkhash { uint8_t rmd160[20]; uint32_t pkind; };// __attribute__((packed)); //firstunspentind,pubkeyoffset
struct iguana_pkhash { uint8_t rmd160[20]; uint32_t pkind; }PACKEDSTRUCT; //firstunspentind,pubkeyoffset
// dynamic
struct iguana_account { int64_t total; uint32_t lastunspentind; };// __attribute__((packed));
struct iguana_utxo { uint32_t fromheight:31,lockedflag:1,prevunspentind:31,spentflag:1,spendind; };// __attribute__((packed));
struct iguana_account { int64_t total; uint32_t lastunspentind; }PACKEDSTRUCT;
struct iguana_utxo { uint32_t fromheight:31,lockedflag:1,prevunspentind:31,spentflag:1,spendind; }PACKEDSTRUCT;
#ifdef DEPRECATED_HHUTXO
struct iguana_hhaccount { UT_hash_handle hh; uint64_t pval; struct iguana_account a; };// __attribute__((packed));
struct iguana_hhaccount { UT_hash_handle hh; uint64_t pval; struct iguana_account a; }PACKEDSTRUCT;
#endif
struct iguana_hhutxo { UT_hash_handle hh; uint64_t uval; struct iguana_utxo u; };// __attribute__((packed));
struct iguana_utxoaddr { UT_hash_handle hh; int64_t histbalance; uint32_t pkind:31,searchedhist:1; uint16_t hdrsi; uint8_t rmd160[20]; };// __attribute__((packed));
struct iguana_hhutxo { UT_hash_handle hh; uint64_t uval; struct iguana_utxo u; }PACKEDSTRUCT;
struct iguana_utxoaddr { UT_hash_handle hh; int64_t histbalance; uint32_t pkind:31,searchedhist:1; uint16_t hdrsi; uint8_t rmd160[20]; }PACKEDSTRUCT;
// GLOBAL one zero to non-zero write (unless reorg)
struct iguana_spendvector { uint64_t value; uint32_t pkind,unspentind; int32_t fromheight; uint16_t hdrsi:15,tmpflag:1; };// __attribute__((packed)); // unspentind
//struct iguana_pkextra { uint32_t firstspendind; } __attribute__((packed)); // pkind
struct iguana_spendvector { uint64_t value; uint32_t pkind,unspentind; int32_t fromheight; uint16_t hdrsi:15,tmpflag:1; }PACKEDSTRUCT; // unspentind
//struct iguana_pkextra { uint32_t firstspendind; } PACKEDSTRUCT; // pkind
struct iguana_txblock
{

2
m_onetime

@ -20,5 +20,5 @@ cd crypto777
./$1
cd ..
cd iguana
./m_unix
./$1
../agents/iguana

2
pnacl_main.h

@ -6,13 +6,13 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef _WIN32
#include "OSlibs/win/pthread.h"
#include <windows.h>
//static inline void sleep(unsigned ms) { Sleep(ms*1000); }
#else
#include <unistd.h>
#include <pthread.h>
#endif

Loading…
Cancel
Save