Merge pull request #44 from jl777/dPoW

bundle assetchains
This commit is contained in:
jl777
2016-10-29 16:40:31 -03:00
committed by GitHub
55 changed files with 468 additions and 216 deletions

View File

@@ -152,6 +152,11 @@ tail -f ~/.komodo/debug.log
#To view all command
./src/komodo-cli help
ASSETCHAINS: -ac_name=name -ac_supply=nnnnn
Both komodod and komodo-cli recognize -ac_name=option so you can create a zcash fork from the commandline
```
=======

32
src/assetchains Executable file
View File

@@ -0,0 +1,32 @@
./komodod -ac_name=USD -addnode=78.47.196.146 &
./komodod -ac_name=EUR -addnode=78.47.196.146 &
./komodod -ac_name=JPY -addnode=78.47.196.146 &
./komodod -ac_name=GBP -addnode=78.47.196.146 &
./komodod -ac_name=AUD -addnode=78.47.196.146 &
./komodod -ac_name=CAD -addnode=78.47.196.146 &
./komodod -ac_name=CHF -addnode=78.47.196.146 &
./komodod -ac_name=NZD -addnode=78.47.196.146 &
./komodod -ac_name=CNY -addnode=78.47.196.146 &
./komodod -ac_name=RUB -addnode=78.47.196.146 &
./komodod -ac_name=MXN -addnode=78.47.196.146 &
./komodod -ac_name=BRL -addnode=78.47.196.146 &
./komodod -ac_name=INR -addnode=78.47.196.146 &
./komodod -ac_name=HKD -addnode=78.47.196.146 &
./komodod -ac_name=TRY -addnode=78.47.196.146 &
./komodod -ac_name=ZAR -addnode=78.47.196.146 &
./komodod -ac_name=PLN -addnode=78.47.196.146 &
./komodod -ac_name=NOK -addnode=78.47.196.146 &
./komodod -ac_name=SEK -addnode=78.47.196.146 &
./komodod -ac_name=DKK -addnode=78.47.196.146 &
./komodod -ac_name=CZK -addnode=78.47.196.146 &
./komodod -ac_name=HUF -addnode=78.47.196.146 &
./komodod -ac_name=ILS -addnode=78.47.196.146 &
./komodod -ac_name=KRW -addnode=78.47.196.146 &
./komodod -ac_name=MYR -addnode=78.47.196.146 &
./komodod -ac_name=PHP -addnode=78.47.196.146 &
./komodod -ac_name=RON -addnode=78.47.196.146 &
./komodod -ac_name=SGD -addnode=78.47.196.146 &
./komodod -ac_name=THB -addnode=78.47.196.146 &
./komodod -ac_name=BGN -addnode=78.47.196.146 &
./komodod -ac_name=IDR -addnode=78.47.196.146 &
./komodod -ac_name=HRK -addnode=78.47.196.146 &

View File

@@ -56,12 +56,18 @@ public:
};
#include "uint256.h"
#include "arith_uint256.h"
#include "komodo_globals.h"
#include "komodo_utils.h"
static bool AppInitRPC(int argc, char* argv[])
{
//
// Parameters
//
ParseParameters(argc, argv);
komodo_args();
if (argc<2 || mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version")) {
std::string strUsage = _("Komodo RPC client version") + " " + FormatFullVersion() + "\n";
if (!mapArgs.count("-version")) {

View File

@@ -32,6 +32,8 @@
*/
static bool fDaemon;
extern char ASSETCHAINS_SYMBOL[16];
void komodo_gateway_iteration(char *symbol);
void WaitForShutdown(boost::thread_group* threadGroup)
{
@@ -39,7 +41,9 @@ void WaitForShutdown(boost::thread_group* threadGroup)
// Tell the main threads to shutdown.
while (!fShutdown)
{
MilliSleep(200);
MilliSleep(2000);
if ( ASSETCHAINS_SYMBOL[0] != 0 )
komodo_gateway_iteration(ASSETCHAINS_SYMBOL);
fShutdown = ShutdownRequested();
}
if (threadGroup)
@@ -53,7 +57,7 @@ void WaitForShutdown(boost::thread_group* threadGroup)
//
// Start
//
extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY;
extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,ASSETCHAIN_INIT;
extern std::string NOTARY_PUBKEY;
bool AppInit(int argc, char* argv[])
@@ -92,6 +96,13 @@ bool AppInit(int argc, char* argv[])
try
{
void komodo_args();
fprintf(stderr,"call komodo_args\n");
komodo_args();
while ( ASSETCHAIN_INIT == 0 )
{
sleep(1);
}
if (!boost::filesystem::is_directory(GetDataDir(false)))
{
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str());
@@ -109,12 +120,7 @@ bool AppInit(int argc, char* argv[])
fprintf(stderr, "Error: Invalid combination of -regtest and -testnet.\n");
return false;
}
IS_KOMODO_NOTARY = GetBoolArg("-notary", false);
NOTARY_PUBKEY = GetArg("-pubkey", "");
if ( strlen(NOTARY_PUBKEY.c_str()) == 66 )
USE_EXTERNAL_PUBKEY = 1;
fprintf(stderr,"IS_KOMODO_NOTARY %d %s\n",IS_KOMODO_NOTARY,NOTARY_PUBKEY.c_str());
// Command-line RPC
bool fCommandLine = false;
for (int i = 1; i < argc; i++)

View File

@@ -29,12 +29,19 @@ using namespace std;
* timestamp before)
* + Contains no strange transactions
*/
void *chainparams_commandline(void *ptr);
extern char ASSETCHAINS_SYMBOL[16];
extern uint16_t ASSETCHAINS_PORT;
extern uint32_t ASSETCHAIN_INIT;
extern uint32_t ASSETCHAINS_MAGIC;
extern uint64_t ASSETCHAINS_SUPPLY;
const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
class CMainParams : public CChainParams {
public:
CMainParams() {
CMainParams()
{
strNetworkID = "main";
consensus.fCoinbaseMustBeProtected = false;//true;
consensus.nSubsidySlowStartInterval = 20000;
@@ -43,8 +50,6 @@ public:
consensus.nMajorityRejectBlockOutdated = 950;
consensus.nMajorityWindow = 4000;
consensus.powLimit = uint256S("0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
//consensus.powLimit = uint256S("0007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.nPowAveragingWindow = 17;
assert(maxUint/UintToArith256(consensus.powLimit) >= consensus.nPowAveragingWindow);
consensus.nPowMaxAdjustDown = 32; // 32% adjustment down
@@ -62,7 +67,6 @@ public:
pchMessageStart[3] = 0x8d;
vAlertPubKey = ParseHex("020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9");
nDefaultPort = 7770;
nMinerThreads = 0;
nMaxTipAge = 24 * 60 * 60;
nPruneAfterHeight = 100000;
@@ -70,46 +74,27 @@ public:
BOOST_STATIC_ASSERT(equihash_parameters_acceptable(N, K));
nEquihashN = N;
nEquihashK = K;
/**
* Build the genesis block. Note that the output of its generation
* transaction cannot be spent since it did not originally exist in the
* database (and is in any case of zero value).
* CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
* CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
* CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
* CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
* vMerkleTree: 4a5e1e
*/
const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
CMutableTransaction txNew;
txNew.vin.resize(1);
txNew.vout.resize(1);
txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
txNew.vout[0].nValue = 50 * COIN;
/*txNew.vin[0].scriptSig = CScript() << 520617983 << CScriptNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
txNew.vout[0].nValue = 0;*/
txNew.vout[0].scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
genesis.vtx.push_back(txNew);
genesis.hashPrevBlock.SetNull();
genesis.hashMerkleRoot = genesis.BuildMerkleTree();
genesis.nVersion = 1;
genesis.nTime = 1231006505;
// TODO generate harder genesis block
//genesis.nBits = 0x1d00ffff;
genesis.nBits = KOMODO_MINDIFF_NBITS;
genesis.nNonce = uint256S("0x000000000000000000000000000000000000000000000000000000000000000b");
genesis.nSolution = ParseHex("000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2");
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71"));
assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
vFixedSeeds.clear();
vSeeds.clear();
// TODO: set up bootstrapping for mainnet
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,60);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,85);
@@ -121,21 +106,6 @@ public:
// guarantees the first two characters, when base58 encoded, are "SK"
base58Prefixes[ZCSPENDING_KEY] = {171,54};
/*
// guarantees the first 2 characters, when base58 encoded, are "t1"
base58Prefixes[PUBKEY_ADDRESS] = {0x1C,0xB8};
// guarantees the first 2 characters, when base58 encoded, are "t3"
base58Prefixes[SCRIPT_ADDRESS] = {0x1C,0xBD};
// the first character, when base58 encoded, is "5" or "K" or "L" (as in Bitcoin)
base58Prefixes[SECRET_KEY] = {0x80};
// do not rely on these BIP32 prefixes; they are not specified and may change
base58Prefixes[EXT_PUBLIC_KEY] = {0x04,0x88,0xB2,0x1E};
base58Prefixes[EXT_SECRET_KEY] = {0x04,0x88,0xAD,0xE4};
// guarantees the first 2 characters, when base58 encoded, are "zc"
base58Prefixes[ZCPAYMENT_ADDRRESS] = {0x16,0x9A};
// guarantees the first 2 characters, when base58 encoded, are "SK"
base58Prefixes[ZCSPENDING_KEY] = {0xAB,0x36};*/
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
fRequireRPCPassword = true;
@@ -144,8 +114,8 @@ public:
fRequireStandard = true;
fMineBlocksOnDemand = false;
fTestnetToBeDeprecatedFieldRPC = false;
checkpointData = (Checkpoints::CCheckpointData) {
checkpointData = (Checkpoints::CCheckpointData)
{
boost::assign::map_list_of
( 0, consensus.hashGenesisBlock),
genesis.nTime, // * UNIX timestamp of last checkpoint block
@@ -153,10 +123,34 @@ public:
// (the tx=... number in the SetBestChain debug.log lines)
0 // * estimated number of transactions per day after checkpoint
};
if ( pthread_create((pthread_t *)malloc(sizeof(pthread_t)),NULL,chainparams_commandline,(void *)&consensus) != 0 )
{
}
}
};
static CMainParams mainParams;
void *chainparams_commandline(void *ptr)
{
while ( ASSETCHAINS_PORT == 0 )
{
sleep(1);
}
fprintf(stderr,">>>>>>>> port.%u\n",ASSETCHAINS_PORT);
if ( ASSETCHAINS_SYMBOL[0] != 0 )
{
mainParams.SetDefaultPort(ASSETCHAINS_PORT);
mainParams.pchMessageStart[0] = ASSETCHAINS_MAGIC & 0xff;
mainParams.pchMessageStart[1] = (ASSETCHAINS_MAGIC >> 8) & 0xff;
mainParams.pchMessageStart[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff;
mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff;
fprintf(stderr,">>>>>>>>>> %s: port.%u/%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT,ASSETCHAINS_PORT+1,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY);
}
ASSETCHAIN_INIT = 1;
return(0);
}
/**
* Testnet (v3)
*/
@@ -215,23 +209,6 @@ public:
0,
0
};
// Founders reward script expects a vector of 2-of-3 multisig addresses
vFoundersRewardAddress = {
"t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi", "t2N9PH9Wk9xjqYg9iin1Ua3aekJqfAtE543", "t2NGQjYMQhFndDHguvUw4wZdNdsssA6K7x2", "t27ktmq1kbeCWiQ5TZ7w5npSzcdbBmTB7v6",
"t2GcBttAKD2WTHka8HyGc2dfvVTKYZUfHmJ", "t2Q3vxWaD9LrdqUE8Xd9Ddjpr9pUQ2aGotK", "t2TTfWDsYu998fHWzVP9Gns4fgxXXRi1Wzu", "t2KS6R4MMWdSBMjLCiw2iMyhWGRQPmyRqDn",
"t2Q2ELrgotWv3Eec6LEtMMiiQ8dtW38u8Tj", "t2AEgJA88vTWAKqxJDFUEJWyHUtQAZi5G1D", "t2HCSdmpq1TQKksuwPQevwAzPTgfJ2rkMbG", "t2HQCPFAUQaUdJWHPhg5pPBxit7inaJzubE",
"t2Fzqvq8Y9e6Mn3JNPb982aYsLmq4b5HmhH", "t2HEz7YZQqDUgC5h4y2WSD3mWneqJNVRjjJ", "t2GCR1SCk687Eeo5NEZ23MLsms7JjVWBgfG", "t2KyiPR9Lztq2w1w747X6W4nkUMAGL8M9KN",
"t2UxymadyxSyVihmbq7S1yxw5dCBqJ1S4jT", "t2AVeMy7fdmTcJhckqiKRG8B7F1vccEhSqU", "t26m7LwihQzD2sH7ZVhYpPJM5j7kzwbfKW9", "t2DgwUNTe7NxuyPU6fxsB5xJXap3E4yWXrN",
"t2U6funcXA11fC9SZehyvUL3rk3Vhuh7fzS", "t284JhyS8LGM72Tx1porSqwrcq3CejthP1p", "t29egu8QcpzKeLoPLqWS6QVMnUUPQdF6eNm", "t29LqD9p9D3B26euBwFi6mfcWu8HPA38VNs",
"t28GsAMCxAyLy85XaasddDzaYFTtfewr86y", "t2GV44QyaikQPLUfm6oTfZnw71LLjnR7gDG", "t2U2QzNLQ1jtAu4L6xxVnRXLBsQpQvGRR2g", "t2QKGr5PNan7nrwDgseyHMN9NFeeuUjCh8b",
"t2AfS8u6HwBeJpKpbuxztvRjupKQDXqnrwa", "t2CTRQUViQd3CWMhnKhFnUHqDLUyTxmWhJs", "t2CbM9EqszNURqh1UXZBXYhwp1R4GwEhWRE", "t2LM7uYiAsKDU42GNSnMwDxbZ8s1DowQzYH",
"t2AgvT35LHR378AE3ouz6xKMhkTLHLJC6nD", "t285EAQXUVyi4NMddJv2QqTrnv45GRMbP8e", "t2EpMRCD5b8f2DCQ37npNULcpZhkjC8muqA", "t2BCmWXrRPiCeQTpizSWKKRPM5X6PS7umDY",
"t2DN7X6wDFn5hYKBiBmn3Z98st419yaTVTH", "t2QJj8HeCwQ6mHwqekxxDLZntYpZTHNU62t", "t2QdHBR1Yciqn4j8gpS8DcQZZtYetKvfNj3", "t2E5cpLA1ey5VNxFNcuopeQMq2rH2NHiPdu",
"t2EVRGtzjFAyz8CF8ndvLuiJu7qZUfDa93H", "t2KoQDk3BSFadBkuaWdLwchFuQamzw9RE4L", "t2FnR3yhTmuiejEJeu6qpidWTghRd1HpjLt", "t2BAuBAAospDc9d1u5nNGEi6x4NRJBD2PQ2",
"t2RtKrLCGcyPkm4a4APg1YY9Wu2m4R2PgrB", "t28aUbSteZzBq2pFgj1K1XNZRZP5mMMyakV", "t2Urdy1ERfkvsFuy6Z4BkhvYGzWdmivfAFR", "t2ADinR4JrvCMd4Q1XGALPajzFrirqvhED6",
};
assert(vFoundersRewardAddress.size() <= consensus.GetLastFoundersRewardBlockHeight());
}
};
static CTestNetParams testNetParams;

View File

@@ -85,14 +85,20 @@ public:
std::string GetFoundersRewardAddressAtIndex(int i) const;
/** Enforce coinbase consensus rule in regtest mode */
void SetRegTestCoinbaseMustBeProtected() { consensus.fCoinbaseMustBeProtected = true; }
void SetDefaultPort(uint16_t port) { nDefaultPort = port; }
//void setnonce(uint32_t nonce) { memcpy(&genesis.nNonce,&nonce,sizeof(nonce)); }
//void settimestamp(uint32_t timestamp) { genesis.nTime = timestamp; }
//void setgenesis(CBlock &block) { genesis = block; }
//void recalc_genesis(uint32_t nonce) { genesis = CreateGenesisBlock(ASSETCHAINS_TIMESTAMP, nonce, GENESIS_NBITS, 1, COIN); };
int nDefaultPort = 0;
CMessageHeader::MessageStartChars pchMessageStart; // jl777 moved
protected:
CChainParams() {}
Consensus::Params consensus;
Consensus::Params consensus;
CMessageHeader::MessageStartChars pchMessageStart;
//! Raw pub key bytes for the broadcast alert signing key.
//! Raw pub key bytes for the broadcast alert signing key.
std::vector<unsigned char> vAlertPubKey;
int nDefaultPort = 0;
int nMinerThreads = 0;
long nMaxTipAge = 0;
uint64_t nPruneAfterHeight = 0;

View File

@@ -66,6 +66,8 @@ static CBaseChainParams* pCurrentBaseParams = 0;
const CBaseChainParams& BaseParams()
{
if ( pCurrentBaseParams == 0 )
pCurrentBaseParams = &mainParams;
assert(pCurrentBaseParams);
return *pCurrentBaseParams;
}

32
src/clearassets Executable file
View File

@@ -0,0 +1,32 @@
rm -rf ~/.komodo/USD
rm -rf ~/.komodo/EUR
rm -rf ~/.komodo/JPY
rm -rf ~/.komodo/GBP
rm -rf ~/.komodo/AUD
rm -rf ~/.komodo/CAD
rm -rf ~/.komodo/CHF
rm -rf ~/.komodo/NZD
rm -rf ~/.komodo/CNY
rm -rf ~/.komodo/RUB
rm -rf ~/.komodo/MXN
rm -rf ~/.komodo/BRL
rm -rf ~/.komodo/INR
rm -rf ~/.komodo/HKD
rm -rf ~/.komodo/TRY
rm -rf ~/.komodo/ZAR
rm -rf ~/.komodo/PLN
rm -rf ~/.komodo/NOK
rm -rf ~/.komodo/SEK
rm -rf ~/.komodo/DKK
rm -rf ~/.komodo/CZK
rm -rf ~/.komodo/HUF
rm -rf ~/.komodo/ILS
rm -rf ~/.komodo/KRW
rm -rf ~/.komodo/MYR
rm -rf ~/.komodo/PHP
rm -rf ~/.komodo/RON
rm -rf ~/.komodo/SGD
rm -rf ~/.komodo/THB
rm -rf ~/.komodo/BGN
rm -rf ~/.komodo/IDR
rm -rf ~/.komodo/HRK

View File

@@ -17,7 +17,7 @@ static const unsigned int MAX_BLOCK_SIGOPS = 20000;
/** The maximum size of a transaction (network rule) */
static const unsigned int MAX_TX_SIZE = 100000;
/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
static const int COINBASE_MATURITY = 100;
extern int COINBASE_MATURITY;
/** Flags for LockTime() */
enum {

32
src/fiat-cli Executable file
View File

@@ -0,0 +1,32 @@
echo aud; fiat/aud $1 $2 $3 $4
echo bgn; fiat/bgn $1 $2 $3 $4
echo cad; fiat/cad $1 $2 $3 $4
echo chf; fiat/chf $1 $2 $3 $4
echo cny; fiat/cny $1 $2 $3 $4
echo czk; fiat/czk $1 $2 $3 $4
echo dkk; fiat/dkk $1 $2 $3 $4
echo eur; fiat/eur $1 $2 $3 $4
echo gbp; fiat/gbp $1 $2 $3 $4
echo hkd; fiat/hkd $1 $2 $3 $4
echo hrk; fiat/hrk $1 $2 $3 $4
echo huf; fiat/huf $1 $2 $3 $4
echo idr; fiat/idr $1 $2 $3 $4
echo ils; fiat/ils $1 $2 $3 $4
echo inr; fiat/inr $1 $2 $3 $4
echo jpy; fiat/jpy $1 $2 $3 $4
echo krw; fiat/krw $1 $2 $3 $4
echo mxn; fiat/mxn $1 $2 $3 $4
echo myr; fiat/myr $1 $2 $3 $4
echo nok; fiat/nok $1 $2 $3 $4
echo nzd; fiat/nzd $1 $2 $3 $4
echo php; fiat/php $1 $2 $3 $4
echo pln; fiat/pln $1 $2 $3 $4
echo brl; fiat/brl $1 $2 $3 $4
echo ron; fiat/ron $1 $2 $3 $4
echo rub; fiat/rub $1 $2 $3 $4
echo sek; fiat/sek $1 $2 $3 $4
echo sgd; fiat/sgd $1 $2 $3 $4
echo thb; fiat/thb $1 $2 $3 $4
echo try; fiat/try $1 $2 $3 $4
echo usd; fiat/usd $1 $2 $3 $4
echo zar; fiat/zar $1 $2 $3 $4

1
src/fiat/aud Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=AUD $1 $2 $3 $4

1
src/fiat/bgn Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=BGN $1 $2 $3 $4

1
src/fiat/brl Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=BRL $1 $2 $3 $4

1
src/fiat/cad Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=CAD $1 $2 $3 $4

1
src/fiat/chf Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=CHF $1 $2 $3 $4

1
src/fiat/cny Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=CNY $1 $2 $3 $4

1
src/fiat/czk Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=CZK $1 $2 $3 $4

1
src/fiat/dkk Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=DKK $1 $2 $3 $4

1
src/fiat/eur Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=EUR $1 $2 $3 $4

1
src/fiat/gbp Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=GBP $1 $2 $3 $4

1
src/fiat/hkd Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=HKD $1 $2 $3 $4

1
src/fiat/hrk Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=HRK $1 $2 $3 $4

1
src/fiat/huf Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=HUF $1 $2 $3 $4

1
src/fiat/idr Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=IDR $1 $2 $3 $4

1
src/fiat/ils Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=ILS $1 $2 $3 $4

1
src/fiat/inr Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=INR $1 $2 $3 $4

1
src/fiat/jpy Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=JPY $1 $2 $3 $4

1
src/fiat/krw Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=KRW $1 $2 $3 $4

1
src/fiat/mxn Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=MXN $1 $2 $3 $4

1
src/fiat/myr Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=MYR $1 $2 $3 $4

1
src/fiat/nok Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=NOK $1 $2 $3 $4

1
src/fiat/nzd Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=NZD $1 $2 $3 $4

1
src/fiat/php Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=PHP $1 $2 $3 $4

1
src/fiat/pln Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=PLN $1 $2 $3 $4

1
src/fiat/ron Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=RON $1 $2 $3 $4

1
src/fiat/rub Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=RUB $1 $2 $3 $4

1
src/fiat/sek Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=SEK $1 $2 $3 $4

1
src/fiat/sgd Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=SGD $1 $2 $3 $4

1
src/fiat/thb Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=THB $1 $2 $3 $4

1
src/fiat/try Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=TRY $1 $2 $3 $4

1
src/fiat/usd Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=USD $1 $2 $3 $4

1
src/fiat/zar Executable file
View File

@@ -0,0 +1 @@
./komodo-cli -ac_name=ZAR $1 $2 $3 $4

View File

@@ -1493,7 +1493,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
#ifdef ENABLE_WALLET
// Generate coins in the background
if (pwalletMain)
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 1));
GenerateBitcoins(GetBoolArg("-gen", true), pwalletMain, GetArg("-genproclimit", 1));
#endif
// ********************************************************* Step 11: finished

View File

@@ -23,6 +23,10 @@
using namespace std;
#include "uint256.h"
#include "arith_uint256.h"
#include "komodo_globals.h"
#include "komodo_interest.h"
static bool fCreateBlank;

View File

@@ -28,13 +28,8 @@ void komodo_init();
int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp);
char *komodo_issuemethod(char *method,char *params,uint16_t port);
int32_t ASSETCHAINS_SHORTFLAG,NOTARIZED_HEIGHT,Num_nutxos,KMDHEIGHT = 43000;
uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID;
pthread_mutex_t komodo_mutex;
uint32_t KOMODO_INITDONE;
char KMDUSERPASS[1024]; uint16_t BITCOIND_PORT = 7771;
uint64_t KOMODO_DEPOSIT,PENDING_KOMODO_TX;
#define GENESIS_NBITS 0x1f00ffff
#include "komodo_globals.h"
#include "komodo_utils.h"
queue_t DepositsQ,PendingsQ;

34
src/komodo_globals.h Normal file
View File

@@ -0,0 +1,34 @@
/******************************************************************************
* Copyright © 2014-2016 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. *
* *
******************************************************************************/
int COINBASE_MATURITY = 100;
int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY;
std::string NOTARY_PUBKEY;
uint8_t NOTARY_PUBKEY33[33];
int32_t ASSETCHAINS_SHORTFLAG;
char ASSETCHAINS_SYMBOL[16];
uint16_t ASSETCHAINS_PORT;
uint32_t ASSETCHAIN_INIT;
uint32_t ASSETCHAINS_MAGIC = 2387029918;
uint64_t ASSETCHAINS_SUPPLY = 10;
int32_t NOTARIZED_HEIGHT,Num_nutxos,KMDHEIGHT = 43000;
uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID;
pthread_mutex_t komodo_mutex;
uint32_t KOMODO_INITDONE;
char KMDUSERPASS[1024]; uint16_t BITCOIND_PORT = 7771;
uint64_t KOMODO_DEPOSIT,PENDING_KOMODO_TX;

View File

@@ -112,9 +112,12 @@ void komodo_notarysinit(int32_t height,uint8_t pubkeys[64][33],int32_t num)
memcpy(kp->pubkey,pubkeys[k],33);
kp->notaryid = k;
HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp);
for (i=0; i<33; i++)
printf("%02x",pubkeys[k][i]);
printf(" notarypubs.[%d]\n",k);
if ( height > 10000 )
{
for (i=0; i<33; i++)
printf("%02x",pubkeys[k][i]);
printf(" notarypubs.[%d]\n",k);
}
}
N.numnotaries = num;
htind = KOMODO_PUBKEYS_HEIGHT(height) / KOMODO_ELECTION_GAP;

View File

@@ -18,9 +18,7 @@ int32_t NUM_PRICES; uint32_t *PVALS;
#define USD 0
#define MAX_CURRENCIES 32
char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", // major currencies
"CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK",
"KMD" };
extern char CURRENCIES[][8];
uint64_t M1SUPPLY[] = { 3317900000000, 6991604000000, 667780000000000, 1616854000000, 331000000000, 861909000000, 584629000000, 46530000000, // major currencies
45434000000000, 16827000000000, 3473357229000, 306435000000, 27139000000000, 2150641000000, 347724099000, 1469583000000, 749543000000, 1826110000000, 2400434000000, 1123925000000, 3125276000000, 13975000000000, 317657000000, 759706000000000, 354902000000, 2797061000000, 162189000000, 163745000000, 1712000000000, 39093000000, 1135490000000000, 80317000000,
@@ -233,19 +231,6 @@ void komodo_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals)
}
}
int32_t komodo_baseid(char *origbase)
{
int32_t i; char base[64];
for (i=0; origbase[i]!=0&&i<sizeof(base); i++)
base[i] = toupper((int32_t)(origbase[i] & 0xff));
base[i] = 0;
for (i=0; i<=MAX_CURRENCIES; i++)
if ( strcmp(CURRENCIES[i],base) == 0 )
return(i);
printf("illegal base.(%s) %s\n",origbase,base);
return(-1);
}
uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t basevolume)
{
uint32_t pvalb,pvalr,kmdbtc,btcusd; uint64_t usdvol,baseusd,usdkmd,baserel,ranked[32];

View File

@@ -782,6 +782,24 @@ char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,
return(coinaddr);
}
#define MAX_CURRENCIES 32
char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", // major currencies
"CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK",
"KMD" };
int32_t komodo_baseid(char *origbase)
{
int32_t i; char base[64];
for (i=0; origbase[i]!=0&&i<sizeof(base); i++)
base[i] = toupper((int32_t)(origbase[i] & 0xff));
base[i] = 0;
for (i=0; i<=MAX_CURRENCIES; i++)
if ( strcmp(CURRENCIES[i],base) == 0 )
return(i);
printf("illegal base.(%s) %s\n",origbase,base);
return(-1);
}
int32_t _unhex(char c)
{
if ( c >= '0' && c <= '9' )
@@ -1086,89 +1104,6 @@ void OS_randombytes(unsigned char *x,long xlen)
}
}
void komodo_userpass(char *username,char *password,FILE *fp)
{
char *rpcuser,*rpcpassword,*str,line[8192];
rpcuser = rpcpassword = 0;
username[0] = password[0] = 0;
while ( fgets(line,sizeof(line),fp) != 0 )
{
if ( line[0] == '#' )
continue;
//printf("line.(%s) %p %p\n",line,strstr(line,(char *)"rpcuser"),strstr(line,(char *)"rpcpassword"));
if ( (str= strstr(line,(char *)"rpcuser")) != 0 )
rpcuser = parse_conf_line(str,(char *)"rpcuser");
else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 )
rpcpassword = parse_conf_line(str,(char *)"rpcpassword");
}
if ( rpcuser != 0 && rpcpassword != 0 )
{
strcpy(username,rpcuser);
strcpy(password,rpcpassword);
}
//printf("rpcuser.(%s) rpcpassword.(%s) KMDUSERPASS.(%s) %u\n",rpcuser,rpcpassword,KMDUSERPASS,port);
if ( rpcuser != 0 )
free(rpcuser);
if ( rpcpassword != 0 )
free(rpcpassword);
}
void komodo_configfile(char *symbol,uint16_t port)
{
static char myusername[512],mypassword[8192];
FILE *fp; uint8_t buf2[512]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i;
r = (uint32_t)time(NULL);
r2 = OS_milliseconds();
memcpy(buf,&r,sizeof(r));
memcpy(&buf[sizeof(r)],&r2,sizeof(r2));
memcpy(&buf[sizeof(r)+sizeof(r2)],symbol,strlen(symbol));
crc = calc_crc32(0,(uint8_t *)buf,(int32_t)(sizeof(r)+sizeof(r2)+strlen(symbol)));
OS_randombytes(buf2,sizeof(buf2));
for (i=0; i<sizeof(buf2); i++)
sprintf(&password[i*2],"%02x",buf2[i]);
password[i*2] = 0;
sprintf(buf,"%s.conf",symbol);
BITCOIND_PORT = port;
#ifdef WIN32
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),buf);
#else
sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),buf);
#endif
if ( (fp= fopen(fname,"rb")) == 0 )
{
if ( (fp= fopen(fname,"wb")) != 0 )
{
fprintf(fp,"rpcuser=user%u\nrpcpassword=pass%s\nrpcport=%u\nserver=1\ntxindex=1\nbind=127.0.0.1\n",crc,password,port);
fclose(fp);
printf("Created (%s)\n",fname);
} else printf("Couldnt create (%s)\n",fname);
}
else
{
komodo_userpass(myusername,mypassword,fp);
mapArgs["-rpcpassword"] = mypassword;
mapArgs["-rpcusername"] = myusername;
fclose(fp);
}
strcpy(fname,GetDataDir(false).string().c_str());
#ifdef WIN32
while ( fname[strlen(fname)-1] != '\\' )
fname[strlen(fname)-1] = 0;
strcat(fname,".komodo/komodo.conf");
#else
while ( fname[strlen(fname)-1] != '/' )
fname[strlen(fname)-1] = 0;
strcat(fname,".komodo/komodo.conf");
#endif
printf("KOMODO.(%s)\n",fname);
if ( (fp= fopen(fname,"rb")) != 0 )
{
komodo_userpass(username,password,fp);
sprintf(KMDUSERPASS,"%s:%s",username,password);
fclose(fp);
} else printf("couldnt open.(%s)\n",fname);
}
void lock_queue(queue_t *queue)
{
if ( queue->initflag == 0 )
@@ -1282,3 +1217,134 @@ void iguana_initQ(queue_t *Q,char *name)
if ( (item= queue_dequeue(Q)) != 0 )
free(item);
}
void komodo_userpass(char *username,char *password,FILE *fp)
{
char *rpcuser,*rpcpassword,*str,line[8192];
rpcuser = rpcpassword = 0;
username[0] = password[0] = 0;
while ( fgets(line,sizeof(line),fp) != 0 )
{
if ( line[0] == '#' )
continue;
//printf("line.(%s) %p %p\n",line,strstr(line,(char *)"rpcuser"),strstr(line,(char *)"rpcpassword"));
if ( (str= strstr(line,(char *)"rpcuser")) != 0 )
rpcuser = parse_conf_line(str,(char *)"rpcuser");
else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 )
rpcpassword = parse_conf_line(str,(char *)"rpcpassword");
}
if ( rpcuser != 0 && rpcpassword != 0 )
{
strcpy(username,rpcuser);
strcpy(password,rpcpassword);
}
//printf("rpcuser.(%s) rpcpassword.(%s) KMDUSERPASS.(%s) %u\n",rpcuser,rpcpassword,KMDUSERPASS,port);
if ( rpcuser != 0 )
free(rpcuser);
if ( rpcpassword != 0 )
free(rpcpassword);
}
void komodo_configfile(char *symbol,uint16_t port)
{
static char myusername[512],mypassword[8192];
FILE *fp; uint8_t buf2[33]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i;
r = (uint32_t)time(NULL);
r2 = OS_milliseconds();
memcpy(buf,&r,sizeof(r));
memcpy(&buf[sizeof(r)],&r2,sizeof(r2));
memcpy(&buf[sizeof(r)+sizeof(r2)],symbol,strlen(symbol));
crc = calc_crc32(0,(uint8_t *)buf,(int32_t)(sizeof(r)+sizeof(r2)+strlen(symbol)));
OS_randombytes(buf2,sizeof(buf2));
for (i=0; i<sizeof(buf2); i++)
sprintf(&password[i*2],"%02x",buf2[i]);
password[i*2] = 0;
sprintf(buf,"%s.conf",symbol);
BITCOIND_PORT = port;
#ifdef WIN32
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),buf);
#else
sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),buf);
#endif
if ( (fp= fopen(fname,"rb")) == 0 )
{
if ( (fp= fopen(fname,"wb")) != 0 )
{
fprintf(fp,"rpcuser=user%u\nrpcpassword=pass%s\nrpcport=%u\nserver=1\ntxindex=1\n\n",crc,password,port);
fclose(fp);
printf("Created (%s)\n",fname);
} else printf("Couldnt create (%s)\n",fname);
}
else
{
komodo_userpass(myusername,mypassword,fp);
mapArgs["-rpcpassword"] = mypassword;
mapArgs["-rpcusername"] = myusername;
//fprintf(stderr,"myusername.(%s)\n",myusername);
fclose(fp);
}
strcpy(fname,GetDataDir().string().c_str());
#ifdef WIN32
while ( fname[strlen(fname)-1] != '\\' )
fname[strlen(fname)-1] = 0;
strcat(fname,"komodo.conf");
#else
while ( fname[strlen(fname)-1] != '/' )
fname[strlen(fname)-1] = 0;
strcat(fname,"komodo.conf");
#endif
//printf("KOMODO.(%s)\n",fname);
if ( (fp= fopen(fname,"rb")) != 0 )
{
komodo_userpass(username,password,fp);
sprintf(KMDUSERPASS,"%s:%s",username,password);
fclose(fp);
} else printf("couldnt open.(%s)\n",fname);
}
void komodo_args()
{
std::string name; char *dirname; uint8_t buf[512]; int32_t i,len;
IS_KOMODO_NOTARY = GetBoolArg("-notary", false);
NOTARY_PUBKEY = GetArg("-pubkey", "");
if ( strlen(NOTARY_PUBKEY.c_str()) == 66 )
USE_EXTERNAL_PUBKEY = 1;
name = GetArg("-ac_name","");
if ( name.c_str()[0] != 0 )
{
ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10);
strncpy(ASSETCHAINS_SYMBOL,name.c_str(),sizeof(ASSETCHAINS_SYMBOL)-1);
len = iguana_rwnum(1,&buf[len],sizeof(ASSETCHAINS_SUPPLY),(void *)&ASSETCHAINS_SUPPLY);
strcpy((char *)&buf[len],ASSETCHAINS_SYMBOL);
len += strlen(ASSETCHAINS_SYMBOL);
ASSETCHAINS_MAGIC = calc_crc32(0,buf,len);
ASSETCHAINS_PORT = GetArg("-ac_port",8000 + (ASSETCHAINS_MAGIC % 7777));
if ( ASSETCHAINS_SYMBOL[0] == '-' )
{
ASSETCHAINS_SHORTFLAG = 1;
for (i=0; ASSETCHAINS_SYMBOL[i+1]!=0; i++)
ASSETCHAINS_SYMBOL[i] = ASSETCHAINS_SYMBOL[i+1];
}
//fprintf(stderr,"after args: %c%s port.%u magic.%08x supply.%u\n",ASSETCHAINS_SHORTFLAG!=0?'-':'+',ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT,ASSETCHAINS_MAGIC,(int32_t)ASSETCHAINS_SUPPLY);
while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 )
{
fprintf(stderr,"waiting for datadir\n");
sleep(3);
}
//fprintf(stderr,"Got datadir.(%s)\n",dirname);
if ( ASSETCHAINS_SYMBOL[0] != 0 )
{
int32_t komodo_baseid(char *origbase);
extern int COINBASE_MATURITY;
komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1);
if ( komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 )
COINBASE_MATURITY = 1;
}
}
else
{
ASSETCHAINS_PORT = 8777;
fprintf(stderr,"IS_KOMODO_NOTARY %d %s\n",IS_KOMODO_NOTARY,NOTARY_PUBKEY.c_str());
}
//fprintf(stderr,"%s chain params initialized\n",ASSETCHAINS_SYMBOL);
}

View File

@@ -549,9 +549,6 @@ CCoinsViewCache *pcoinsTip = NULL;
CBlockTreeDB *pblocktree = NULL;
// Komodo globals
int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY;
std::string NOTARY_PUBKEY;
uint8_t NOTARY_PUBKEY33[33];
#define KOMODO_TESTNET_EXPIRATION 60000
//#define KOMODO_ENABLE_INTEREST enabling this is a hardfork
@@ -1421,15 +1418,27 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex)
}
uint64_t komodo_moneysupply(int32_t height);
extern char ASSETCHAINS_SYMBOL[16];
extern uint32_t ASSETCHAINS_MAGIC;
extern uint64_t ASSETCHAINS_SUPPLY;
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
CAmount nSubsidy = 3 * COIN;
if ( nHeight == 1 )
return(100000000 * COIN); // ICO allocation
else if ( komodo_moneysupply(nHeight) < MAX_MONEY )
return(3 * COIN);
else return(0);
if ( ASSETCHAINS_SYMBOL[0] == 0 )
{
if ( nHeight == 1 )
return(100000000 * COIN); // ICO allocation
else if ( komodo_moneysupply(nHeight) < MAX_MONEY )
return(3 * COIN);
else return(0);
}
else
{
if ( nHeight == 1 )
return(ASSETCHAINS_SUPPLY * COIN + (ASSETCHAINS_MAGIC & 0xffffff));
else return(10000);
}
/*
// Mining slow start
// The subsidy is ramped up linearly, skipping the middle payout of

View File

@@ -99,6 +99,9 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,
}
int32_t komodo_pax_opreturn(uint8_t *opret,int32_t maxsize);
extern int32_t KOMODO_INITDONE;
extern uint64_t KOMODO_DEPOSIT;
extern char ASSETCHAINS_SYMBOL[16];
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
{
@@ -108,6 +111,17 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
if(!pblocktemplate.get())
return NULL;
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
while ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight > 10 && mempool.GetTotalTxSize() <= 0 )
{
sleep(10);
if ( KOMODO_INITDONE == 0 || time(NULL) < KOMODO_INITDONE+60 )
continue;
if ( KOMODO_DEPOSIT != 0 )
{
printf("KOMODO_DEPOSIT %llu pblock->nHeight %d mempool.GetTotalTxSize(%d)\n",(long long)KOMODO_DEPOSIT,(int32_t)chainActive.Tip()->nHeight,(int32_t)mempool.GetTotalTxSize());
break;
}
}
// -regtest only: allow overriding block.nVersion with
// -blockversion=N to test forking scenarios
@@ -410,6 +424,9 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&
//
extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY;
extern std::string NOTARY_PUBKEY;
extern uint8_t NOTARY_PUBKEY33[33];
uint32_t Mining_start,Mining_height;
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33);
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
{
@@ -457,10 +474,6 @@ static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& rese
return true;
}
extern uint8_t NOTARY_PUBKEY33[33];
uint32_t Mining_start;
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33);
void static BitcoinMiner(CWallet *pwallet)
{
LogPrintf("ZcashMiner started\n");
@@ -478,7 +491,7 @@ void static BitcoinMiner(CWallet *pwallet)
std::string solver = GetArg("-equihashsolver", "tromp");
assert(solver == "tromp" || solver == "default");
LogPrint("pow", "Using Equihash solver \"%s\" with n = %u, k = %u\n", solver, n, k);
fprintf(stderr,"Mining with %s\n",solver.c_str());
//fprintf(stderr,"Mining with %s\n",solver.c_str());
std::mutex m_cs;
bool cancelSolver = false;
boost::signals2::connection c = uiInterface.NotifyBlockTip.connect(
@@ -495,7 +508,7 @@ void static BitcoinMiner(CWallet *pwallet)
{
// Busy-wait for the network to come online so we don't waste time mining
// on an obsolete chain. In regtest mode we expect to fly solo.
fprintf(stderr,"Wait for peers...\n");
//fprintf(stderr,"Wait for peers...\n");
do {
bool fvNodesEmpty;
{
@@ -506,7 +519,7 @@ void static BitcoinMiner(CWallet *pwallet)
break;
MilliSleep(1000);
} while (true);
fprintf(stderr,"Found peers\n");
//fprintf(stderr,"Found peers\n");
}
//fprintf(stderr,"create new block\n");
//
@@ -539,31 +552,25 @@ void static BitcoinMiner(CWallet *pwallet)
Mining_start = (uint32_t)time(NULL);
//fprintf(stderr,"I am the chosen one for ht.%d\n",pindexPrev->nHeight+1);
} else Mining_start = 0;
Mining_height = pindexPrev->nHeight+1;
while (true)
{
// Hash state
crypto_generichash_blake2b_state state;
EhInitialiseState(n, k, state);
// I = the block header minus nonce and solution.
CEquihashInput I{*pblock};
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss << I;
// H(I||...
crypto_generichash_blake2b_update(&state, (unsigned char*)&ss[0], ss.size());
// H(I||V||...
crypto_generichash_blake2b_state curr_state;
curr_state = state;
crypto_generichash_blake2b_update(&curr_state,
pblock->nNonce.begin(),
pblock->nNonce.size());
crypto_generichash_blake2b_update(&curr_state,pblock->nNonce.begin(),pblock->nNonce.size());
// (x_1, x_2, ...) = A(I, V, n, k)
LogPrint("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",
solver, pblock->nNonce.ToString());
LogPrint("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",solver, pblock->nNonce.ToString());
std::function<bool(std::vector<unsigned char>)> validBlock =
[&pblock, &hashTarget, &pwallet, &reservekey, &m_cs, &cancelSolver, &chainparams]
@@ -572,35 +579,30 @@ void static BitcoinMiner(CWallet *pwallet)
LogPrint("pow", "- Checking solution against target\n");
pblock->nSolution = soln;
solutionTargetChecks.increment();
if (UintToArith256(pblock->GetHash()) > hashTarget) {
if ( UintToArith256(pblock->GetHash()) > hashTarget )
return false;
}
if ( Mining_start != 0 && time(NULL) < Mining_start+50 )
{
printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+50-time(NULL)));
sleep(Mining_start+50-time(NULL));
}
// Found a solution
SetThreadPriority(THREAD_PRIORITY_NORMAL);
LogPrintf("ZcashMiner:\n");
LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", pblock->GetHash().GetHex(), hashTarget.GetHex());
if (ProcessBlockFound(pblock, *pwallet, reservekey)) {
// Ignore chain updates caused by us
std::lock_guard<std::mutex> lock{m_cs};
cancelSolver = false;
}
fprintf(stderr,"%s Block found %d\n",ASSETCHAINS_SYMBOL,Mining_height);
SetThreadPriority(THREAD_PRIORITY_LOWEST);
// In regression test mode, stop mining after a block is found.
if (chainparams.MineBlocksOnDemand()) {
// Increment here because throwing skips the call below
ehSolverRuns.increment();
throw boost::thread_interrupted();
}
return true;
};
std::function<bool(EhSolverCancelCheck)> cancelled = [&m_cs, &cancelSolver](EhSolverCancelCheck pos) {

View File

@@ -115,6 +115,7 @@ void AddOneShot(string strDest)
unsigned short GetListenPort()
{
//printf("Listenport.%u\n",Params().GetDefaultPort());
return (unsigned short)(GetArg("-port", Params().GetDefaultPort()));
}

View File

@@ -400,6 +400,8 @@ void PrintExceptionContinue(const std::exception* pex, const char* pszThread)
strMiscWarning = message;
}
extern char ASSETCHAINS_SYMBOL[16];
boost::filesystem::path GetDefaultDataDir()
{
namespace fs = boost::filesystem;
@@ -409,7 +411,9 @@ boost::filesystem::path GetDefaultDataDir()
// Unix: ~/.zcash
#ifdef WIN32
// Windows
return GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo";
if ( ASSETCHAINS_SYMBOL[0] == 0 )
return GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo";
else return GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo" / ASSETCHAINS_SYMBOL;
#else
fs::path pathRet;
char* pszHome = getenv("HOME");
@@ -421,10 +425,19 @@ boost::filesystem::path GetDefaultDataDir()
// Mac
pathRet /= "Library/Application Support";
TryCreateDirectory(pathRet);
return pathRet / "Komodo";
if ( ASSETCHAINS_SYMBOL[0] == 0 )
return pathRet / "Komodo";
else
{
pathRet /= "Komodo";
TryCreateDirectory(pathRet);
return pathRet / ASSETCHAINS_SYMBOL;
}
#else
// Unix
return pathRet / ".komodo";
if ( ASSETCHAINS_SYMBOL[0] == 0 )
return pathRet / ".komodo";
else return pathRet / ".komodo" / ASSETCHAINS_SYMBOL;
#endif
#endif
}
@@ -521,7 +534,11 @@ void ClearDatadirCache()
boost::filesystem::path GetConfigFile()
{
boost::filesystem::path pathConfigFile(GetArg("-conf", "komodo.conf"));
char confname[512];
if ( ASSETCHAINS_SYMBOL[0] != 0 )
sprintf(confname,"%s.conf",ASSETCHAINS_SYMBOL);
else strcpy(confname,"komodo.conf");
boost::filesystem::path pathConfigFile(GetArg("-conf",confname));
if (!pathConfigFile.is_complete())
pathConfigFile = GetDataDir(false) / pathConfigFile;

View File

@@ -82,7 +82,8 @@ bool CDBEnv::Open(const boost::filesystem::path& pathIn)
boost::filesystem::path pathLogDir = pathIn / "database";
TryCreateDirectory(pathLogDir);
boost::filesystem::path pathErrorFile = pathIn / "db.log";
LogPrintf("CDBEnv::Open: LogDir=%s ErrorFile=%s\n", pathLogDir.string(), pathErrorFile.string());
LogPrintf("CDBEnv::Open: LogDir=%s ErrorFile=%s pathIn.(%s)\n", pathLogDir.string(), pathErrorFile.string(),pathIn.string());
fprintf(stderr,"strPath.(%s)\n",strPath.c_str());
unsigned int nEnvFlags = 0;
if (GetBoolArg("-privdb", true))

View File

@@ -771,6 +771,11 @@ void CWallet::DecrementNoteWitnesses()
}
// TODO: If nWitnessCache is zero, we need to regenerate the caches (#1302)
assert(nWitnessCacheSize > 0);
if ( nWitnessCacheSize <= 0 )
{
extern char ASSETCHAINS_SYMBOL[16];
fprintf(stderr,"%s nWitnessCacheSize.%d\n",ASSETCHAINS_SYMBOL,(int32_t)nWitnessCacheSize);
}
if (fFileBacked) {
CWalletDB walletdb(strWalletFile);
WriteWitnessCache(walletdb);