Browse Source

Refactoring

pull/32/head
Duke Leto 3 years ago
parent
commit
1f4c4f27e6
  1. 2
      src/cc/CCPrices.h
  2. 2
      src/cc/CCutils.cpp
  3. 2
      src/cc/oracles.cpp
  4. 24
      src/cc/prices.cpp
  5. 4
      src/compat.h
  6. 20
      src/hush.h
  7. 153
      src/hush_bitcoind.h
  8. 13
      src/hush_defs.h
  9. 8
      src/hush_events.h
  10. 30
      src/hush_gateway.h
  11. 6
      src/hush_globals.h
  12. 4
      src/hush_nk.h
  13. 2
      src/hush_notary.h
  14. 4
      src/hush_pax.h
  15. 2
      src/hush_structs.h
  16. 2
      src/main.cpp
  17. 6
      src/miner.cpp
  18. 3
      src/net.h
  19. 14
      src/rpc/blockchain.cpp
  20. 13
      src/rpc/misc.cpp
  21. 4
      src/txdb.cpp
  22. 12
      src/wallet-utility.cpp
  23. 12
      src/wallet/rpcwallet.cpp

2
src/cc/CCPrices.h

@ -32,7 +32,7 @@ extern CScript HUSH_EARLYTXID_SCRIPTPUB;
#define PRICES_MAXLEVERAGE 777
#define PRICES_SMOOTHWIDTH 1
#define HUSH_MAXPRICES 2048 // must be power of 2 and less than 8192
#define KOMODO_PRICEMASK (~(HUSH_MAXPRICES - 1)) // actually 1111 1000 0000 0000
#define HUSH_PRICEMASK (~(HUSH_MAXPRICES - 1)) // actually 1111 1000 0000 0000
#define PRICES_WEIGHT (HUSH_MAXPRICES * 1) // 0000 1000 0000 0000
#define PRICES_MULT (HUSH_MAXPRICES * 2) // 0001 0000 0000 0000
#define PRICES_DIV (HUSH_MAXPRICES * 3) // 0001 1000 0000 0000

2
src/cc/CCutils.cpp

@ -173,7 +173,7 @@ bool CheckTxFee(const CTransaction &tx, uint64_t txfee, uint32_t height, uint64_
uint32_t GetLatestTimestamp(int32_t height)
{
if ( HUSH_NSPV_SUPERLITE ) return ((uint32_t)NSPV_blocktime(height));
return(komodo_heightstamp(height));
return(hush_heightstamp(height));
} // :P
void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr)

2
src/cc/oracles.cpp

@ -645,7 +645,7 @@ bool OraclesDataValidate(struct CCcontract_info *cp,Eval* eval,const CTransactio
/*nt32_t GetLatestTimestamp(int32_t height)
{
if ( HUSH_NSPV_SUPERLITE ) return (NSPV_blocktime(height));
return(komodo_heightstamp(height));
return(hush_heightstamp(height));
} */
bool OraclesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn)

24
src/cc/prices.cpp

@ -659,7 +659,7 @@ static std::string prices_getsourceexpression(const std::vector<uint16_t> &vec)
uint16_t opcode = vec[i];
int32_t value = (opcode & (HUSH_MAXPRICES - 1)); // index or weight
switch (opcode & KOMODO_PRICEMASK)
switch (opcode & HUSH_PRICEMASK)
{
case 0: // indices
komodo_pricename(name, value);
@ -949,7 +949,7 @@ int32_t prices_syntheticvec(std::vector<uint16_t> &vec, std::vector<std::string>
}
depth -= need;
///std::cerr << "prices_syntheticvec() opcode=" << opcode << " opstr=" << opstr << " need=" << need << " depth=" << depth << std::endl;
if ((opcode & KOMODO_PRICEMASK) != PRICES_WEIGHT) { // skip weight
if ((opcode & HUSH_PRICEMASK) != PRICES_WEIGHT) { // skip weight
depth++; // increase operands count
///std::cerr << "depth++=" << depth << std::endl;
}
@ -997,8 +997,8 @@ int64_t prices_syntheticprice(std::vector<uint16_t> vec, int32_t height, int32_t
mpz_set_ui(mpzResult, 0); // clear result to test overflow (see below)
//std::cerr << "prices_syntheticprice" << " i=" << i << " mpzTotalPrice=" << mpz_get_si(mpzTotalPrice) << " value=" << value << " depth=" << depth << " opcode&KOMODO_PRICEMASK=" << (opcode & KOMODO_PRICEMASK) <<std::endl;
switch (opcode & KOMODO_PRICEMASK)
//std::cerr << "prices_syntheticprice" << " i=" << i << " mpzTotalPrice=" << mpz_get_si(mpzTotalPrice) << " value=" << value << " depth=" << depth << " opcode&HUSH_PRICEMASK=" << (opcode & HUSH_PRICEMASK) <<std::endl;
switch (opcode & HUSH_PRICEMASK)
{
case 0: // indices
pricestack[depth] = 0;
@ -2230,16 +2230,16 @@ static bool prices_ispositionup(const std::vector<uint16_t> &vecparsed, int16_t
int32_t value = (opcode & (HUSH_MAXPRICES - 1)); // filter index or weight = opcode & (2048-1)
if ((opcode & KOMODO_PRICEMASK) == 0) {
if ((opcode & HUSH_PRICEMASK) == 0) {
char name[65];
if (komodo_pricename(name, value)) {
std::string upperquote, bottomquote;
prices_splitpair(std::string(name), upperquote, bottomquote);
uint16_t opcode1 = vecparsed[1];
bool isInverted = ((opcode1 & KOMODO_PRICEMASK) == PRICES_INV);
bool isInverted = ((opcode1 & HUSH_PRICEMASK) == PRICES_INV);
//std::cerr << "prices_ispositionup upperquote=" << upperquote << " bottomquote=" << bottomquote << " opcode1=" << opcode1 << " (opcode1 & KOMODO_PRICEMASK)=" << (opcode1 & KOMODO_PRICEMASK) << std::endl;
//std::cerr << "prices_ispositionup upperquote=" << upperquote << " bottomquote=" << bottomquote << " opcode1=" << opcode1 << " (opcode1 & HUSH_PRICEMASK)=" << (opcode1 & HUSH_PRICEMASK) << std::endl;
if (upperquote == "BTC" || bottomquote == "BTC") { // it is relatively btc
if (upperquote == "BTC" && (leverage > 0 && !isInverted || leverage < 0 && isInverted) ||
@ -2280,7 +2280,7 @@ static bool prices_isopposite(BetInfo p1, BetInfo p2) {
int32_t value1 = (opcode1 & (HUSH_MAXPRICES - 1)); // index or weight
int32_t value2 = (opcode2 & (HUSH_MAXPRICES - 1)); // index or weight
if ( (opcode1 & KOMODO_PRICEMASK) == 0 && (opcode2 & KOMODO_PRICEMASK) == 0 ) {
if ( (opcode1 & HUSH_PRICEMASK) == 0 && (opcode2 & HUSH_PRICEMASK) == 0 ) {
char name1[65];
char name2[65];
if (komodo_pricename(name1, value1) && komodo_pricename(name2, value2)) {
@ -2292,10 +2292,10 @@ static bool prices_isopposite(BetInfo p1, BetInfo p2) {
prices_splitpair(std::string(name1), upperquote1, bottomquote1);
prices_splitpair(std::string(name2), upperquote2, bottomquote2);
bool isInverted1 = ((opcode1 & KOMODO_PRICEMASK) != PRICES_INV);
bool isInverted2 = ((opcode2 & KOMODO_PRICEMASK) != PRICES_INV);
bool isInverted1 = ((opcode1 & HUSH_PRICEMASK) != PRICES_INV);
bool isInverted2 = ((opcode2 & HUSH_PRICEMASK) != PRICES_INV);
if (/*upperquote1 == bottomquote2 && bottomquote1 == upperquote2 && (p1.leverage > 0 == p2.leverage > 0 || (opcode1 & KOMODO_PRICEMASK) == PRICES_INV == (opcode2 & KOMODO_PRICEMASK) == PRICES_INV) ||*/
if (/*upperquote1 == bottomquote2 && bottomquote1 == upperquote2 && (p1.leverage > 0 == p2.leverage > 0 || (opcode1 & HUSH_PRICEMASK) == PRICES_INV == (opcode2 & HUSH_PRICEMASK) == PRICES_INV) ||*/
upperquote1 == upperquote2 && bottomquote1 == bottomquote2 && ((p1.leverage > 0) != (p2.leverage > 0) || isInverted1 != isInverted2) )
return true;
}
@ -2313,7 +2313,7 @@ static std::string findMatchedBook(const std::vector<uint16_t> &vecparsed, const
int32_t value = (opcode & (HUSH_MAXPRICES - 1)); // filter index or weight = opcode & (2048-1)
if ((opcode & KOMODO_PRICEMASK) == 0) {
if ((opcode & HUSH_PRICEMASK) == 0) {
char name[65];
if (komodo_pricename(name, value)) {
auto it = bookmatched.find(std::string(name));

4
src/compat.h

@ -2,7 +2,6 @@
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
/******************************************************************************
* Copyright © 2014-2019 The SuperNET Developers. *
* *
@ -42,7 +41,6 @@
#define FD_SETSIZE 1024 // max number of fds in fd_set
#include <winsock2.h> // Must be included before mswsock.h and windows.h
#include <mswsock.h>
#include <windows.h>
#include <ws2tcpip.h>
@ -85,10 +83,12 @@ typedef u_int SOCKET;
#define S_IWUSR 0200
#endif
#else
#undef MAX_PATH
#define MAX_PATH 1024
#endif
// As Solaris does not have the MSG_NOSIGNAL flag for send(2) syscall, it is defined as 0
// Should we add support for PDP-11's too? - Duke
#if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
#define MSG_NOSIGNAL 0
#endif

20
src/hush.h

@ -25,7 +25,7 @@
// Todo: verify: reorgs, lollerskates
#define HUSH_SMART_CHAINS_WAITNOTARIZE
#define KOMODO_PAXMAX (10000 * COIN)
#define HUSH_PAXMAX (10000 * COIN)
extern int32_t NOTARIZED_HEIGHT;
uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID;
@ -545,9 +545,9 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
{
if ( i == 0 && j == 0 && memcmp(NOTARY_PUBKEY33,scriptbuf+1,33) == 0 && IS_HUSH_NOTARY != 0 )
{
printf("%s KOMODO_LASTMINED.%d -> %d\n",SMART_CHAIN_SYMBOL,KOMODO_LASTMINED,height);
prevKOMODO_LASTMINED = KOMODO_LASTMINED;
KOMODO_LASTMINED = height;
printf("%s HUSH_LASTMINED.%d -> %d\n",SMART_CHAIN_SYMBOL,HUSH_LASTMINED,height);
prevHUSH_LASTMINED = HUSH_LASTMINED;
HUSH_LASTMINED = height;
}
decode_hex(crypto555,33,(char *)CRYPTO555_PUBSECPSTR);
/*for (k=0; k<33; k++)
@ -620,7 +620,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
if ( j == 1 && opretlen >= len+offset-opoffset )
{
memset(&MoMoMdata,0,sizeof(MoMoMdata));
if ( matched == 0 && signedmask != 0 && bitweight(signedmask) >= KOMODO_MINRATIFY )
if ( matched == 0 && signedmask != 0 && bitweight(signedmask) >= HUSH_MINRATIFY )
notarized = 1;
if ( strcmp("PIZZA",ccdata.symbol) == 0 || strncmp("TXSCL",ccdata.symbol,5) == 0 || strcmp("BEER",ccdata.symbol) == 0)
notarized = 1;
@ -777,13 +777,13 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
/*int32_t komodo_isratify(int32_t isspecial,int32_t numvalid)
{
if ( isspecial != 0 && numvalid >= KOMODO_MINRATIFY )
if ( isspecial != 0 && numvalid >= HUSH_MINRATIFY )
return(1);
else return(0);
}*/
// Special tx have vout[0] -> CRYPTO555 address
// with more than KOMODO_MINRATIFY pay2pubkey outputs -> ratify
// with more than HUSH_MINRATIFY pay2pubkey outputs -> ratify
// if all outputs to notary -> notary utxo
// if txi == 0 && 2 outputs and 2nd OP_RETURN, len == 32*2+4 -> notarized, 1st byte 'P' -> pricefeed
// OP_RETURN: 'D' -> deposit, 'W' -> withdraw
@ -880,8 +880,8 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
} //else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j);
}
numvalid = bitweight(signedmask);
if ( ((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) ||
(numvalid >= KOMODO_MINRATIFY && SMART_CHAIN_SYMBOL[0] != 0) ||
if ( ((height < 90000 || (signedmask & 1) != 0) && numvalid >= HUSH_MINRATIFY) ||
(numvalid >= HUSH_MINRATIFY && SMART_CHAIN_SYMBOL[0] != 0) ||
numvalid > (numnotaries/5) )
{
if ( !fJustCheck && SMART_CHAIN_SYMBOL[0] != 0)
@ -984,7 +984,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
}
if ( SMART_CHAIN_SYMBOL[0] != 0 || height < 100000 )
{
if ( ((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries/3) )
if ( ((signedmask & 1) != 0 && numvalid >= HUSH_MINRATIFY) || bitweight(signedmask) > (numnotaries/3) )
{
memset(&txhash,0,sizeof(txhash));
hush_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0,zero,0);

153
src/hush_bitcoind.h

@ -31,8 +31,7 @@ bool EnsureWalletIsAvailable(bool avoidException);
extern bool fRequestShutdown;
extern CScript HUSH_EARLYTXID_SCRIPTPUB;
uint8_t DecodeMaramaraCoinbaseOpRet(const CScript scriptPubKey,CPubKey &pk,int32_t &height,int32_t &unlockht);
uint32_t komodo_heightstamp(int32_t height);
uint32_t hush_heightstamp(int32_t height);
//#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"curl",(char *)"http://127.0.0.1:7776",0,0,(char *)(cmdstr))
@ -672,28 +671,6 @@ uint32_t komodo_txtime2(uint64_t *valuep,uint256 hash,int32_t n,char *destaddr)
return(txtime);
}
int32_t komodo_WhoStaked(CBlock *pblock, CTxDestination &addressout)
{
int32_t n,vout; uint32_t txtime; uint64_t value; char voutaddr[64],destaddr[64]; CTxDestination voutaddress; uint256 txid; CScript opret;
if ( (n= pblock->vtx.size()) > 1 && pblock->vtx[n-1].vin.size() == 1 && pblock->vtx[n-1].vout.size() == 1 )
{
txid = pblock->vtx[n-1].vin[0].prevout.hash;
vout = pblock->vtx[n-1].vin[0].prevout.n;
txtime = komodo_txtime(opret,&value,txid,vout,destaddr);
if ( ExtractDestination(pblock->vtx[n-1].vout[0].scriptPubKey,voutaddress) )
{
strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str());
if ( strcmp(destaddr,voutaddr) == 0 && pblock->vtx[n-1].vout[0].nValue == value )
{
//fprintf(stderr,"is PoS block!\n");
addressout = voutaddress;
return(1);
}
}
}
return(0);
}
bool komodo_checkopret(CBlock *pblock, CScript &merkleroot)
{
merkleroot = pblock->vtx.back().vout.back().scriptPubKey;
@ -728,7 +705,7 @@ void komodo_disconnect(CBlockIndex *pindex,CBlock& block)
{
//sp->rewinding = pindex->GetHeight();
//fprintf(stderr,"-%d ",pindex->GetHeight());
} else printf("komodo_disconnect: ht.%d cant get hush_state.(%s)\n",pindex->GetHeight(),SMART_CHAIN_SYMBOL);
} else printf("hush_disconnect: ht.%d cant get hush_state.(%s)\n",pindex->GetHeight(),SMART_CHAIN_SYMBOL);
}
int32_t hush_is_notarytx(const CTransaction& tx)
@ -851,12 +828,12 @@ CBlockIndex *hush_chainactive(int32_t height)
return(0);
}
uint32_t komodo_heightstamp(int32_t height)
uint32_t hush_heightstamp(int32_t height)
{
CBlockIndex *ptr;
if ( height > 0 && (ptr= hush_chainactive(height)) != 0 )
return(ptr->nTime);
//else fprintf(stderr,"komodo_heightstamp null ptr for block.%d\n",height);
//else fprintf(stderr,"hush_heightstamp null ptr for block.%d\n",height);
return(0);
}
@ -1285,14 +1262,14 @@ uint64_t the_commission(const CBlock *pblock,int32_t height)
return(commission);
}
uint32_t komodo_segid32(char *coinaddr)
uint32_t hush_segid32(char *coinaddr)
{
bits256 addrhash;
vcalc_sha256(0,(uint8_t *)&addrhash,(uint8_t *)coinaddr,(int32_t)strlen(coinaddr));
return(addrhash.uints[0]);
}
int8_t komodo_segid(int32_t nocache,int32_t height)
int8_t hush_segid(int32_t nocache,int32_t height)
{
CTxDestination voutaddress; CBlock block; CBlockIndex *pindex; uint64_t value; uint32_t txtime; char voutaddr[64],destaddr[64]; int32_t txn_count,vout; uint256 txid; CScript opret; int8_t segid = -1;
if ( height > 0 && (pindex= hush_chainactive(height)) != 0 )
@ -1312,18 +1289,18 @@ int8_t komodo_segid(int32_t nocache,int32_t height)
strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str());
if ( strcmp(destaddr,voutaddr) == 0 && block.vtx[txn_count-1].vout[0].nValue == value )
{
segid = komodo_segid32(voutaddr) & 0x3f;
segid = hush_segid32(voutaddr) & 0x3f;
pindex->segid = segid;
//fprintf(stderr,"komodo_segid.(%d) -> %d\n",height,pindex->segid);
//fprintf(stderr,"hush_segid.(%d) -> %d\n",height,pindex->segid);
}
} else fprintf(stderr,"komodo_segid ht.%d couldnt extract voutaddress\n",height);
} else fprintf(stderr,"hush_segid ht.%d couldnt extract voutaddress\n",height);
}
}
}
return(segid);
}
void komodo_segids(uint8_t *hashbuf,int32_t height,int32_t n)
void hush_segids(uint8_t *hashbuf,int32_t height,int32_t n)
{
static uint8_t prevhashbuf[100]; static int32_t prevheight;
int32_t i;
@ -1334,7 +1311,7 @@ void komodo_segids(uint8_t *hashbuf,int32_t height,int32_t n)
memset(hashbuf,0xff,n);
for (i=0; i<n; i++)
{
hashbuf[i] = (uint8_t)komodo_segid(1,height+i);
hashbuf[i] = (uint8_t)hush_segid(1,height+i);
//fprintf(stderr,"%02x ",hashbuf[i]);
}
if ( n == 100 )
@ -1346,17 +1323,6 @@ void komodo_segids(uint8_t *hashbuf,int32_t height,int32_t n)
}
}
uint32_t komodo_stakehash(uint256 *hashp,char *address,uint8_t *hashbuf,uint256 txid,int32_t vout)
{
bits256 addrhash;
vcalc_sha256(0,(uint8_t *)&addrhash,(uint8_t *)address,(int32_t)strlen(address));
memcpy(&hashbuf[100],&addrhash,sizeof(addrhash));
memcpy(&hashbuf[100+sizeof(addrhash)],&txid,sizeof(txid));
memcpy(&hashbuf[100+sizeof(addrhash)+sizeof(txid)],&vout,sizeof(vout));
vcalc_sha256(0,(uint8_t *)hashp,hashbuf,100 + (int32_t)sizeof(uint256)*2 + sizeof(vout));
return(addrhash.uints[0]);
}
arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,uint32_t nTime)
{
arith_uint256 origtarget,easy; int32_t diff,tipdiff; int64_t mult; bool fNegative,fOverflow; CBlockIndex *tipindex;
@ -1402,7 +1368,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he
continue;
if ( (pindex= hush_chainactive(ht)) != 0 )
{
if ( komodo_segid(0,ht) >= 0 )
if ( hush_segid(0,ht) >= 0 )
{
n++;
percPoS++;
@ -1487,93 +1453,8 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he
return(bnTarget);
}
uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_t vout,uint32_t blocktime,uint32_t prevtime,char *destaddr,int32_t PoSperc)
{
bool fNegative,fOverflow; uint8_t hashbuf[256]; char address[64]; bits256 addrhash; arith_uint256 hashval,mindiff,ratio,coinage256; uint256 hash,pasthash; int32_t segid,minage,i,iter=0; int64_t diff=0; uint32_t txtime,segid32,winner = 0 ; uint64_t value,coinage;
txtime = komodo_txtime2(&value,txid,vout,address);
if ( validateflag == 0 )
{
//fprintf(stderr,"blocktime.%u -> ",blocktime);
if ( blocktime < prevtime+3 )
blocktime = prevtime+3;
if ( blocktime < GetTime()-60 )
blocktime = GetTime()+30;
//fprintf(stderr,"blocktime.%u txtime.%u\n",blocktime,txtime);
}
if ( value == 0 || txtime == 0 || blocktime == 0 || prevtime == 0 )
{
//fprintf(stderr,"komodo_stake null %.8f %u %u %u\n",dstr(value),txtime,blocktime,prevtime);
return(0);
}
if ( value < SATOSHIDEN )
return(0);
value /= SATOSHIDEN;
mindiff.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow);
ratio = (mindiff / bnTarget);
if ( (minage= nHeight*3) > 6000 ) // about 100 blocks
minage = 6000;
komodo_segids(hashbuf,nHeight-101,100);
segid32 = komodo_stakehash(&hash,address,hashbuf,txid,vout);
segid = ((nHeight + segid32) & 0x3f);
for (iter=0; iter<600; iter++)
{
if ( blocktime+iter+segid*2 < txtime+minage )
continue;
diff = (iter + blocktime - txtime - minage);
if ( diff < 0 )
diff = 60;
else if ( diff > 3600*24*30 )
{
//printf("diff.%d (iter.%d blocktime.%u txtime.%u minage.%d)\n",(int32_t)diff,iter,blocktime,txtime,(int32_t)minage);
diff = 3600*24*30;
}
if ( iter > 0 )
diff += segid*2;
coinage = (value * diff);
if ( blocktime+iter+segid*2 > prevtime+480 )
coinage *= ((blocktime+iter+segid*2) - (prevtime+400));
coinage256 = arith_uint256(coinage+1);
hashval = ratio * (UintToArith256(hash) / coinage256);
if ( hashval <= bnTarget )
{
winner = 1;
if ( validateflag == 0 )
{
//fprintf(stderr,"winner blocktime.%u iter.%d segid.%d\n",blocktime,iter,segid);
blocktime += iter;
blocktime += segid * 2;
}
break;
}
if ( validateflag != 0 )
{
/*for (i=31; i>=24; i--)
fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]);
fprintf(stderr," vs ");
for (i=31; i>=24; i--)
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]);
fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff); */
break;
}
}
//fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner);
if ( 0 && validateflag != 0 )
{
for (i=31; i>=24; i--)
fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]);
fprintf(stderr," vs ");
for (i=31; i>=24; i--)
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]);
fprintf(stderr," segid.%d iter.%d winner.%d coinage.%llu %d ht.%d t.%u v%d diff.%d ht.%d\n",segid,iter,winner,(long long)coinage,(int32_t)(blocktime - txtime),nHeight,blocktime,(int32_t)value,(int32_t)diff,nHeight);
}
if ( nHeight < 10 )
return(blocktime);
return(blocktime * winner);
}
// lulz
int32_t komodo_is_PeiceOfShit() { return(1); }
bool GetStakeParams(const CTransaction &stakeTx, CStakeParams &stakeParams);
bool ValidateMatchingStake(const CTransaction &ccTx, uint32_t voutNum, const CTransaction &stakeTx, bool &cheating);
uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount)
{
@ -1908,13 +1789,13 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
return(checktoshis);
}
bool KOMODO_TEST_ASSETCHAIN_SKIP_POW = 0;
bool HUSH_TEST_ASSETCHAIN_SKIP_POW = 0;
int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
{
uint256 hash,merkleroot; arith_uint256 bnTarget,bhash; bool fNegative,fOverflow; uint8_t *script,pubkey33[33],pubkeys[64][33]; int32_t i,scriptlen,possible,PoSperc,is_PoSblock=0,n,failed = 0,notaryid = -1; int64_t checktoshis,value; CBlockIndex *pprev;
if ( KOMODO_TEST_ASSETCHAIN_SKIP_POW == 0 && Params().NetworkIDString() == "regtest" )
KOMODO_TEST_ASSETCHAIN_SKIP_POW = 1;
if ( HUSH_TEST_ASSETCHAIN_SKIP_POW == 0 && Params().NetworkIDString() == "regtest" )
HUSH_TEST_ASSETCHAIN_SKIP_POW = 1;
if ( !CheckEquihashSolution(pblock, Params()) )
{
fprintf(stderr,"komodo_checkPOW slowflag.%d ht.%d CheckEquihashSolution failed\n",slowflag,height);
@ -1950,7 +1831,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
}
}
} else if ( possible == 0 || SMART_CHAIN_SYMBOL[0] != 0 ) {
if ( KOMODO_TEST_ASSETCHAIN_SKIP_POW )
if ( HUSH_TEST_ASSETCHAIN_SKIP_POW )
return(0);
if ( ASSETCHAINS_STAKED == 0 )
return(-1);

13
src/hush_defs.h

@ -497,13 +497,9 @@ extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC;
extern int32_t ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER,ASSETCHAINS_BLOCKTIME;
extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD;
extern int32_t ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER,ASSETCHAINS_BLOCKTIME;
extern int32_t KOMODO_BLOCK_POSUNITS, KOMODO_CONSECUTIVE_POS_THRESHOLD, KOMODO_NOPOS_THRESHHOLD;
extern uint64_t ASSETCHAINS_TIMELOCKGTE;
extern uint32_t ASSETCHAINS_ALGO,ASSETCHAINS_EQUIHASH,HUSH_INITDONE;
extern int32_t HUSH_MININGTHREADS,HUSH_LONGESTCHAIN,ASSETCHAINS_SEED,IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY,HUSH_CHOSEN_ONE,KOMODO_ON_DEMAND,HUSH_PASSPORT_INITDONE,ASSETCHAINS_STAKED,HUSH_NSPV;
extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_LASTERA,ASSETCHAINS_CBOPRET;
extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2];
@ -512,14 +508,11 @@ extern uint32_t ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[];
extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB;
extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA;
extern std::vector<std::string> ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS;
extern uint256 HUSH_EARLYTXID;
extern int32_t HUSH_CONNECTING,HUSH_CCACTIVATE,KOMODO_DEALERNODE;
extern uint32_t ASSETCHAINS_CC;
extern std::string CCerror,ASSETCHAINS_CCLIB;
extern uint8_t ASSETCHAINS_CCDISABLES[256];
extern int32_t USE_EXTERNAL_PUBKEY;
extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS;
extern std::string DONATION_PUBKEY;
@ -551,15 +544,15 @@ int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *fla
uint32_t hush_blocktime(uint256 hash);
int32_t hush_longestchain();
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
int8_t komodo_segid(int32_t nocache,int32_t height);
int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight);
int8_t hush_segid(int32_t nocache,int32_t height);
int32_t hush_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight);
char *komodo_pricename(char *name,int32_t ind);
int32_t komodo_priceind(const char *symbol);
int32_t komodo_pricesinit();
int64_t komodo_priceave(int64_t *tmpbuf,int64_t *correlated,int32_t cskip);
int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth);
int32_t hush_nextheight();
uint32_t komodo_heightstamp(int32_t height);
uint32_t hush_heightstamp(int32_t height);
int64_t komodo_pricemult(int32_t ind);
int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks);
int32_t hush_currentheight();

8
src/hush_events.h

@ -135,11 +135,11 @@ void hush_event_rewind(struct hush_state *sp,char *symbol,int32_t height)
struct hush_event *ep;
if ( sp != 0 )
{
if ( SMART_CHAIN_SYMBOL[0] == 0 && height <= KOMODO_LASTMINED && prevKOMODO_LASTMINED != 0 )
if ( SMART_CHAIN_SYMBOL[0] == 0 && height <= HUSH_LASTMINED && prevHUSH_LASTMINED != 0 )
{
printf("undo KOMODO_LASTMINED %d <- %d\n",KOMODO_LASTMINED,prevKOMODO_LASTMINED);
KOMODO_LASTMINED = prevKOMODO_LASTMINED;
prevKOMODO_LASTMINED = 0;
printf("undo HUSH_LASTMINED %d <- %d\n",HUSH_LASTMINED,prevHUSH_LASTMINED);
HUSH_LASTMINED = prevHUSH_LASTMINED;
prevHUSH_LASTMINED = 0;
}
while ( sp->Hush_events != 0 && sp->Hush_numeventss > 0 )
{

30
src/hush_gateway.h

@ -119,7 +119,7 @@ void komodo_paxdelete(struct pax_transaction *pax)
void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,uint8_t type,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context
{
struct pax_transaction *pax; uint8_t buf[35]; int32_t addflag = 0; struct hush_state *sp; char str[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN],*s;
//if ( KOMODO_PAX == 0 )
//if ( HUSH_PAX == 0 )
// return;
//if ( strcmp(symbol,SMART_CHAIN_SYMBOL) != 0 )
// return;
@ -211,7 +211,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio
int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int64_t *srcvalues,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo)
{
struct pax_transaction p,*pax; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t type,rmd160[20]; uint64_t fiatoshis; char symbol[HUSH_SMART_CHAIN_MAXLEN];
//if ( KOMODO_PAX == 0 )
//if ( HUSH_PAX == 0 )
// return(0);
incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4));
//41e77b91cb68dc2aa02fa88550eae6b6d44db676a7e935337b6d1392d9718f03cb0200305c90660400000000fbcbeb1f000000bde801006201000058e7945ad08ddba1eac9c9b6c8e1e97e8016a2d152
@ -304,7 +304,7 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che
uint64_t komodo_paxtotal()
{
struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN],*str; int32_t i,ht; int64_t checktoshis; uint64_t seed,total = 0; struct hush_state *basesp;
if ( HUSH_PASSPORT_INITDONE == 0 ) //KOMODO_PAX == 0 ||
if ( HUSH_PASSPORT_INITDONE == 0 ) //HUSH_PAX == 0 ||
return(0);
if ( komodo_isrealtime(&ht) == 0 )
return(0);
@ -429,7 +429,7 @@ static int _paxorder(const void *a,const void *b)
int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic order
{
struct pax_transaction *pax,*pax2,*tmp,*paxes[64]; uint8_t opretbuf[16384*4]; int32_t i,n,ht,len=0; uint64_t total = 0;
if ( KOMODO_PAX == 0 || HUSH_PASSPORT_INITDONE == 0 )
if ( HUSH_PAX == 0 || HUSH_PASSPORT_INITDONE == 0 )
return(0);
if ( komodo_isrealtime(&ht) == 0 || SMART_CHAIN_SYMBOL[0] != 0 )
return(0);
@ -478,7 +478,7 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic
int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t tokomodo)
{
struct pax_transaction *pax,*tmp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; uint8_t *script,opcode,opret[16384*4],data[16384*4]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct hush_state *sp; uint64_t available,deposited,issued,withdrawn,approved,redeemed,mask,sum = 0;
if ( HUSH_PASSPORT_INITDONE == 0 )//KOMODO_PAX == 0 ||
if ( HUSH_PASSPORT_INITDONE == 0 )//HUSH_PAX == 0 ||
return(0);
struct hush_state *kmdsp = hush_stateptrget((char *)"KMD");
sp = hush_stateptr(symbol,dest);
@ -849,7 +849,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
komodo_kvupdate(opretbuf,opretlen,value);
return("kv");
}
else if ( SMART_CHAIN_SYMBOL[0] == 0 && KOMODO_PAX == 0 )
else if ( SMART_CHAIN_SYMBOL[0] == 0 && HUSH_PAX == 0 )
return("nopax");
if ( opretbuf[0] == 'D' )
{
@ -1223,7 +1223,7 @@ void hush_stateind_set(struct hush_state *sp,uint32_t *inds,int32_t n,uint8_t *f
}
else if ( func == 'V' )
{
if ( KOMODO_PAX != 0 && numv > numV-1440 )
if ( HUSH_PAX != 0 && numv > numV-1440 )
doissue = 1;
numv++;
}
@ -1524,7 +1524,7 @@ void hush_passport_iteration()
RTmask |= (1LL << baseid);
memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1]));
}
else if ( KOMODO_PAX != 0 && (time(NULL)-buf[2]) > 60 && SMART_CHAIN_SYMBOL[0] != 0 )
else if ( HUSH_PAX != 0 && (time(NULL)-buf[2]) > 60 && SMART_CHAIN_SYMBOL[0] != 0 )
fprintf(stderr,"[%s]: %s not RT %u %u %d\n",SMART_CHAIN_SYMBOL,base,buf[0],buf[1],(int32_t)(time(NULL)-buf[2]));
} //else fprintf(stderr,"%s size error RT\n",base);
fclose(fp);
@ -1606,7 +1606,7 @@ void komodo_PriceCache_shift()
memcpy(PriceCache[0],Mineropret.data(),Mineropret.size());
}
int32_t _komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,CBlock *block)
int32_t _hush_heightpricebits(uint64_t *seedp,uint32_t *heightbits,CBlock *block)
{
CTransaction tx; int32_t numvouts; std::vector<uint8_t> vopret;
tx = block->vtx[0];
@ -1622,8 +1622,8 @@ int32_t _komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,CBlock *blo
return(-1);
}
// komodo_heightpricebits() extracts the price data in the coinbase for nHeight
int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight)
// hush_heightpricebits() extracts the price data in the coinbase for nHeight
int32_t hush_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight)
{
CBlockIndex *pindex; CBlock block;
if ( seedp != 0 )
@ -1632,7 +1632,7 @@ int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHei
{
if ( komodo_blockload(block,pindex) == 0 )
{
return(_komodo_heightpricebits(seedp,heightbits,&block));
return(_hush_heightpricebits(seedp,heightbits,&block));
}
}
fprintf(stderr,"couldnt get pricebits for %d\n",nHeight);
@ -1731,7 +1731,7 @@ CScript komodo_mineropret(int32_t nHeight)
sleep(61);
}
}
if ( komodo_heightpricebits(0,prevbits,nHeight-1) > 0 )
if ( hush_heightpricebits(0,prevbits,nHeight-1) > 0 )
{
memcpy(pricebits,Mineropret.data(),Mineropret.size());
memset(maxflags,0,sizeof(maxflags));
@ -1813,7 +1813,7 @@ int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,i
btcgbp = (double)pricebits[2]/10000;
btceur = (double)pricebits[3]/10000;
fprintf(stderr,"ht.%d: lag.%d %.4f USD, %.4f GBP, %.4f EUR, GBPUSD %.6f, EURUSD %.6f, EURGBP %.6f [%d]\n",nHeight,lag,btcusd,btcgbp,btceur,btcusd/btcgbp,btcusd/btceur,btcgbp/btceur,lag2);
if ( komodo_heightpricebits(0,prevbits,nHeight-1) > 0 )
if ( hush_heightpricebits(0,prevbits,nHeight-1) > 0 )
{
if ( nHeight < testchain_exemption )
{
@ -2743,7 +2743,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock)
tmpbuf = (int64_t *)calloc(sizeof(int64_t),2*PRICES_DAYWINDOW);
fprintf(stderr,"prices update: numprices.%d %p %p\n",numprices,ptr32,ptr64);
}
if ( _komodo_heightpricebits(&seed,rawprices,pblock) == numprices )
if ( _hush_heightpricebits(&seed,rawprices,pblock) == numprices )
{
//for (ind=0; ind<numprices; ind++)
// fprintf(stderr,"%u ",rawprices[ind]);

6
src/hush_globals.h

@ -18,7 +18,7 @@
#include "hush_defs.h"
void komodo_prefetch(FILE *fp);
uint32_t komodo_heightstamp(int32_t height);
uint32_t hush_heightstamp(int32_t height);
void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint32_t ktime,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth);
void komodo_init(int32_t height);
int32_t hush_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip);
@ -47,8 +47,8 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10;
uint256 HUSH_EARLYTXID;
int32_t HUSH_MININGTHREADS = -1,IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY,HUSH_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,HUSH_EXTERNAL_NOTARIES,HUSH_PASSPORT_INITDONE,KOMODO_PAX,HUSH_EXCHANGEWALLET,HUSH_REWIND,HUSH_CONNECTING = -1,KOMODO_DEALERNODE,HUSH_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,HUSH_NSPV;
int32_t HUSH_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,HUSH_CCACTIVATE;
int32_t HUSH_MININGTHREADS = -1,IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY,HUSH_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,HUSH_EXTERNAL_NOTARIES,HUSH_PASSPORT_INITDONE,HUSH_PAX,HUSH_EXCHANGEWALLET,HUSH_REWIND,HUSH_CONNECTING = -1,KOMODO_DEALERNODE,HUSH_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,HUSH_NSPV;
int32_t HUSH_INSYNC,HUSH_LASTMINED,prevHUSH_LASTMINED,HUSH_CCACTIVATE;
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,ASSETCHAINS_SELFIMPORT,ASSETCHAINS_CCLIB;
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_MARMARA;
int8_t ASSETCHAINS_ADAPTIVEPOW;

4
src/hush_nk.h

@ -1,5 +1,5 @@
#ifndef KOMODO_NK_H
#define KOMODO_NK_H
#ifndef HUSH_NK_H
#define HUSH_NK_H
//#define ASSETCHAINS_N 77
//#define ASSETCHAINS_K 3

2
src/hush_notary.h

@ -91,7 +91,7 @@ int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp)
static uint8_t kmd_pubkeys[NUM_HUSH_SEASONS][64][33],didinit[NUM_HUSH_SEASONS];
if ( timestamp == 0 && SMART_CHAIN_SYMBOL[0] != 0 ) {
timestamp = komodo_heightstamp(height);
timestamp = hush_heightstamp(height);
} else if ( SMART_CHAIN_SYMBOL[0] == 0 ) {
timestamp = 0;
}

4
src/hush_pax.h

@ -426,7 +426,7 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed)
uint64_t komodo_paxcalc(int32_t height,uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t basevolume,uint64_t refkmdbtc,uint64_t refbtcusd)
{
uint32_t pvalb,pvalr; double BTCUSD; uint64_t price,kmdbtc,btcusd,usdvol,baseusd,usdkmd,baserel,ranked[32];
if ( basevolume > KOMODO_PAXMAX )
if ( basevolume > HUSH_PAXMAX )
{
printf("paxcalc overflow %.8f\n",dstr(basevolume));
return(0);
@ -559,7 +559,7 @@ int32_t komodo_kmdbtcusd(int32_t rwflag,uint64_t *kmdbtcp,uint64_t *btcusdp,int3
uint64_t _komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume)
{
int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0,votes[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],btcusds[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtcs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtc,btcusd;
if ( basevolume > KOMODO_PAXMAX )
if ( basevolume > HUSH_PAXMAX )
{
printf("komodo_paxprice overflow %.8f\n",dstr(basevolume));
return(0);

2
src/hush_structs.h

@ -28,7 +28,7 @@
#ifndef HUSH_STRUCTS_H
#define HUSH_STRUCTS_H
#define GENESIS_NBITS 0x1f00ffff
#define KOMODO_MINRATIFY ((height < 90000) ? 7 : 11)
#define HUSH_MINRATIFY ((height < 90000) ? 7 : 11)
#define HUSH_NOTARIES_HARDCODED 180000 // DONT CHANGE
#define HUSH_MAXBLOCKS 250000 // DONT CHANGE
#define HUSH_EVENT_RATIFY 'P'

2
src/main.cpp

@ -3247,8 +3247,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
}
bool fScriptChecks = (!fCheckpointsEnabled || pindex->GetHeight() >= Checkpoints::GetTotalBlocksEstimate(chainparams.Checkpoints()));
//if ( KOMODO_TESTNET_EXPIRATION != 0 && pindex->GetHeight() > KOMODO_TESTNET_EXPIRATION ) // "testnet"
// return(false);
// Do not allow blocks that contain transactions which 'overwrite' older transactions,
// unless those are already completely spent.
BOOST_FOREACH(const CTransaction& tx, block.vtx) {

6
src/miner.cpp

@ -980,7 +980,7 @@ int32_t komodo_baseid(char *origbase);
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t *blocktimes,int32_t *nonzpkeysp,int32_t height);
arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc);
int32_t FOUND_BLOCK,KOMODO_MAYBEMINED;
extern int32_t KOMODO_LASTMINED,HUSH_INSYNC;
extern int32_t HUSH_LASTMINED,HUSH_INSYNC;
int32_t roundrobin_delay;
arith_uint256 HASHTarget,HASHTarget_POW;
@ -1248,9 +1248,9 @@ void static BitcoinMiner()
if ( mids[j] == notaryid )
break;
if ( j == 65 )
KOMODO_LASTMINED = 0;
HUSH_LASTMINED = 0;
} else fprintf(stderr,"no nonz pubkeys\n");
if ( (Mining_height >= 235300 && Mining_height < 236000) || (j == 65 && Mining_height > KOMODO_MAYBEMINED+1 && Mining_height > KOMODO_LASTMINED+64) )
if ( (Mining_height >= 235300 && Mining_height < 236000) || (j == 65 && Mining_height > KOMODO_MAYBEMINED+1 && Mining_height > HUSH_LASTMINED+64) )
{
HASHTarget = arith_uint256().SetCompact(HUSH_MINDIFF_NBITS);
fprintf(stderr,"I am the chosen one for %s ht.%d\n",SMART_CHAIN_SYMBOL,pindexPrev->GetHeight()+1);

3
src/net.h

@ -42,7 +42,8 @@
#include <boost/filesystem/path.hpp>
#include <boost/foreach.hpp>
#include <boost/signals2/signal.hpp>
// Enable WolfSSL Support for Hush
// Enable side-channel resistant WolfSSL Support for Hush
#define ECC_TIMING_RESISTANT 420
#include <wolfssl/options.h>
#include <wolfssl/ssl.h>

14
src/rpc/blockchain.cpp

@ -151,7 +151,7 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex)
result.push_back(Pair("bits", strprintf("%08x", blockindex->nBits)));
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
result.push_back(Pair("chainwork", blockindex->chainPower.chainWork.GetHex()));
result.push_back(Pair("segid", (int)komodo_segid(0,blockindex->GetHeight())));
result.push_back(Pair("segid", (int)hush_segid(0,blockindex->GetHeight())));
if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
@ -178,7 +178,7 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex)
result.push_back(Pair("height", blockindex->GetHeight()));
result.push_back(Pair("version", block.nVersion));
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
result.push_back(Pair("segid", (int)komodo_segid(0,blockindex->GetHeight())));
result.push_back(Pair("segid", (int)hush_segid(0,blockindex->GetHeight())));
UniValue deltas(UniValue::VARR);
@ -299,7 +299,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
result.push_back(Pair("height", blockindex->GetHeight()));
result.push_back(Pair("version", block.nVersion));
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
result.push_back(Pair("segid", (int)komodo_segid(0,blockindex->GetHeight())));
result.push_back(Pair("segid", (int)hush_segid(0,blockindex->GetHeight())));
result.push_back(Pair("finalsaplingroot", block.hashFinalSaplingRoot.GetHex()));
UniValue txs(UniValue::VARR);
BOOST_FOREACH(const CTransaction&tx, block.vtx)
@ -1105,12 +1105,12 @@ UniValue paxprice(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
int32_t height,i,n,width,numpricefeeds = -1; uint64_t seed,ignore,rngval; uint32_t rawprices[1440*6],*ptr; int64_t *tmpbuf;
width = numblocks+PRICES_DAYWINDOW*2+PRICES_SMOOTHWIDTH; // need 2*PRICES_DAYWINDOW previous raw price points to calc PRICES_DAYWINDOW correlated points to calc, in turn, smoothed point
komodo_heightpricebits(&seed,rawprices,firstheight + numblocks - 1);
hush_heightpricebits(&seed,rawprices,firstheight + numblocks - 1);
if ( firstheight < width )
return(-1);
for (i=0; i<width; i++)
{
if ( (n= komodo_heightpricebits(&ignore,rawprices,firstheight + numblocks - 1 - i)) < 0 ) // stores raw prices in backward order
if ( (n= hush_heightpricebits(&ignore,rawprices,firstheight + numblocks - 1 - i)) < 0 ) // stores raw prices in backward order
return(-1);
if ( numpricefeeds < 0 )
numpricefeeds = n;
@ -1154,7 +1154,7 @@ UniValue prices(const UniValue& params, bool fHelp, const CPubKey& mypk)
if ( PRICES_DAYWINDOW < 7 )
throw JSONRPCError(RPC_INVALID_PARAMETER, "daywindow is too small");
width = maxsamples+2*PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH;
numpricefeeds = komodo_heightpricebits(&seed,rawprices,nextheight-1);
numpricefeeds = hush_heightpricebits(&seed,rawprices,nextheight-1);
if ( numpricefeeds <= 0 )
throw JSONRPCError(RPC_INVALID_PARAMETER, "illegal numpricefeeds");
prices = (uint32_t *)calloc(sizeof(*prices),width*numpricefeeds);
@ -1166,7 +1166,7 @@ UniValue prices(const UniValue& params, bool fHelp, const CPubKey& mypk)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
else
{
if ( (n= komodo_heightpricebits(0,rawprices,ht)) > 0 )
if ( (n= hush_heightpricebits(0,rawprices,ht)) > 0 )
{
if ( n != numpricefeeds )
throw JSONRPCError(RPC_INVALID_PARAMETER, "numprices != first numprices");

13
src/rpc/misc.cpp

@ -62,17 +62,14 @@ int32_t hush_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *tx
bool komodo_txnotarizedconfirmed(uint256 txid);
uint32_t hush_chainactive_timestamp();
int32_t hush_whoami(char *pubkeystr,int32_t height,uint32_t timestamp);
extern int32_t KOMODO_LASTMINED,HUSH_LONGESTCHAIN,IS_HUSH_NOTARY,HUSH_INSYNC;
extern int32_t HUSH_LASTMINED,HUSH_LONGESTCHAIN,IS_HUSH_NOTARY,HUSH_INSYNC;
extern char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];
uint32_t komodo_segid32(char *coinaddr);
uint32_t hush_segid32(char *coinaddr);
int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height);
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *hushnotarized_heightp);
uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount);
int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
// This is the last version of upstream that was merged in
// We only cherry-pick since then
#define KOMODO_VERSION "0.5.0"
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
extern uint32_t ASSETCHAINS_CC;
extern uint32_t ASSETCHAINS_MAGIC,ASSETCHAINS_ALGO;
@ -280,8 +277,8 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
char pubkeystr[65]; int32_t notaryid; std::string notaryname;
if( (notaryid= hush_whoami(pubkeystr,(int32_t)chainActive.LastTip()->GetHeight(),hush_chainactive_timestamp())) >= 0 ) {
obj.push_back(Pair("notaryid", notaryid));
if ( KOMODO_LASTMINED != 0 )
obj.push_back(Pair("lastmined", KOMODO_LASTMINED));
if ( HUSH_LASTMINED != 0 )
obj.push_back(Pair("lastmined", HUSH_LASTMINED));
}
obj.push_back(Pair("pubkey", NOTARY_PUBKEY));
}
@ -496,7 +493,7 @@ UniValue validateaddress(const UniValue& params, bool fHelp, const CPubKey& mypk
CScript scriptPubKey = GetScriptForDestination(dest);
ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end())));
ret.push_back(Pair("segid", (int32_t)komodo_segid32((char *)params[0].get_str().c_str()) & 0x3f));
ret.push_back(Pair("segid", (int32_t)hush_segid32((char *)params[0].get_str().c_str()) & 0x3f));
#ifdef ENABLE_WALLET
isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO;
ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false));

4
src/txdb.cpp

@ -426,7 +426,7 @@ bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, int type,
}
bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address);
uint32_t komodo_segid32(char *coinaddr);
uint32_t hush_segid32(char *coinaddr);
#define DECLARE_IGNORELIST std::map <std::string,int> ignoredMap = { \
{"RReUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1}, \
@ -580,7 +580,7 @@ UniValue CBlockTreeDB::Snapshot(int top)
char amount[32];
sprintf(amount, "%.8f", (double) it->first / COIN);
obj.push_back( make_pair("amount", amount) );
obj.push_back( make_pair("segid",(int32_t)komodo_segid32((char *)it->second.c_str()) & 0x3f) );
obj.push_back( make_pair("segid",(int32_t)hush_segid32((char *)it->second.c_str()) & 0x3f) );
addressesSorted.push_back(obj);
topN++;
// If requested, only show top N addresses in output JSON

12
src/wallet-utility.cpp

@ -8,8 +8,8 @@
#include "base58.h"
#include "wallet/crypter.h"
#include <boost/foreach.hpp>
#include "hush_defs.h"
char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];
int64_t MAX_MONEY = 200000000 * 100000000LL;
uint64_t ASSETCHAINS_SUPPLY;
@ -19,12 +19,10 @@ uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC;
uint32_t ASSETCHAINS_MAGIC = 2387029918;
uint32_t ASSETCHAINS_EQUIHASH = 0;
uint32_t ASSETCHAINS_ALGO = 0;
int32_t ASSETCHAINS_LWMAPOS = 0;
int32_t ASSETCHAINS_OVERWINTER = 227520;
int32_t ASSETCHAINS_SAPLING = 227520;
int32_t HUSH_TESTNODE = 0;
int32_t KOMODO_BLOCK_POSUNITS = 1000;
int32_t ASSETCHAINS_LWMAPOS = 0;
int32_t ASSETCHAINS_OVERWINTER = 227520;
int32_t ASSETCHAINS_SAPLING = 227520;
int32_t HUSH_TESTNODE = 0;
unsigned int MAX_BLOCK_SIGOPS = 20000;
void show_help()

12
src/wallet/rpcwallet.cpp

@ -62,7 +62,7 @@ extern std::string ASSETCHAINS_OVERRIDE_PUBKEY;
const std::string ADDR_TYPE_SAPLING = "sapling";
const std::string ADDR_TYPE_AMNESIA = "amnesia";
extern int32_t HUSH_INSYNC;
uint32_t komodo_segid32(char *coinaddr);
uint32_t hush_segid32(char *coinaddr);
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
int32_t hush_isnotaryvout(char *coinaddr,uint32_t tiptime); // from ac_private chains only
CBlockIndex *komodo_getblockindex(uint256 hash);
@ -569,7 +569,7 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
#define DRAGON_MAXSCRIPTSIZE 10001
uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pubkey37[37],char *coinaddr,int32_t height,char *base,int64_t fiatoshis);
int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen);
extern int32_t KOMODO_PAX;
extern int32_t HUSH_PAX;
int32_t komodo_is_issuer();
int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
int32_t komodo_isrealtime(int32_t *kmdheightp);
@ -728,7 +728,7 @@ UniValue paxdeposit(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
uint64_t available,deposited,issued,withdrawn,approved,redeemed,seed,komodoshis = 0; int32_t height; char destaddr[64]; uint8_t i,pubkey37[33];
bool fSubtractFeeFromAmount = false;
if ( KOMODO_PAX == 0 )
if ( HUSH_PAX == 0 )
{
throw runtime_error("paxdeposit disabled without -pax");
}
@ -2842,7 +2842,7 @@ UniValue resendwallettransactions(const UniValue& params, bool fHelp, const CPub
return result;
}
extern uint32_t komodo_segid32(char *coinaddr);
extern uint32_t hush_segid32(char *coinaddr);
UniValue listunspent(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
@ -2946,7 +2946,7 @@ UniValue listunspent(const UniValue& params, bool fHelp, const CPubKey& mypk)
if (fValidAddress) {
entry.push_back(Pair("address", EncodeDestination(address)));
entry.push_back(Pair("segid", (int)komodo_segid32((char*)EncodeDestination(address).c_str()) & 0x3f ));
entry.push_back(Pair("segid", (int)hush_segid32((char*)EncodeDestination(address).c_str()) & 0x3f ));
if (pwalletMain->mapAddressBook.count(address))
entry.push_back(Pair("account", pwalletMain->mapAddressBook[address].name));
@ -7756,7 +7756,7 @@ UniValue getbalance64(const UniValue& params, bool fHelp, const CPubKey& mypk)
nValue = out.tx->vout[out.i].nValue;
if ( ExtractDestination(out.tx->vout[out.i].scriptPubKey, address) )
{
segid = (komodo_segid32((char *)CBitcoinAddress(address).ToString().c_str()) & 0x3f);
segid = (hush_segid32((char *)CBitcoinAddress(address).ToString().c_str()) & 0x3f);
if ( out.nDepth < 100 )
nValues2[segid] += nValue, total2 += nValue;
else nValues[segid] += nValue, total += nValue;

Loading…
Cancel
Save