You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

234 lines
8.4 KiB

9 years ago
/******************************************************************************
* Copyright © 2014-2018 The SuperNET Developers. *
9 years ago
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* SuperNET software, including this file may be copied, modified, propagated *
* or distributed except according to the terms contained in the LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
8 years ago
/*
adding assetchain coin: copy genCOIN to SuperNET/iguana/coins, make a _7776 variant with RELAY=-1 and VALIDATE=0
8 years ago
copy that into basilisk as coin, changing RELAY -> 0
8 years ago
*/
7 years ago
/*
To add a new dPoW'ed assetchain with DEX* API support:
1. add to komodo/src: assetchains, assetchains.old, 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. make coins/basilisk/<ac_name>
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
7 years ago
8. m_splitfunds
7 years ago
*/
9 years ago
#ifndef iguana777_net_h
#define iguana777_net_h
8 years ago
#if defined(_WIN32) || defined(_WIN64)
8 years ago
#ifndef WIN32
8 years ago
#define WIN32
#endif
8 years ago
#endif
8 years ago
9 years ago
#if (defined(_WIN32) || defined(__WIN32__)) && \
!defined(WIN32) && !defined(__SYMBIAN32__)
8 years ago
#ifndef WIN32
9 years ago
#define WIN32
8 years ago
#endif
8 years ago
#endif
8 years ago
#ifdef WIN32
8 years ago
#define __MINGW
8 years ago
8 years ago
#else
8 years ago
#ifndef __MINGW
8 years ago
#include <arpa/inet.h>
9 years ago
#endif
8 years ago
#endif
9 years ago
8 years ago
#define LOCKTIME_THRESHOLD 500000000
8 years ago
#define KOMODO_INTEREST ((uint64_t)(0.05 * SATOSHIDEN)) // 5% CANNOT CHANGE as komodo_interest.h div 20
8 years ago
9 years ago
//#define BTC2_VERSION
#define BTC2_HARDFORK_HEIGHT 444444
#define BTC2_SIGHASH_FORKID 0xcf
#define BTC2_NETMAGIC 0xaabbccdd
#define BTC2_DEFAULT_PORT 8222
#define BTC2_DIFF_WINDOW 60
8 years ago
/*#ifdef __APPLE__
8 years ago
#define ISNOTARYNODE 1
#include "nn.h"
#include "bus.h"
8 years ago
#else*/
8 years ago
//#ifdef __APPLE__
#if defined(__APPLE__) || defined(WIN32) || defined(USE_STATIC_NANOMSG)
8 years ago
#include "../crypto777/nanosrc/nn.h"
#include "../crypto777/nanosrc/bus.h"
#include "../crypto777/nanosrc/pubsub.h"
8 years ago
#include "../crypto777/nanosrc/pipeline.h"
8 years ago
#include "../crypto777/nanosrc/reqrep.h"
8 years ago
#include "../crypto777/nanosrc/tcp.h"
#else
8 years ago
#include "/usr/local/include/nanomsg/nn.h"
8 years ago
#include "/usr/local/include/nanomsg/bus.h"
#include "/usr/local/include/nanomsg/pubsub.h"
8 years ago
#include "/usr/local/include/nanomsg/pipeline.h"
8 years ago
#include "/usr/local/include/nanomsg/reqrep.h"
#include "/usr/local/include/nanomsg/tcp.h"
8 years ago
#endif
8 years ago
struct supernet_info;
struct exchange_info;
#include "../crypto777/OS_portable.h"
9 years ago
#include "../datachain/datachain.h"
9 years ago
#include "../includes/iguana_defines.h"
#include "../includes/iguana_types.h"
#include "../includes/iguana_structs.h"
9 years ago
#include "../basilisk/basilisk.h"
#include "dPoW.h"
9 years ago
struct supernet_address
{
bits256 pubkey,iphash,persistent;
uint32_t selfipbits,myipbits; int32_t confirmed,totalconfirmed; uint64_t nxt64bits;
char NXTADDR[32],BTC[64],BTCD[64];
};
9 years ago
struct smartaddress_symbol { double maxbid,minask,srcavail,destamount; char symbol[16]; };
8 years ago
8 years ago
struct smartaddress
{
bits256 privkey,pubkey;
8 years ago
int32_t numsymbols;
8 years ago
uint8_t pubkey33[33],rmd160[20];
8 years ago
char typestr[16];
struct smartaddress_symbol *symbols;
8 years ago
};
8 years ago
struct pending_trade { UT_hash_handle hh; double basevolume,relvolume,dir; char base[32],rel[32]; };
8 years ago
#define PSOCK_IDLETIMEOUT 600
struct psock { uint32_t lasttime; int32_t pullsock,pubsock; uint16_t pushport,subport; };
#define JUMBLR_DEPOSITPREFIX "deposit "
struct jumblr_item
{
UT_hash_handle hh;
int64_t amount,fee,txfee;
8 years ago
uint32_t spent,pad;
char opid[64],src[128],dest[128],status;
};
8 years ago
struct liquidity_info
{
char base[16],rel[16],exchange[16];
uint64_t assetid;
8 years ago
double profit,refprice,bid,ask,minvol,maxvol,totalvol;
8 years ago
};
8 years ago
struct message_info { int32_t msgcount; bits256 refhash,msghashes[64]; uint32_t timestamps[64]; };
8 years ago
9 years ago
struct supernet_info
{
struct supernet_address myaddr;
8 years ago
bits256 persistent_priv,privkey,jumblr_pubkey,jumblr_depositkey;
9 years ago
uint8_t persistent_pubkey33[33];
char ipaddr[64],NXTAPIURL[512],secret[4096],password[4096],rpcsymbol[64],handle[1024],permanentfile[1024],jumblr_passphrase[1024];
9 years ago
char *decryptstr;
void (*liquidity_command)(struct supernet_info *myinfo,char *base,bits256 hash,cJSON *vals);
double (*liquidity_active)(struct supernet_info *myinfo,double *refpricep,char *exchange,char *base,char *rel,double volume);
8 years ago
int32_t maxdelay,IAMRELAY,IAMNOTARY,IAMLP,publicRPC,basilisk_busy,genesisresults,remoteorigin;
8 years ago
uint32_t expiration,dirty,DEXactive,DEXpoll,totalcoins,nanoinit,lastdexrequestid,dexcrcs[1024];
9 years ago
uint16_t argport,rpcport;
struct basilisk_info basilisks;
struct jumblr_item *jumblrs;
9 years ago
struct exchange_info *tradingexchanges[SUPERNET_MAXEXCHANGES]; int32_t numexchanges;
struct iguana_waccount *wallet;
struct iguana_info *allcoins; int32_t allcoins_being_added,allcoins_numvirts;
7 years ago
portable_mutex_t bu_mutex,allcoins_mutex,gecko_mutex,basilisk_mutex,DEX_mutex,DEX_reqmutex,DEX_swapmutex,smart_mutex,MoM_mutex;
8 years ago
struct queueitem *DEX_quotes; cJSON *Cunspents,*Cspends;
9 years ago
struct basilisk_swap *swaps[256]; int32_t numswaps;
struct basilisk_message *messagetable; portable_mutex_t messagemutex; queue_t msgQ,p2pQ;
7 years ago
void *ctx;
9 years ago
uint8_t *pingbuf;
8 years ago
struct basilisk_request DEXaccept;
8 years ago
FILE *dexfp;
7 years ago
struct dpow_info *DPOWS[8192]; int32_t numdpows,dpowsock,dexsock,pubsock,repsock,subsock,reqsock;
9 years ago
struct delayedPoW_info dPoW;
9 years ago
struct basilisk_spend *spends; int32_t numspends;
8 years ago
char bindaddr[64];
char blocktrail_apikey[256];
struct peggy_info *PEGS;
8 years ago
void *PAXDATA;
8 years ago
struct liquidity_info linfos[512]; cJSON *liquidity_currencies; struct pending_trade *trades; portable_mutex_t pending_mutex;
8 years ago
struct komodo_notaries NOTARY;
8 years ago
char seedipaddr[64]; uint32_t dpowipbits[128]; int32_t numdpowipbits; portable_mutex_t notarymutex,dpowmutex;
8 years ago
#ifdef NOTARY_TESTMODE
char dexseed_ipaddrs[1][64];
#else
8 years ago
char dexseed_ipaddrs[4][64];
8 years ago
#endif
uint32_t dexipbits[128]; int32_t numdexipbits; portable_mutex_t dexmutex;
9 years ago
// compatibility
bits256 pangea_category,instantdex_category;
9 years ago
uint8_t logs[256],exps[510];
8 years ago
struct message_info msgids[8192];
double *svmfeatures;
8 years ago
uint16_t psockport,numpsocks; struct psock *PSOCKS; portable_mutex_t psockmutex;
8 years ago
uint8_t notaries[64][33]; int32_t numnotaries,DEXEXPLORER;
8 years ago
FILE *swapsfp;
8 years ago
double DEXratio;
8 years ago
struct smartaddress smartaddrs[64]; int32_t numsmartaddrs,cancelrefresh,runsilent,DEXtrades;
9 years ago
};
9 years ago
8 years ago
struct basilisk_swapmessage
{
bits256 srchash,desthash;
uint32_t crc32,msgbits,quoteid,datalen;
uint8_t *data;
};
8 years ago
struct basilisk_swap
{
8 years ago
struct supernet_info *myinfoptr; struct iguana_info *bobcoin,*alicecoin;
8 years ago
void (*balancingtrade)(struct supernet_info *myinfo,struct basilisk_swap *swap,int32_t iambob);
8 years ago
int32_t subsock,pushsock,connected,aliceunconf,depositunconf,paymentunconf; uint32_t lasttime,aborted;
8 years ago
FILE *fp;
8 years ago
bits256 persistent_privkey,persistent_pubkey;
8 years ago
struct basilisk_swapinfo I;
8 years ago
struct basilisk_rawtx bobdeposit,bobpayment,alicepayment,myfee,otherfee,aliceclaim,alicespend,bobreclaim,bobspend,bobrefund,alicereclaim;
8 years ago
bits256 privkeys[INSTANTDEX_DECKSIZE];
8 years ago
struct basilisk_swapmessage *messages; int32_t nummessages;
8 years ago
char Bdeposit[64],Bpayment[64];
8 years ago
uint64_t otherdeck[INSTANTDEX_DECKSIZE][2],deck[INSTANTDEX_DECKSIZE][2];
8 years ago
uint8_t persistent_pubkey33[33],pad[15],verifybuf[65536];
8 years ago
};
8 years ago
#include "../includes/iguana_funcs.h"
#include "../includes/iguana_globals.h"
#include "../gecko/gecko.h"
8 years ago
#ifndef MAX
#define MAX(a,b) ((a) >= (b) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
9 years ago
#endif