Hush Delayed Proof Of Work Dragon
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.
 
 
 
 

599 lines
24 KiB

/******************************************************************************
* Copyright © 2018-2020 The Hush Developers *
* Copyright © 2014-2018 The SuperNET Developers. *
* *
* 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. *
* *
******************************************************************************/
#ifndef H_DRAGONSTRUCTS_H
#define H_DRAGONSTRUCTS_H
#ifdef WIN32
#define PACKEDSTRUCT
#else
#define PACKEDSTRUCT __attribute__((packed))
#endif
struct dragon_thread
{
struct queueitem DL;
pthread_t handle;
struct dragon_info *coin;
char name[16];
uint8_t type;
dragon_func funcp;
void *arg;
};
struct dragon_blockreq { struct queueitem DL; bits256 hash2,*blockhashes; struct dragon_bundle *bp; int32_t n,height,bundlei; };
struct dragon_peermsgrequest { struct queueitem DL; struct dragon_peer *addr; bits256 hash2; int32_t type; };
struct dragon_chain
{
//const int32_t chain_id;
char name[32],symbol[16],messagemagic[64];
uint8_t pubtype,p2shtype,wiftype,netmagic[4];
char *genesis_hash,*genesis_hex; // hex string
uint16_t portp2p,rpcport;
uint8_t isPoS,unitval;
uint64_t rewards[512][2];
uint8_t genesis_hashdata[32],minconfirms;
uint16_t bundlesize,hasheaders;
char gethdrsmsg[16];
uint64_t txfee,minoutput,dust,halvingduration,initialreward;
blockhashfunc hashalgo;
char userhome[512],serverport[128],userpass[1024];
char use_addmultisig,do_opreturn;
int32_t estblocktime,protover;
bits256 genesishash2,PoWtarget,PoStargets[16]; int32_t numPoStargets,PoSheights[16];
uint8_t zcash,fixit,auxpow,debug,havecltv,alertpubkey[65];
uint16_t targetspacing,targettimespan; uint32_t nBits,normal_txversion,locktime_txversion;
};
struct dragon_msgaddress { uint32_t nTime; uint64_t nServices; uint8_t ip[16]; uint16_t port; }PACKEDSTRUCT;
struct dragon_msgversion
{
uint32_t nVersion;
uint64_t nServices;
int64_t nTime;
struct dragon_msgaddress addrTo,addrFrom;
uint64_t nonce;
char strSubVer[80];
uint32_t nStartingHeight;
uint8_t relayflag;
}PACKEDSTRUCT;
struct dragon_msgalert // warning, many varints/variable length fields, struct is 1:1
{
int32_t version;
int64_t relayuntil,expiration;
int32_t ID,cancel;
uint32_t numcancellist;
int32_t minver,maxver;
uint32_t setsubvervar; char subver[1024];
int32_t priority;
char comment[1024],statusbar[1024],reserved[1024];
uint8_t siglen,sig[74];
uint32_t list[64];
};
struct dragon_VPNversion
{
uint32_t nVersion;
uint64_t nServices;
int64_t nTime;
struct dragon_msgaddress addrTo,addrFrom;
uint64_t nonce;
char strSubVer[80];
uint32_t nStartingHeight;
uint32_t iVer,v_Network_id; uint16_t wPort; uint8_t bIsGui; uint16_t wCtPort,wPrPort;
} PACKEDSTRUCT;
struct dragon_msgblockhdr
{
uint32_t version;
bits256 prev_block,merkle_root;
uint32_t timestamp,bits,nonce;
} PACKEDSTRUCT;
#define LP_IS_ZCASHPROTOCOL 1
#define SIGHASH_FORKID 0x40
#define ZKSNARK_PROOF_SIZE 296
#define GROTH_PROOF_SIZE 192
#define SAPLING_AUTH_SIG_SIZE 64
#define ENC_CIPHER_SIZE 580
#define OUT_CIPHER_SIZE 80
#define ZCASH_SOLUTION_ELEMENTS 1344
struct dragon_msgzblockhdr
{
uint32_t version;
bits256 prev_block,merkle_root,reserved;
uint32_t timestamp,bits;
bits256 bignonce;
uint8_t var_numelements[3];
uint8_t solution[ZCASH_SOLUTION_ELEMENTS];
} PACKEDSTRUCT;
/*int32_t nVersion;
uint256 hashPrevBlock;
uint256 hashMerkleRoot;
uint256 hashReserved;
uint32_t nTime;
uint32_t nBits;
uint256 nNonce;
std::vector<unsigned char> nSolution;*/
/*struct dragon_msgblockhdr_zcash
{
bits256 bignonce;
uint8_t numelements;
uint32_t solution[ZCASH_SOLUTION_ELEMENTS];
//bits256 reserved; // only here if auxpow is set
}PACKEDSTRUCT;*/
struct dragon_msgmerkle
{
uint32_t branch_length;
bits256 branch_hash[4096];
uint32_t branch_side_mask;
}; //PACKEDSTRUCT;
struct dragon_msgblock
{
struct dragon_msgblockhdr H; // double hashed for blockhash
uint32_t txn_count;
} PACKEDSTRUCT;
struct dragon_msgzblock
{
struct dragon_msgzblockhdr zH; // double hashed for blockhash
uint32_t txn_count;
} PACKEDSTRUCT;
struct dragon_msgvin { bits256 prev_hash; uint8_t *vinscript,*userdata,*spendscript,*redeemscript; uint32_t prev_vout,sequence; uint16_t scriptlen,p2shlen,userdatalen,spendlen; }; //PACKEDSTRUCT;
struct dragon_msgvout { uint64_t value; uint32_t pk_scriptlen; uint8_t *pk_script; }; //PACKEDSTRUCT;
struct dragon_msgtx
{
uint32_t version, version_group_id, tx_in, tx_out, lock_time, expiry_height;
struct dragon_msgvin *vins;
struct dragon_msgvout *vouts;
struct sapling_spend_description *shielded_spends;
struct sapling_output_description *shielded_outputs;
bits256 txid;
int32_t allocsize, timestamp, numinputs, numoutputs;
int64_t inputsum, outputsum, txfee;
uint8_t *serialized, shielded_spend_num, shielded_output_num, numjoinsplits;
uint64_t value_balance;
uint8_t binding_sig[64];
};// PACKEDSTRUCT;
struct dragon_msgjoinsplit
{
uint64_t vpub_old,vpub_new;
bits256 anchor,nullifiers[2],commitments[2],ephemeralkey;
bits256 randomseed,vmacs[2];
uint8_t zkproof[ZKSNARK_PROOF_SIZE];
uint8_t ciphertexts[2][601];
}PACKEDSTRUCT;
struct sapling_spend_description {
bits256 cv, anchor, nullifier, rk;
uint8_t zkproof[GROTH_PROOF_SIZE], spend_auth_sig[SAPLING_AUTH_SIG_SIZE];
};
struct sapling_output_description {
bits256 cv, cm, ephemeral_key;
uint8_t zkproof[GROTH_PROOF_SIZE], enc_ciphertext[ENC_CIPHER_SIZE], out_ciphertext[OUT_CIPHER_SIZE];
};
struct dragon_packet { struct queueitem DL; struct dragon_peer *addr; struct tai embargo; int32_t datalen,getdatablock; uint8_t serialized[]; };
struct msgcounts { uint32_t version,verack,getaddr,addr,inv,getdata,notfound,getblocks,getheaders,headers,tx,block,mempool,ping,pong,reject,filterload,filteradd,filterclear,merkleblock,alert; };
//struct dragon_fileitem { bits256 hash2; struct dragon_txdatabits txdatabits; };
struct dragon_kvitem { UT_hash_handle hh; uint8_t keyvalue[]; };
struct dragon_iAddr
{
UT_hash_handle hh; uint64_t ipbits;
uint32_t lastkilled,lastconnect;
int32_t status,height,numkilled,numconnects;
};
struct dragon_cacheptr { struct queueitem DL; int32_t allocsize,recvlen; uint8_t *data; };
// dragon blocks
struct dragon_blockRO
{
bits256 hash2,prev_block,merkle_root;
uint32_t timestamp,nonce,bits,version;
uint32_t firsttxidind,firstvin,firstvout,firstpkind,firstexternalind,recvlen:24,tbd:8;
uint16_t txn_count,numvouts,numvins,allocsize;
}PACKEDSTRUCT;
struct dragon_zcashRO { bits256 bignonce; uint32_t numelements; uint8_t solution[ZCASH_SOLUTION_ELEMENTS]; } PACKEDSTRUCT;
struct dragon_zblockRO
{
struct dragon_blockRO RO;
struct dragon_zcashRO zRO;
} PACKEDSTRUCT;
#define dragon_blockfields double PoW; \
int32_t height,fpos; uint32_t fpipbits,issued,lag:17,sigsvalid:1,protected:1,peerid:12,processed:1; \
uint16_t hdrsi:15,mainchain:1; int16_t bundlei:12,valid:1,queued:1,txvalid:1,newtx:1; \
UT_hash_handle hh; struct dragon_bundlereq *req; \
struct dragon_blockRO RO
struct dragon_block
{
dragon_blockfields;
struct dragon_zcashRO zRO[];
} ;
struct dragon_zblock // mu
{
dragon_blockfields; // this is to minimize code needed to support both types
struct dragon_zcashRO zRO; // if zRO is changed, the RO part must also be updated
} ;
#define DRAGON_LHASH_BLOCKS 0
#define DRAGON_LHASH_TXIDS 1 //
#define DRAGON_LHASH_UNSPENTS 2 //
#define DRAGON_LHASH_SPENDS 3 //
#define DRAGON_LHASH_PKHASHES 4 //
#define DRAGON_LHASH_ACCOUNTS 5 //
#define DRAGON_LHASH_EXTERNALS 6 //
#define DRAGON_LHASH_KSPACE 7 //
#define DRAGON_LHASH_TXBITS 8 //
#define DRAGON_LHASH_PKBITS 9 //
#define DRAGON_NUMLHASHES (DRAGON_LHASH_PKBITS + 1)
struct dragon_counts
{
uint32_t firsttxidind,firstunspentind,firstspendind,firstpkind;
uint64_t credits,debits;
struct dragon_block block;
} PACKEDSTRUCT;
struct dragon_blocks
{
char coin[16];
struct dragonkv *db;
struct dragon_block *hash;
int32_t maxblocks,initblocks,hashblocks,pending,issuedblocks,recvblocks,emitblocks,parsedblocks,dirty;
struct dragon_zblock hwmchain,prev,prev2;
};
struct dragon_ledger
{
struct dragon_counts snapshot;
//struct dragon_account accounts[];
} PACKEDSTRUCT;
// ramchain temp file structures
struct dragon_unspent20 { uint64_t value; uint32_t scriptpos,txidind:28,type:4; uint16_t scriptlen,fileid; uint8_t rmd160[20]; }PACKEDSTRUCT;
struct dragon_spend256 { bits256 prevhash2; uint64_t scriptpos:48,vinscriptlen:16; uint32_t sequenceid; int16_t prevout; uint16_t spendind,fileid; }PACKEDSTRUCT;
// permanent readonly structs
struct dragon_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 dragon_unspent { uint64_t value; uint32_t txidind,pkind,prevunspentind,scriptpos,scriptlen:13,fileid:14,type:5; uint16_t hdrsi; int16_t vout; } PACKEDSTRUCT;
struct dragon_spend { uint64_t scriptpos:48,scriptlen:16; uint32_t spendtxidind,sequenceid; int16_t prevout; uint16_t fileid:14,external:1,tbd:1; }PACKEDSTRUCT; // numsigs:4,numpubkeys:4,p2sh:1,sighash:4
struct dragon_pkhash { uint8_t rmd160[20]; uint32_t pkind; }PACKEDSTRUCT; //firstunspentind,pubkeyoffset
// dynamic
struct dragon_account { int64_t total; uint32_t lastunspentind; }PACKEDSTRUCT;
struct dragon_utxo { uint32_t fromheight:31,lockedflag:1,prevunspentind:31,spentflag:1,spendind; }PACKEDSTRUCT;
#ifdef DEPRECATED_HHUTXO
struct dragon_hhaccount { UT_hash_handle hh; uint64_t pval; struct dragon_account a; }PACKEDSTRUCT;
#endif
struct dragon_hhutxo { UT_hash_handle hh; uint64_t uval; struct dragon_utxo u; };
struct dragon_utxoaddr { UT_hash_handle hh; uint64_t histbalance; uint32_t pkind:30,p2sh:1,searchedhist:1; uint16_t hdrsi; uint8_t rmd160[20]; };
// GLOBAL one zero to non-zero write (unless reorg)
struct dragon_spendvector { uint64_t value; uint32_t pkind,unspentind; int32_t fromheight; uint16_t hdrsi:15,tmpflag:1; }PACKEDSTRUCT; // unspentind
//struct dragon_pkextra { uint32_t firstspendind; } PACKEDSTRUCT; // pkind
struct dragon_txblock
{
uint32_t numtxids,numunspents,numspends,extralen,recvlen;
// following set during second pass (still in peer context)
uint32_t numpkinds,numexternaltxids,datalen,pkoffset;
uint8_t space[256]; // order: extra[], T, U, S, P, external txids
struct dragon_zblock zblock;
};
#if defined(_M_X64)
/*
* calculate the address in a portable manner
* in all platform sizeof(char) / sizeof(uchar) == 1
* @author - fadedreamz@gmail.com
*/
#define RAMCHAIN_PTR(rdata,offset) ((void *)((unsigned char *)rdata + rdata->offset))
#else
#define RAMCHAIN_PTR(rdata,offset) ((void *)(long)((long)(rdata) + (long)(rdata)->offset))
#endif
struct dragon_ramchaindata
{
bits256 sha256;
bits256 lhashes[DRAGON_NUMLHASHES],firsthash2,prevhash2;
int64_t allocsize,Boffset,Toffset,Uoffset,Soffset,Poffset,Aoffset,Xoffset,TXoffset,PKoffset,Koffset;
int32_t numblocks,height,firsti,hdrsi,txsparsebits,pksparsebits;
uint32_t numtxids,numunspents,numspends,numpkinds,numexternaltxids,numtxsparse,numpksparse,scriptspace,stackspace;
uint8_t rdata[];
};
struct dragon_ramchain_hdr
{
uint32_t txidind,unspentind,spendind,scriptoffset,stacksize; uint16_t hdrsi,bundlei:15,ROflag:1;
struct dragon_ramchaindata *data;
};
struct dragon_ramchain
{
struct dragon_ramchain_hdr H; bits256 lasthash2; uint64_t datasize,allocatedA2,allocatedU2;
uint32_t numblocks:31,expanded:1,pkind,externalind,height,numXspends;
long sparseadds,sparsesearches,sparseadditers,sparsesearchiters,sparsehits,sparsemax;
struct dragon_kvitem *txids,*pkhashes;
struct OS_memspace *hashmem; long filesize,sigsfilesize,debitsfilesize,lastspendsfilesize;
void *fileptr,*sigsfileptr,*Xspendptr,*debitsfileptr,*lastspendsfileptr;
char from_ro,from_roX,from_roA,from_roU;
struct dragon_account *A,*A2,*creditsA; struct dragon_spendvector *Xspendinds;
struct dragon_utxo *Uextras; uint8_t *txbits; struct dragon_txid *cacheT;
//int16_t permutation[DRAGON_MAXBUNDLES];
//struct dragon_Uextra *U2,*roU2; struct dragon_pkextra *P2,*roP2;
};
struct dragon_peer
{
struct queueitem DL;
queue_t sendQ;
bits256 iphash,pubkey,persistent; uint32_t lastpersist; uint8_t netmagic[4];
struct dragon_msgaddress A;
char ipaddr[64],lastcommand[16],coinname[64],symbol[64];
uint64_t pingnonce,totalsent,totalrecv,ipbits; double pingtime,sendmillis,pingsum,getdatamillis;
uint32_t lastcontact,sendtime,ready,startsend,startrecv,pending,lastgotaddr,lastblockrecv,pendtime,lastflush,lastpoll,myipbits,persistent_peer,protover,numrecverrs;
int32_t supernet,dead,addrind,usock,lastheight,relayflag,numpackets,numpings,ipv6,height,rank,pendhdrs,pendblocks,recvhdrs,lastlefti,validpub,othervalid,dirty[2],laggard,headerserror,lastsent,isrelay;
double recvblocks,recvtotal;
int64_t allocated,freed;
bits256 RThashes[DRAGON_MAXBUNDLESIZE]; int32_t numRThashes;
struct msgcounts msgcounts;
struct OS_memspace RAWMEM,TXDATA,HASHMEM;
struct dragon_ramchain ramchain;
//struct dragon_fileitem *filehash2; int32_t numfilehash2,maxfilehash2;
FILE *voutsfp,*vinsfp;
uint8_t *blockspace;//[DRAGON_MAXPACKETSIZE + 8192];
#ifdef DRAGON_PEERALLOC
struct OS_memspace *SEROUT[128];
#endif
};
struct dragon_peers
{
bits256 lastrequest;
struct dragon_peer active[DRAGON_MAXPEERS+1],*ranked[DRAGON_MAXPEERS+1],*localaddr;
struct dragon_thread *peersloop,*recvloop; pthread_t *acceptloop;
double topmetrics[DRAGON_MAXPEERS+1],avemetric;
uint32_t numranked,mostreceived,shuttingdown,lastpeer,lastmetrics,numconnected;
int32_t numfiles;
};
struct dragon_bloom16 { uint8_t hash2bits[65536 / 8]; };
struct dragon_bloominds { uint16_t inds[8]; };
struct dragon_bundle
{
struct queueitem DL; struct dragon_info *coin; struct dragon_bundle *nextbp;
struct dragon_bloom16 bloom; int64_t totaldurations,duplicatedurations; int32_t durationscount,duplicatescount;
uint32_t issuetime,hdrtime,emitfinish,mergefinish,purgetime,queued,startutxo,balancefinish,validated,lastspeculative,dirty,nexttime,currenttime,lastprefetch,lastRT,missingstime,unsticktime,converted,utxofinish;
int32_t numhashes,numrecv,numsaved,numcached,generrs,currentflag,origmissings,numissued,Xvalid;
int32_t minrequests,n,hdrsi,bundleheight,numtxids,numspends,numunspents,numspec,isRT;
double avetime,threshold,metric; uint64_t datasize,estsize;
struct dragon_block *blocks[DRAGON_MAXBUNDLESIZE];
uint8_t *speculativecache[DRAGON_MAXBUNDLESIZE],haveblock[DRAGON_MAXBUNDLESIZE/3+1];
uint32_t issued[DRAGON_MAXBUNDLESIZE],firsttxidinds[DRAGON_MAXBUNDLESIZE];
bits256 prevbundlehash2,hashes[DRAGON_MAXBUNDLESIZE+1],nextbundlehash2,allhash,*speculative,validatehash;
struct dragon_ramchain ramchain; uint8_t red,green,blue;
struct dragon_spendvector *tmpspends; int32_t numtmpspends;
uint64_t *weights,supply; int32_t numweights;
};
struct dragon_bundlereq
{
struct queueitem DL; struct dragon_info *coin; int32_t type;
struct dragon_peer *addr; struct dragon_zblock *blocks; bits256 *hashes,txid;
//struct dragon_txdatabits txdatabits;
struct dragon_msghdr H;
int32_t allocsize,datalen,n,recvlen,numtx; uint32_t ipbits;
struct dragon_zblock zblock;
uint8_t copyflag,serializeddata[];
};
struct dragon_bitmap { int32_t width,height,amplitude; char name[52]; uint8_t data[DRAGON_WIDTH*DRAGON_HEIGHT*3]; };
struct dragon_waddress { UT_hash_handle hh; uint64_t balance; uint16_t scriptlen; uint8_t rmd160[20],pubkey[33],wiftype,addrtype; bits256 privkey; char symbol[16],coinaddr[36],wifstr[54]; uint8_t redeemScript[]; };
struct dragon_waccount { UT_hash_handle hh; struct dragon_waddress *waddr,*current; char account[]; };
struct dragon_wallet { UT_hash_handle hh; struct dragon_waccount *wacct; };
struct scriptinfo { UT_hash_handle hh; uint32_t fpos; uint16_t scriptlen; uint8_t script[]; };
struct hhbits256 { UT_hash_handle hh; bits256 txid; int32_t height; uint16_t firstvout; };
struct dragon_monitorinfo { bits256 txid; int32_t numreported; uint8_t peerbits[DRAGON_MAXPEERS >> 3]; };
struct dragon_RTunspent
{
uint8_t rmd160[20];
int64_t value;
int32_t vout,height,fromheight;
struct dragon_RTtxid *parent;
struct dragon_RTspend *spend;
struct dragon_RTunspent *prevunspent;
int16_t scriptlen;
uint8_t locked,validflag;
uint8_t script[];
};
struct dragon_RTspend
{
bits256 prev_hash;
struct dragon_RTunspent *bundle_unspent;
int16_t prev_vout,scriptlen;
uint8_t vinscript[];
};
struct dragon_RTaddr
{
UT_hash_handle hh;
char coinaddr[64];
int64_t histbalance,debits,credits;
int32_t numunspents;
struct dragon_RTunspent *lastunspent;
};
struct dragon_RTtxid
{
UT_hash_handle hh; struct dragon_info *coin; struct dragon_block *block;
bits256 txid;
int32_t height,txi,txn_count,numvouts,numvins,txlen;
uint32_t locktime,version,timestamp;
uint8_t *rawtxbytes;
struct dragon_RTunspent **unspents;
struct dragon_RTspend *spends[];
};
struct hashstr_item { UT_hash_handle hh; char address[40]; };
struct dragon_info
{
UT_hash_handle hh;
char CMCname[64],name[64],symbol[64],protocol,statusstr[512],scriptsfname[2][512];
struct dragon_peers *peers; struct dragon_peer internaladdr;
#if defined(_M_X64)
/*
* because we have no choice but to pass the value as parameters
* we need 64bit to hold 64bit memory address, thus changing
* to uint64_t instead of long in win x64
* @author - fadedreamz@gmail.com
*/
uint64_t vinptrs[DRAGON_MAXPEERS + 1][2], voutptrs[DRAGON_MAXPEERS + 1][2];
#else
long vinptrs[DRAGON_MAXPEERS+1][2],voutptrs[DRAGON_MAXPEERS+1][2];
#endif
uint32_t fastfind; FILE *fastfps[0x100]; uint8_t *fast[0x100]; int32_t *fasttables[0x100]; long fastsizes[0x100];
uint64_t instance_nonce,myservices,totalsize,totalrecv,totalpackets,sleeptime;
int64_t mining,totalfees,TMPallocated,MAXRECVCACHE,MAXMEM,PREFETCHLAG,estsize,activebundles;
int32_t MoMoMheight,MAXPEERS,MAXPENDINGREQUESTS,MAXBUNDLES,MAXSTUCKTIME,active,closestbundle,numemitted,lastsweep,numemit,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE,FULLNODE,VALIDATENODE,origbalanceswritten,balanceswritten,lastRTheight,RTdatabad,sapling;
bits256 balancehash,allbundles;
uint32_t lastsync,parsetime,numiAddrs,lastpossible,bundlescount,savedblocks,backlog,spendvectorsaved,laststats,lastinv2,symbolcrc,spendvalidated; char VALIDATEDIR[512];
int32_t longestchain,badlongestchain,longestchain_strange,RTramchain_busy,emitbusy,stuckiters,virtualchain,RTheight,RTreset_needed;
struct tai starttime; double startmillis;
struct dragon_chain *chain;
struct dragon_iAddr *iAddrs;
void *ctx;
struct dragon_bitmap *screen;
struct OS_memspace TXMEM,MEM,MEMB[DRAGON_MAXBUNDLESIZE];
queue_t acceptQ,hdrsQ,blocksQ,priorityQ,possibleQ,cacheQ,recvQ,msgrequestQ,jsonQ,finishedQ;
double parsemillis,avetime; uint32_t Launched[8],Terminated[8];
portable_mutex_t peers_mutex,blocks_mutex,special_mutex,RTmutex,allcoins_mutex,MoM_mutex;
char changeaddr[64];
struct dragon_bundle *bundles[DRAGON_MAXBUNDLES],*current,*lastpending;
struct OS_memspace RTrawmem,RTmem,RThashmem; // struct dragon_ramchain RTramchain;
bits256 RThash1;
int32_t numremain,numpendings,zcount,recvcount,bcount,pcount,lastbundle,numsaved,pendbalances,numverified,blockdepth,matchedfiles;
uint32_t recvtime,hdrstime,backstoptime,lastbundletime,numreqsent,numbundlesQ,lastbundleitime,lastdisp,RTgenesis,firstRTgenesis,RTstarti,idletime,stucktime,stuckmonitor,maxstuck,lastreqtime,RThdrstime,nextchecked,lastcheckpoint,sigserrs,sigsvalidated,coinid;
double bandwidth,maxbandwidth,backstopmillis; bits256 backstophash2; int64_t spaceused;
int32_t disableUTXO,initialheight,mapflags,minconfirms,numrecv,bindsock,isRT,backstop,blocksrecv,merging,firstRTheight,maxRTheight,polltimeout,numreqtxids,allhashes,balanceflush,almostRT,busy_processing; bits256 reqtxids[64];
void *launched,*started,*rpcloop;
uint64_t bloomsearches,bloomhits,bloomfalse,collisions,txfee_perkb,txfee;
uint8_t *blockspace; int32_t blockspacesize; struct OS_memspace blockMEM,RTHASHMEM;
bits256 APIblockhash,APItxid; char *APIblockstr;
struct dragon_hhutxo *utxotable;
#ifdef DEPRECATED_HHUTXO
struct dragon_hhaccount *accountstable;
#endif
char lastdispstr[2048],getinfostr[64],validateaddress[64],estimatefeestr[64],signtxstr[64];
double txidfind_totalmillis,txidfind_num,spendtxid_totalmillis,spendtxid_num;
struct dragon_monitorinfo monitoring[256];
int32_t notarychain,didaddresses;
//struct datachain_info dPoW;
struct dragon_zblock newblock; char *newblockstr;
int32_t relay_RTheights[BASILISK_MAXRELAYS];
struct dragon_blocks blocks; void *mempool; void *mempools[BASILISK_MAXRELAYS];
struct dragon_utxoaddr *utxoaddrs,*RTprev; uint32_t utxodatasize,utxoaddrind;
uint64_t histbalance,RTcredits,RTdebits;
void *utxoaddrfileptr; long utxoaddrfilesize;
uint32_t utxoaddrlastcount,*utxoaddroffsets,lastunspentsupdate; uint8_t *utxoaddrtable; bits256 utxoaddrhash;
FILE *utxofp;
bits256 markedunspents[1024];
uint64_t estimatedfee;
char seedipaddr[64];
uint32_t lastbesthashtime; bits256 lastbesthash; int32_t lastbestheight;
//struct DEXcoin_info DEXinfo;
struct dragon_block *RTblocks[65536]; uint8_t *RTrawdata[65536]; int32_t RTrecvlens[65536],RTnumtx[65536];
struct dragon_RTtxid *RTdataset; struct dragon_RTaddr *RTaddrs;
struct hashstr_item *alladdresses;
struct kmd_transactionhh *kmd_transactions; struct kmd_addresshh *kmd_addresses; portable_mutex_t kmdmutex; FILE *kmd_txidfp,*kmd_spendfp; int32_t kmd_didinit,kmd_height,DEXEXPLORER; uint32_t kmd_lasttime;
};
struct vin_signer { bits256 privkey; char coinaddr[64]; uint8_t siglen,sig[80],rmd160[20],pubkey[66]; };
struct vin_info
{
struct dragon_msgvin vin; uint64_t amount; cJSON *extras; bits256 sigtxid;
int32_t M,N,validmask,spendlen,type,p2shlen,numpubkeys,numsigs,height,hashtype,userdatalen,suppress_pubkeys,ignore_cltverr;
uint32_t sequence,unspentind; struct vin_signer signers[16]; char coinaddr[65];
uint8_t rmd160[20],spendscript[DRAGON_MAXSCRIPTSIZE],p2shscript[DRAGON_MAXSCRIPTSIZE],userdata[DRAGON_MAXSCRIPTSIZE];
};
struct bitcoin_unspent
{
bits256 txid,privkeys[16]; uint64_t value; int32_t vout,spendlen,p2shlen,numpubkeys; uint32_t sequence;
uint8_t addrtype,rmd160[20],pubkeys[16][65],spendscript[DRAGON_MAXSCRIPTSIZE],p2shscript[DRAGON_MAXSCRIPTSIZE];
};
struct bitcoin_spend
{
char changeaddr[64]; uint8_t change160[20];
int32_t numinputs;
int64_t txfee,input_satoshis,satoshis,change;
struct bitcoin_unspent inputs[];
};
struct dragon_outpoint { void *ptr; bits256 txid; int64_t value; uint32_t unspentind; int16_t hdrsi,vout,spendlen:15,isptr:1; uint8_t spendscript[512]; };
struct exchange_quote { uint64_t satoshis,orderid,offerNXT,exchangebits; double price,volume; uint32_t timestamp,val; };
struct _gfshare_ctx
{
uint32_t sharecount,threshold,size,buffersize,allocsize;
uint8_t sharenrs[255],buffer[];
};
#endif