diff --git a/crypto777/curve25519.c b/crypto777/curve25519.c index ec23175f8..05d906c56 100755 --- a/crypto777/curve25519.c +++ b/crypto777/curve25519.c @@ -16,11 +16,11 @@ #include "../includes/curve25519.h" -#undef force_inline -#define force_inline __attribute__((always_inline)) +//#undef force_inline +//#define force_inline __attribute__((always_inline)) // Sum two numbers: output += in -static inline bits320 force_inline fsum(bits320 output,bits320 in) +static inline bits320 fsum(bits320 output,bits320 in) { int32_t i; for (i=0; i<5; i++) @@ -28,7 +28,7 @@ static inline bits320 force_inline fsum(bits320 output,bits320 in) return(output); } -static inline void force_inline fdifference_backwards(uint64_t *out,const uint64_t *in) +static inline void fdifference_backwards(uint64_t *out,const uint64_t *in) { static const uint64_t two54m152 = (((uint64_t)1) << 54) - 152; // 152 is 19 << 3 static const uint64_t two54m8 = (((uint64_t)1) << 54) - 8; @@ -38,14 +38,14 @@ static inline void force_inline fdifference_backwards(uint64_t *out,const uint64 out[i] = in[i] + two54m8 - out[i]; } -inline void force_inline store_limb(uint8_t *out,uint64_t in) +inline void store_limb(uint8_t *out,uint64_t in) { int32_t i; for (i=0; i<8; i++,in>>=8) out[i] = (in & 0xff); } -static inline uint64_t force_inline load_limb(uint8_t *in) +static inline uint64_t load_limb(uint8_t *in) { return ((uint64_t)in[0]) | @@ -75,7 +75,7 @@ bits320 fexpand(bits256 basepoint) typedef unsigned uint128_t __attribute__((mode(TI))); // Multiply a number by a scalar: output = in * scalar -static inline bits320 force_inline fscalar_product(const bits320 in,const uint64_t scalar) +static inline bits320 fscalar_product(const bits320 in,const uint64_t scalar) { int32_t i; uint128_t a = 0; bits320 output; a = ((uint128_t)in.ulongs[0]) * scalar; @@ -119,7 +119,7 @@ bits320 fmul(const bits320 in2,const bits320 in) return(out); } -inline bits320 force_inline fsquare_times(const bits320 in,uint64_t count) +inline 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]; @@ -149,7 +149,7 @@ inline bits320 force_inline fsquare_times(const bits320 in,uint64_t count) return(out); } -static inline void force_inline fcontract_iter(uint128_t t[5],int32_t flag) +static inline void fcontract_iter(uint128_t t[5],int32_t flag) { int32_t i; uint64_t mask = 0x7ffffffffffffLL; for (i=0; i<4; i++) @@ -711,7 +711,7 @@ bits320 bits320_limbs(limb limbs[10]) return(output); } -static inline bits320 force_inline fscalar_product(const bits320 in,const uint64_t scalar) +static inline bits320 fscalar_product(const bits320 in,const uint64_t scalar) { limb output[10],input[10]; int32_t i; for (i=0; i<10; i++) @@ -720,7 +720,7 @@ static inline bits320 force_inline fscalar_product(const bits320 in,const uint64 return(bits320_limbs(output)); } -static inline bits320 force_inline fsquare_times(const bits320 in,uint64_t count) +static inline bits320 fsquare_times(const bits320 in,uint64_t count) { limb output[10],input[10]; int32_t i; for (i=0; i<10; i++) @@ -776,7 +776,7 @@ bits256 curve25519(bits256 mysecret,bits256 theirpublic) // x2 z2: long form && x3 z3: long form // x z: short form, destroyed && xprime zprime: short form, destroyed // qmqp: short form, preserved -static inline void force_inline +static inline void fmonty(bits320 *x2, bits320 *z2, // output 2Q bits320 *x3, bits320 *z3, // output Q + Q' bits320 *x, bits320 *z, // input Q @@ -804,7 +804,7 @@ fmonty(bits320 *x2, bits320 *z2, // output 2Q // long. Perform the swap iff @swap is non-zero. // This function performs the swap without leaking any side-channel information. // ----------------------------------------------------------------------------- -static inline void force_inline swap_conditional(bits320 *a,bits320 *b,uint64_t iswap) +static inline void swap_conditional(bits320 *a,bits320 *b,uint64_t iswap) { int32_t i; const uint64_t swap = -iswap; for (i=0; i<5; ++i) @@ -846,7 +846,7 @@ void cmult(bits320 *resultx,bits320 *resultz,bits256 secret,const bits320 q) } // Shamelessly copied from donna's code that copied djb's code, changed a little -inline bits320 force_inline crecip(const bits320 z) +inline bits320 crecip(const bits320 z) { bits320 a,t0,b,c; /* 2 */ a = fsquare_times(z, 1); // a = 2 @@ -1888,4 +1888,4 @@ uint8_t *_SuperNET_decipher(uint8_t nonce[crypto_box_NONCEBYTES],uint8_t *cipher return(0); } -#undef force_inline +//#undef force_inline diff --git a/crypto777/iguana_OS.c b/crypto777/iguana_OS.c index 0ab6a7b2a..2c9fb7062 100755 --- a/crypto777/iguana_OS.c +++ b/crypto777/iguana_OS.c @@ -114,7 +114,7 @@ void *mycalloc(uint8_t type,int32_t n,long itemsize) item->allocsize = (uint32_t)allocsize; item->type = type; //portable_mutex_unlock(&MEMmutex); - return((void *)(long)item + sizeof(*item)); + return((void *)((long)item + sizeof(*item))); } void *queueitem(char *str) @@ -429,7 +429,7 @@ void *iguana_memalloc(struct OS_memspace *mem,long size,int32_t clearflag) #endif if ( (mem->used + size) <= mem->totalsize ) { - ptr = (void *)(long)((long)(mem->ptr + mem->used)); + ptr = (void *)(long)(((long)mem->ptr + mem->used)); mem->used += size; if ( size*clearflag != 0 ) memset(ptr,0,size); diff --git a/iguana/exchanges777.h b/iguana/exchanges777.h index 1b713c8df..3475c72a6 100755 --- a/iguana/exchanges777.h +++ b/iguana/exchanges777.h @@ -83,10 +83,10 @@ struct exchange_info struct instantdex_msghdr { - struct acct777_sig sig __attribute__((packed)); + struct acct777_sig sig; // __attribute__((packed)) char cmd[8]; uint8_t serialized[]; -} __attribute__((packed)); +}; // __attribute__((packed)) #define NXT_ASSETID ('N' + ((uint64_t)'X'<<8) + ((uint64_t)'T'<<16)) // 5527630 #define INSTANTDEX_ACCT "4383817337783094122" diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 1f3151c86..869fcb1aa 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -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); } diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 37f45c013..ddde9ab9a 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -19,6 +19,8 @@ #if (defined(_WIN32) || defined(__WIN32__)) && \ !defined(WIN32) && !defined(__SYMBIAN32__) #define WIN32 +#define __MINGW +#define _CRT_SECURE_NO_WARNINGS #else #ifndef __MINGW #include diff --git a/iguana/iguana_tx.c b/iguana/iguana_tx.c index b3a04ed60..ccac70870 100755 --- a/iguana/iguana_tx.c +++ b/iguana/iguana_tx.c @@ -14,13 +14,6 @@ ******************************************************************************/ #include "iguana777.h" -//#include "SuperNET.h" - -//struct iguana_txid { bits256 txid; uint32_t txidind,firstvout,firstvin,locktime,version,timestamp; uint16_t numvouts,numvins; } __attribute__((packed)); - -//struct iguana_msgvin { bits256 prev_hash; uint8_t *script; uint32_t prev_vout,scriptlen,sequence; } __attribute__((packed)); - -//struct iguana_spend { uint32_t spendtxidind; int16_t prevout; uint16_t tbd:14,external:1,diffsequence:1; } __attribute__((packed)); int32_t iguana_scriptdata(struct iguana_info *coin,uint8_t *scriptspace,long fileptr[2],char *fname,uint64_t scriptpos,int32_t scriptlen) { diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 38dc804eb..afa7c4ef1 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -266,7 +266,6 @@ cJSON *iguana_RTunspentjson(struct supernet_info *myinfo,struct iguana_info *coi "confirmations" : 6210, "spendable" : true },*/ - //struct iguana_unspent { uint64_t value; uint32_t txidind,pkind,prevunspentind; uint16_t hdrsi:12,type:4,vout; } __attribute__((packed)); struct iguana_waccount *wacct; struct iguana_waddress *waddr; int32_t height; char scriptstr[8192],asmstr[sizeof(scriptstr)+1024]; cJSON *item; uint32_t checkind; struct iguana_RTunspent *unspent; struct iguana_block *block; item = cJSON_CreateObject(); jaddbits256(item,"txid",txid); diff --git a/includes/curve25519.h b/includes/curve25519.h index cff0e0e02..9f8c9ba16 100755 --- a/includes/curve25519.h +++ b/includes/curve25519.h @@ -36,8 +36,8 @@ struct rmd160_vstate { uint64_t length; uint8_t buf[64]; uint32_t curlen, state[ struct acct777_sig { bits256 sigbits,pubkey; uint64_t signer64bits; uint32_t timestamp,allocsize; }; -#undef force_inline -#define force_inline __attribute__((always_inline)) +//#undef force_inline +//#define force_inline __attribute__((always_inline)) bits320 fmul(const bits320 in2,const bits320 in); diff --git a/includes/iguana_defines.h b/includes/iguana_defines.h index db86a677e..720cb2d8f 100755 --- a/includes/iguana_defines.h +++ b/includes/iguana_defines.h @@ -27,7 +27,7 @@ #else #define IGUANA_MAXITERATIONS 7777 #endif -#define IGUANA_DEFAULTLAG 30 +#define IGUANA_DEFAULTLAG 7 #define IGUANA_MAXHEIGHT (1 << 30) #define IGUANA_MAXCOINS 64 diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index dd67f1b6a..50f57a4c0 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -53,7 +53,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; };// __attribute__((packed)); struct iguana_msgversion { @@ -65,7 +65,7 @@ struct iguana_msgversion char strSubVer[80]; uint32_t nStartingHeight; uint8_t relayflag; -} __attribute__((packed)); +};// __attribute__((packed)); struct iguana_msgalert // warning, many varints/variable length fields, struct is 1:1 { @@ -91,14 +91,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)); +};// __attribute__((packed)); struct iguana_msgblockhdr { uint32_t version; bits256 prev_block,merkle_root; uint32_t timestamp,bits,nonce; -} __attribute__((packed)); +};// __attribute__((packed)); #define ZKSNARK_PROOF_SIZE 584 #define ZCASH_SOLUTION_ELEMENTS 32 @@ -109,25 +109,25 @@ struct iguana_msgblockhdr_zcash uint8_t numelements; uint32_t solution[ZCASH_SOLUTION_ELEMENTS]; //bits256 reserved; // only here if auxpow is set -} __attribute__((packed)); +};// __attribute__((packed)); struct iguana_msgmerkle { uint32_t branch_length; bits256 branch_hash[4096]; uint32_t branch_side_mask; -} __attribute__((packed)); +};// __attribute__((packed)); struct iguana_msgblock { struct iguana_msgblockhdr H; // double hashed for blockhash struct iguana_msgblockhdr_zcash zH; uint32_t txn_count; -} __attribute__((packed)); +};// __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; } __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; };// __attribute__((packed)); -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; };// __attribute__((packed)); struct iguana_msgtx { @@ -138,7 +138,7 @@ struct iguana_msgtx int32_t allocsize,timestamp,numinputs,numoutputs; int64_t inputsum,outputsum,txfee; uint8_t *serialized; -} __attribute__((packed)); +};// __attribute__((packed)); struct iguana_msgjoinsplit { @@ -147,7 +147,7 @@ struct iguana_msgjoinsplit uint8_t ciphertexts[2][217]; bits256 randomseed,vmacs[2]; uint8_t zkproof[ZKSNARK_PROOF_SIZE-1]; -} __attribute__((packed)); +};// __attribute__((packed)); struct iguana_packet { struct queueitem DL; struct iguana_peer *addr; struct tai embargo; int32_t datalen,getdatablock; uint8_t serialized[]; }; @@ -173,15 +173,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)); +};// __attribute__((packed)); -struct iguana_zcashRO { bits256 bignonce; uint32_t solution[ZCASH_SOLUTION_ELEMENTS]; } __attribute__((packed)); +struct iguana_zcashRO { bits256 bignonce; uint32_t solution[ZCASH_SOLUTION_ELEMENTS]; };// __attribute__((packed)); struct iguana_zblockRO { struct iguana_blockRO RO; struct iguana_zcashRO zRO; -} __attribute__((packed)); +};// __attribute__((packed)); #define iguana_blockfields double PoW; \ int32_t height,fpos; uint32_t fpipbits,issued,lag:18,sigsvalid:1,protected:1,peerid:12; \ @@ -193,13 +193,13 @@ struct iguana_block { iguana_blockfields; struct iguana_zcashRO zRO[]; -} __attribute__((packed)); +};// __attribute__((packed)); struct iguana_zblock // mu { iguana_blockfields; struct iguana_zcashRO zRO; -} __attribute__((packed)); +};// __attribute__((packed)); #define IGUANA_LHASH_BLOCKS 0 #define IGUANA_LHASH_TXIDS 1 // @@ -218,7 +218,7 @@ struct iguana_counts uint32_t firsttxidind,firstunspentind,firstspendind,firstpkind; uint64_t credits,debits; struct iguana_block block; -} __attribute__((packed)); +};// __attribute__((packed)); struct iguana_blocks { @@ -233,33 +233,33 @@ struct iguana_ledger { struct iguana_counts snapshot; //struct iguana_account accounts[]; -} __attribute__((packed)); +};// __attribute__((packed)); // 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]; };// __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)); // 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; };// __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; } __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; };// __attribute__((packed)); -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; };// __attribute__((packed)); // 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; };// __attribute__((packed)); //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; };// __attribute__((packed)); +struct iguana_utxo { uint32_t fromheight:31,lockedflag:1,prevunspentind:31,spentflag:1,spendind; };// __attribute__((packed)); #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; };// __attribute__((packed)); #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; };// __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)); // 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_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_txblock @@ -522,7 +522,8 @@ struct basilisk_request //char volatile_start,message[43]; uint64_t destamount; uint32_t relaybits; -} __attribute__((packed)); +}; // __attribute__((packed)) + struct basilisk_relaystatus { uint8_t pingdelay;