Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/alert.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
#include <stdint.h>
#include <string>

class CAlert;
class CNode;
class uint256;

extern std::map<uint256, CAlert> mapAlerts;
extern CCriticalSection cs_mapAlerts;

/** Alerts are for notifying old versions if they become too obsolete and
Expand Down Expand Up @@ -86,6 +81,9 @@ class CUnsignedAlert
std::string ToString() const;
};

class CNode;
class uint256;

/** An alert is a combination of a serialized CUnsignedAlert and a signature. */
class CAlert : public CUnsignedAlert
{
Expand Down Expand Up @@ -124,4 +122,6 @@ class CAlert : public CUnsignedAlert
static CAlert getAlertByHash(const uint256 &hash);
};

extern std::map<uint256, CAlert> mapAlerts;

#endif // BITCOIN_ALERT_H
14 changes: 2 additions & 12 deletions src/amount.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,18 @@
#ifndef BITCOIN_AMOUNT_H
#define BITCOIN_AMOUNT_H

#include "serialize.h"

#include "serialize.h"
#include <stdlib.h>
#include <string>
#include <cstdint>

typedef int64_t CAmount;

static const CAmount COIN = 100000000;
static const CAmount CENT = 1000000;

extern const std::string CURRENCY_UNIT;

/** No amount larger than this (in satoshi) is valid.
*
* Note that this constant is *not* the total money supply, which in Bitcoin
* currently happens to be less than 21,000,000 BTC for various reasons, but
* rather a sanity check. As this sanity check is used by consensus-critical
* validation code, the exact value of the MAX_MONEY constant is consensus
* critical; in unusual circumstances like a(nother) overflow bug that allowed
* for the creation of coins out of thin air modification could lead to a fork.
* */
//static const CAmount MAX_MONEY = 21000000 * COIN;
extern int64_t MAX_MONEY;

inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
Expand Down
29 changes: 5 additions & 24 deletions src/bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
#include "util.h"
#include "httpserver.h"
#include "httprpc.h"
#include "komodo.h"
#include "komodo_defs.h"
#include "komodo_gateway.h"
#include "komodo_bitcoind.h"
#include "komodo_gateway.h"

#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem.hpp>
Expand Down Expand Up @@ -56,15 +61,6 @@
*/

static bool fDaemon;
#include "komodo_defs.h"
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
extern int32_t ASSETCHAINS_BLOCKTIME;
extern uint64_t ASSETCHAINS_CBOPRET;
void komodo_passport_iteration();
uint64_t komodo_interestsum();
int32_t komodo_longestchain();
void komodo_cbopretupdate(int32_t forceflag);
CBlockIndex *komodo_chainactive(int32_t height);

void WaitForShutdown(boost::thread_group* threadGroup)
{
Expand All @@ -76,14 +72,6 @@ void WaitForShutdown(boost::thread_group* threadGroup)
fprintf(stderr,"error: earlytx must be before block height %d or tx does not exist\n",KOMODO_EARLYTXID_HEIGHT);
StartShutdown();
}
/*if ( ASSETCHAINS_STAKED == 0 && ASSETCHAINS_ADAPTIVEPOW == 0 && (pindex= komodo_chainactive(1)) != 0 )
{
if ( pindex->nTime > ADAPTIVEPOW_CHANGETO_DEFAULTON )
{
ASSETCHAINS_ADAPTIVEPOW = 1;
fprintf(stderr,"default activate adaptivepow\n");
} else fprintf(stderr,"height1 time %u vs %u\n",pindex->nTime,ADAPTIVEPOW_CHANGETO_DEFAULTON);
} //else fprintf(stderr,"cant find height 1\n");*/
if ( ASSETCHAINS_CBOPRET != 0 )
komodo_pricesinit();
/*
Expand All @@ -107,13 +95,6 @@ void WaitForShutdown(boost::thread_group* threadGroup)
//
// Start
//
extern bool IS_KOMODO_NOTARY;
extern int32_t USE_EXTERNAL_PUBKEY;
extern uint32_t ASSETCHAIN_INIT;
extern std::string NOTARY_PUBKEY;
int32_t komodo_is_issuer();
void komodo_passport_iteration();

bool AppInit(int argc, char* argv[])
{
boost::thread_group threadGroup;
Expand Down
2 changes: 2 additions & 0 deletions src/cc/CCGateways.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ UniValue GatewaysExternalAddress(uint256 bindtxid,CPubKey pubkey);
UniValue GatewaysDumpPrivKey(uint256 bindtxid,CKey privkey);
UniValue GatewaysList();

uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,uint256 &tokenid,std::string &coin,int64_t &totalsupply,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector<CPubKey> &gatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2,uint8_t &wiftype);

#endif
6 changes: 5 additions & 1 deletion src/cc/CCImportGateway.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ UniValue ImportGatewayExternalAddress(uint256 bindtxid,CPubKey pubkey);
UniValue ImportGatewayDumpPrivKey(uint256 bindtxid,CKey key);
UniValue ImportGatewayList();
UniValue ImportGatewayInfo(uint256 bindtxid);
#endif

uint8_t DecodeImportGatewayBindOpRet(char *burnaddr,const CScript &scriptPubKey,std::string &coin,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector<CPubKey> &importgatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2,uint8_t &wiftype);
int64_t ImportGatewayVerify(char *refburnaddr,uint256 oracletxid,int32_t claimvout,std::string refcoin,uint256 burntxid,const std::string deposithex,std::vector<uint8_t>proof,uint256 merkleroot,CPubKey destpub,uint8_t taddr,uint8_t prefix,uint8_t prefix2);

#endif
1 change: 0 additions & 1 deletion src/cc/CCPayments.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#define CC_PAYMENTS_H

#include "CCinclude.h"
#include <gmp.h>
#include <key_io.h>

#define PAYMENTS_TXFEE 10000
Expand Down
7 changes: 4 additions & 3 deletions src/cc/CCPrices.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
#ifndef CC_PRICES_H
#define CC_PRICES_H

#include "komodo_defs.h"
#include "komodo_globals.h"
#include "komodo_gateway.h"
#include "CCinclude.h"

int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks);
extern void GetKomodoEarlytxidScriptPub();
extern CScript KOMODO_EARLYTXID_SCRIPTPUB;

// #define PRICES_DAYWINDOW ((3600*24/ASSETCHAINS_BLOCKTIME) + 1) // defined in komodo_defs.h
#define PRICES_TXFEE 10000
Expand Down Expand Up @@ -59,5 +58,7 @@ UniValue PricesList(uint32_t filter, CPubKey mypk);
UniValue PricesGetOrderbook();
UniValue PricesRefillFund(int64_t amount);

int32_t prices_syntheticvec(std::vector<uint16_t> &vec, std::vector<std::string> synthetic);
int64_t prices_syntheticprice(std::vector<uint16_t> vec, int32_t height, int32_t minmax, int16_t leverage);

#endif
2 changes: 1 addition & 1 deletion src/cc/CCassetstx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "CCassets.h"
#include "CCtokens.h"

#include "komodo_bitcoind.h"

UniValue AssetOrders(uint256 refassetid, CPubKey pk, uint8_t additionalEvalCode)
{
Expand Down
16 changes: 3 additions & 13 deletions src/cc/CCinclude.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ extern CWallet* pwalletMain; //!< global wallet object pointer to access wallet

/// @private seems old-style
bool GetAddressUnspent(uint160 addressHash, int type,std::vector<std::pair<CAddressUnspentKey,CAddressUnspentValue> > &unspentOutputs);
//CBlockIndex *komodo_getblockindex(uint256 hash); //moved to komodo_def.h
//int32_t komodo_nextheight(); //moved to komodo_def.h

/// CCgetspenttxid finds the txid of the transaction which spends a transaction output. The function does this without loading transactions from the chain, by using spent index
/// @param[out] spenttxid transaction id of the spending transaction
Expand All @@ -254,11 +252,6 @@ void CCclearvars(struct CCcontract_info *cp);
UniValue CClib(struct CCcontract_info *cp,char *method,char *jsonstr);
UniValue CClib_info(struct CCcontract_info *cp);

//CBlockIndex *komodo_blockindex(uint256 hash); //moved to komodo_def.h
//CBlockIndex *komodo_chainactive(int32_t height); //moved to komodo_def.h
//int32_t komodo_blockheight(uint256 hash); //moved to komodo_def.h
//void StartShutdown();

static const uint256 zeroid; //!< null uint256 constant

/// \cond INTERNAL
Expand Down Expand Up @@ -370,11 +363,8 @@ int64_t IsTokensvout(bool goDeeper, bool checkPubkeys, struct CCcontract_info *c
/// returns true if success
bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx);

//void komodo_sendmessage(int32_t minpeers,int32_t maxpeers,const char *message,std::vector<uint8_t> payload); // moved to komodo_defs.h

/// @private
int32_t payments_parsehexdata(std::vector<uint8_t> &hexdata,cJSON *item,int32_t len);
// int32_t komodo_blockload(CBlock& block,CBlockIndex *pindex); // this def in komodo_defs.h

/// Makes opreturn scriptPubKey for token creation transaction. Normally this function is called internally by the tokencreate rpc. You might need to call this function to create a customized token.
/// The total opreturn length should not exceed 10001 byte
Expand Down Expand Up @@ -691,7 +681,6 @@ uint64_t stringbits(char *str);
uint256 revuint256(uint256 txid);
char *uint256_str(char *dest,uint256 txid);
char *pubkey33_str(char *dest,uint8_t *pubkey33);
//uint256 Parseuint256(const char *hexstr); // located in komodo_defs
/// \endcond

/// converts public key as array of uint8_t to normal address
Expand Down Expand Up @@ -785,8 +774,6 @@ int32_t CCCointxidExists(char const *logcategory,uint256 cointxid);
/// @private
uint256 BitcoinGetProofMerkleRoot(const std::vector<uint8_t> &proofData, std::vector<uint256> &txids);

// bool komodo_txnotarizedconfirmed(uint256 txid); //moved to komodo_defs.h

/// @private
CPubKey check_signing_pubkey(CScript scriptSig);

Expand Down Expand Up @@ -990,6 +977,9 @@ UniValue report_ccerror(const char *category, int level, T print_to_stream)
return err;
}

bool komodo_txnotarizedconfirmed(uint256 txid);
uint32_t GetLatestTimestamp(int32_t height);

/// @private
#define CCERR_RESULT(category,level,logoperator) return report_ccerror(category, level, [=](std::ostringstream &stream) {logoperator;})
#endif // #ifndef LOGSTREAM_DEFINED
Expand Down
1 change: 0 additions & 1 deletion src/cc/CCrewards.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#define CC_REWARDS_H

#include "CCinclude.h"
#include <gmp.h>

#define EVAL_REWARDS 0xe5
#define REWARDSCC_MAXAPR (COIN * 25)
Expand Down
1 change: 1 addition & 0 deletions src/cc/CCtokens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "CCtokens.h"
#include "importcoin.h"
#include "komodo_bitcoind.h"

/* TODO: correct this:
-----------------------------
Expand Down
14 changes: 4 additions & 10 deletions src/cc/CCutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@

#include "CCinclude.h"
#include "komodo_structs.h"
#include "komodo_bitcoind.h"
#include "komodo_utils.h"
#include "key_io.h"

#ifdef TESTMODE
#define MIN_NON_NOTARIZED_CONFIRMS 2
#else
#define MIN_NON_NOTARIZED_CONFIRMS 101
#endif // TESTMODE
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
struct komodo_state *komodo_stateptr(char *symbol,char *dest);
extern uint32_t KOMODO_DPOWCONFS;

void endiancpy(uint8_t *dest,uint8_t *src,int32_t len)
{
Expand Down Expand Up @@ -434,7 +433,6 @@ bool priv2addr(char *coinaddr,uint8_t *buf33,uint8_t priv32[32])

std::vector<uint8_t> Mypubkey()
{
extern uint8_t NOTARY_PUBKEY33[33];
std::vector<uint8_t> pubkey; int32_t i; uint8_t *dest,*pubkey33;
pubkey33 = NOTARY_PUBKEY33;
pubkey.resize(33);
Expand All @@ -444,25 +442,22 @@ std::vector<uint8_t> Mypubkey()
return(pubkey);
}

extern char NSPV_wifstr[],NSPV_pubkeystr[];
extern uint32_t NSPV_logintime;
#define NSPV_AUTOLOGOUT 777

bool Myprivkey(uint8_t myprivkey[])
{
char coinaddr[64],checkaddr[64]; std::string strAddress; char *dest; int32_t i,n; CBitcoinAddress address; CKeyID keyID; CKey vchSecret; uint8_t buf33[33];
if ( KOMODO_NSPV_SUPERLITE )
{
extern uint32_t NSPV_logintime;
if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT )
{
fprintf(stderr,"need to be logged in to get myprivkey\n");
return false;
}
extern char *NSPV_wifstr;
vchSecret = DecodeSecret(NSPV_wifstr);
memcpy(myprivkey,vchSecret.begin(),32);
//for (i=0; i<32; i++)
// fprintf(stderr,"%02x",myprivkey[i]);
//fprintf(stderr," myprivkey %s\n",NSPV_wifstr);
memset((uint8_t *)vchSecret.begin(),0,32);
return true;
}
Expand Down Expand Up @@ -836,7 +831,6 @@ bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector<uint8_t> param
if (cp->validate == NULL)
return eval->Invalid("validation not supported for eval code");

//fprintf(stderr,"KOMODO_CONNECTING.%d mempool.%d vs CCactive.%d\n",height,from_mempool,KOMODO_CCACTIVATE);
// there is a chance CC tx is valid in mempool, but invalid when in block, so we cant filter duplicate requests. if any of the vins are spent, for example
//txid = ctx.GetHash();
//if ( txid == cp->prevtxid )
Expand Down
1 change: 1 addition & 0 deletions src/cc/auction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "CCauction.h"
#include "../txmempool.h"
#include "komodo_bitcoind.h"

/*
*/
Expand Down
3 changes: 1 addition & 2 deletions src/cc/betprotocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#include "cc/eval.h"
#include "cc/utils.h"
#include "primitives/transaction.h"

int32_t komodo_nextheight();
#include "komodo_bitcoind.h"

std::vector<CC*> BetProtocol::PlayerConditions()
{
Expand Down
1 change: 1 addition & 0 deletions src/cc/cclib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "core_io.h"
#include "crosschain.h"
#include "hex.h"
#include "komodo_bitcoind.h"

#define FAUCET2SIZE COIN
#define EVAL_FAUCET2 EVAL_FIRSTUSER
Expand Down
1 change: 1 addition & 0 deletions src/cc/channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
******************************************************************************/

#include "CCchannels.h"
#include "komodo_bitcoind.h"

/*
The idea here is to allow instant (mempool) payments that are secured by dPoW. In order to simplify things, channels CC will require creating reserves for each payee locked in the destination user's CC address. This will look like the payment is already made, but it is locked until further released. The dPoW protection comes from the cancel channel having a delayed effect until the next notarization. This way, if a payment release is made and the chain reorged, the same payment release will still be valid when it is re-broadcast into the mempool.
Expand Down
2 changes: 2 additions & 0 deletions src/cc/customcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

The above will rebuild komodod and get it running again
*/
#include "komodo_bitcoind.h"


CScript custom_opret(uint8_t funcid,CPubKey pk)
{
Expand Down
2 changes: 1 addition & 1 deletion src/cc/dice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
******************************************************************************/
#include "hex.h"
#include "CCdice.h"
#include "komodo_bitcoind.h"

// timeout

Expand Down Expand Up @@ -99,7 +100,6 @@ What is needed is for the dealer node to track the entropy tx that was already b

#define MAX_ENTROPYUSED 8192
#define DICE_MINUTXOS 15000
extern int32_t KOMODO_INSYNC;

pthread_mutex_t DICE_MUTEX,DICEREVEALED_MUTEX;

Expand Down
2 changes: 1 addition & 1 deletion src/cc/dilithium.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define DBENCH_STOP(arg)

#include "dilithium.h"

#include "komodo_bitcoind.h"

#define NROUNDS 24
#define ROL(a, offset) ((a << offset) ^ (a >> (64-offset)))
Expand Down
Loading