Skip to content

Commit

Permalink
BugFix: Make initialfreecoins configurable, default of 0
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimon authored and instagibbs committed May 11, 2018
1 parent 864b122 commit 5e97d95
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions contrib/assets_tutorial/elements1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ validatepegin=1
mainchainrpcport=18888
mainchainrpcuser=user3
mainchainrpcpassword=password3

# Free money to make testing easier
initialfreecoins=2100000000000000
2 changes: 2 additions & 0 deletions contrib/assets_tutorial/elements2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ mainchainrpcport=18888
mainchainrpcuser=user3
mainchainrpcpassword=password3
validatepegin=1

initialfreecoins=2100000000000000
2 changes: 2 additions & 0 deletions qa/rpc-tests/pegging.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def write_bitcoin_conf(datadir, rpcport, rpcpass=None, p2p_port=None, connect_po
f.write("connect=localhost:"+str(sidechain2_p2p_port)+"\n")
f.write("listen=1\n")
f.write("fallbackfee=0.0001\n")
f.write("initialfreecoins=2100000000000000\n")

with open(os.path.join(sidechain2_datadir, "elements.conf"), 'w') as f:
f.write("regtest=1\n")
Expand All @@ -137,6 +138,7 @@ def write_bitcoin_conf(datadir, rpcport, rpcpass=None, p2p_port=None, connect_po
f.write("connect=localhost:"+str(sidechain1_p2p_port)+"\n")
f.write("listen=1\n")
f.write("fallbackfee=0.0001\n")
f.write("initialfreecoins=2100000000000000\n")

def test_pegout(parent_chain_addr, sidechain):
pegout_txid = sidechain.sendtomainchain(parent_chain_addr, 1)
Expand Down
1 change: 1 addition & 0 deletions qa/rpc-tests/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def initialize_datadir(dirname, n):
f.write("port="+str(p2p_port(n))+"\n")
f.write("rpcport="+str(rpc_port(n))+"\n")
f.write("listenonion=0\n")
f.write("initialfreecoins=2100000000000000\n")
return datadir

def rpc_auth_pair(n):
Expand Down
6 changes: 4 additions & 2 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "tinyformat.h"
#include "util.h"
#include "utilstrencodings.h"
#include "amount.h"
#include "crypto/sha256.h"

#include <assert.h>
Expand Down Expand Up @@ -133,6 +132,7 @@ class CCustomParams : public CChainParams {
consensus.mandatory_coinbase_destination = StrHexToScriptWithDefault(GetArg("-con_mandatorycoinbase", ""), CScript()); // Blank script allows any coinbase destination
// bitcoin regtest is the parent chain by default
parentGenesisBlockHash = uint256S(GetArg("-parentgenesisblockhash", "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));
initialFreeCoins = GetArg("-initialfreecoins", 0);

nDefaultPort = GetArg("-ndefaultport", 7042);
nPruneAfterHeight = GetArg("-npruneafterheight", 1000);
Expand Down Expand Up @@ -174,7 +174,9 @@ class CCustomParams : public CChainParams {
CalculateAsset(consensus.pegged_asset, entropy);

genesis = CreateGenesisBlock(consensus, strNetworkID, 1296688602, genesisChallengeScript, 1);
AppendInitialIssuance(genesis, COutPoint(uint256(commit), 0), parentGenesisBlockHash, 100, 21000000000000, 0, 0, CScript() << OP_TRUE);
if (initialFreeCoins != 0) {
AppendInitialIssuance(genesis, COutPoint(uint256(commit), 0), parentGenesisBlockHash, 100, initialFreeCoins/100, 0, 0, CScript() << OP_TRUE);
}
consensus.hashGenesisBlock = genesis.GetHash();


Expand Down
2 changes: 2 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#ifndef BITCOIN_CHAINPARAMS_H
#define BITCOIN_CHAINPARAMS_H

#include "amount.h"
#include "chainparamsbase.h"
#include "consensus/params.h"
#include "primitives/block.h"
Expand Down Expand Up @@ -103,6 +104,7 @@ class CChainParams
std::string strNetworkID;
CBlock genesis;
uint256 parentGenesisBlockHash;
CAmount initialFreeCoins;
std::vector<SeedSpec6> vFixedSeeds;
bool fMiningRequiresPeers;
bool fDefaultConsistencyChecks;
Expand Down
5 changes: 3 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,6 @@ std::string HelpMessage(HelpMessageMode mode)
{
strUsage += HelpMessageOpt("-checkblocks=<n>", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), DEFAULT_CHECKBLOCKS));
strUsage += HelpMessageOpt("-checklevel=<n>", strprintf(_("How thorough the block verification of -checkblocks is (0-4, default: %u)"), DEFAULT_CHECKLEVEL));
strUsage += HelpMessageOpt("-signblockscript=<hex>", _("Change chain to be signed and validated with a different script.") +
" " + _(" This creates a new chain with a different genesis block."));
strUsage += HelpMessageOpt("-checkblockindex", strprintf("Do a full consistency check for mapBlockIndex, setBlockIndexCandidates, chainActive and mapBlocksUnlinked occasionally. Also sets -checkmempool (default: %u)", defaultChainParams->DefaultConsistencyChecks()));
strUsage += HelpMessageOpt("-checkmempool=<n>", strprintf("Run checks every <n> transactions (default: %u)", defaultChainParams->DefaultConsistencyChecks()));
strUsage += HelpMessageOpt("-checkpoints", strprintf("Disable expensive verification for known chain history (default: %u)", DEFAULT_CHECKPOINTS_ENABLED));
Expand Down Expand Up @@ -512,7 +510,10 @@ std::string HelpMessage(HelpMessageMode mode)
if (showDebug) {
strUsage += HelpMessageOpt("-fedpegscript=<hex>", _("Change federated peg to use a different script.") +
" " + _("This creates a new chain with a different genesis block."));
strUsage += HelpMessageOpt("-signblockscript=<hex>", _("Change chain to be signed and validated with a different script.") +
" " + _(" This creates a new chain with a different genesis block."));
strUsage += HelpMessageOpt("-peginconfirmationdepth", strprintf(_("Pegin claims must be this deep to be considered valid. (default: %d)"), DEFAULT_PEGIN_CONFIRMATION_DEPTH));
strUsage += HelpMessageOpt("-initialfreecoins", strprintf(_("The amount of OP_TRUE coins created in the genesis block. Primarily for testing. (default: %d)"), 0));
}
strUsage += HelpMessageOpt("-validatepegin", strprintf(_("Validate pegin claims. All functionaries must run this. (default: %u)"), DEFAULT_VALIDATE_PEGIN));
strUsage += HelpMessageOpt("-mainchainrpchost=<addr>", strprintf("The address which the daemon will try to connect to validate peg-ins, if enabled. (default: cookie auth)"));
Expand Down
2 changes: 2 additions & 0 deletions src/test/test_bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::st
if (!fedpegscript.empty()) {
SoftSetArg("-fedpegscript", fedpegscript);
}
// MAX_MONEY
SoftSetArg("-initialfreecoins", "2100000000000000");
SelectParams(chainName);
noui_connect();
}
Expand Down

0 comments on commit 5e97d95

Please sign in to comment.