Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DEFAULT chain and set to liquidv1 #808

Merged
merged 4 commits into from
Jan 31, 2020
Merged
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
2 changes: 1 addition & 1 deletion src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static void SetupCliArgs()
{
SetupHelpOptions(gArgs);

const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN);
const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::DEFAULT);
const auto testnetBaseParams = CreateBaseChainParams(CBaseChainParams::TESTNET);
const auto regtestBaseParams = CreateBaseChainParams(CBaseChainParams::REGTEST);

Expand Down
2 changes: 2 additions & 0 deletions src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const std::string CBaseChainParams::TESTNET = "test";
const std::string CBaseChainParams::REGTEST = "regtest";
const std::string CBaseChainParams::LIQUID1 = "liquidv1";

const std::string CBaseChainParams::DEFAULT = CBaseChainParams::LIQUID1;

void SetupChainParamsBaseOptions()
{
gArgs.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Reserved values: main, test, regtest", false, OptionsCategory::CHAINPARAMS);
Expand Down
2 changes: 2 additions & 0 deletions src/chainparamsbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class CBaseChainParams
static const std::string REGTEST;
static const std::string LIQUID1;

static const std::string DEFAULT;

const std::string& DataDir() const { return strDataDir; }
int RPCPort() const { return nRPCPort; }
int MainchainRPCPort() const { return nMainchainRPCPort; }
Expand Down
6 changes: 4 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,12 @@ void SetupServerArgs()
SetupHelpOptions(gArgs);
gArgs.AddArg("-help-debug", "Print help message with debugging options and exit", false, OptionsCategory::DEBUG_TEST); // server-only for now

const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN);
const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::DEFAULT);
const auto mainnetBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN);
const auto testnetBaseParams = CreateBaseChainParams(CBaseChainParams::TESTNET);
const auto regtestBaseParams = CreateBaseChainParams(CBaseChainParams::REGTEST);
const auto defaultChainParams = CreateChainParams(CBaseChainParams::MAIN);
const auto defaultChainParams = CreateChainParams(CBaseChainParams::DEFAULT);
const auto mainnetChainParams = CreateChainParams(CBaseChainParams::MAIN);
const auto testnetChainParams = CreateChainParams(CBaseChainParams::TESTNET);
const auto regtestChainParams = CreateChainParams(CBaseChainParams::REGTEST);

Expand Down
12 changes: 9 additions & 3 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,11 @@ fs::path static StartupShortcutPath()
std::string chain = gArgs.GetChainName();
if (chain == CBaseChainParams::MAIN)
return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin.lnk";
if (chain == CBaseChainParams::LIQUID1)
return GetSpecialFolderPath(CSIDL_STARTUP) / "Liquid.lnk";
if (chain == CBaseChainParams::TESTNET) // Remove this special case when CBaseChainParams::TESTNET = "testnet4"
return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin (testnet).lnk";
return GetSpecialFolderPath(CSIDL_STARTUP) / strprintf("Bitcoin (%s).lnk", chain);
return GetSpecialFolderPath(CSIDL_STARTUP) / strprintf("Elements (%s).lnk", chain);
}

bool GetStartOnSystemStartup()
Expand Down Expand Up @@ -630,7 +632,9 @@ fs::path static GetAutostartFilePath()
std::string chain = gArgs.GetChainName();
if (chain == CBaseChainParams::MAIN)
return GetAutostartDir() / "bitcoin.desktop";
return GetAutostartDir() / strprintf("bitcoin-%s.lnk", chain);
if (chain == CBaseChainParams::LIQUID1)
return GetAutostartDir() / "liquid.desktop";
return GetAutostartDir() / strprintf("elements-%s.lnk", chain);
}

bool GetStartOnSystemStartup()
Expand Down Expand Up @@ -675,8 +679,10 @@ bool SetStartOnSystemStartup(bool fAutoStart)
optionFile << "Type=Application\n";
if (chain == CBaseChainParams::MAIN)
optionFile << "Name=Bitcoin\n";
else if (chain == CBaseChainParams::LIQUID1)
optionFile << "Name=Liquid\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the other changes in this PR, I would expect this to be adding LIQUID1, not replacing MAIN. (But I don't really know what I'm looking for.) Is it correct as written here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah sure, that makes sense. Leaving MAIN in place is the goal as it reduces diff. Good catch.

else
optionFile << strprintf("Name=Bitcoin (%s)\n", chain);
optionFile << strprintf("Name=Elements (%s)\n", chain);
optionFile << "Exec=" << pszExePath << strprintf(" -min -chain=%s\n", chain);
optionFile << "Terminal=false\n";
optionFile << "Hidden=false\n";
Expand Down
2 changes: 1 addition & 1 deletion src/test/util_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ BOOST_AUTO_TEST_CASE(util_ReadConfigStream)
test_args.SetNetworkOnlyArg("-ccc");
test_args.SetNetworkOnlyArg("-h");

test_args.SelectConfigNetwork(CBaseChainParams::MAIN);
test_args.SelectConfigNetwork(CBaseChainParams::DEFAULT);
BOOST_CHECK(test_args.GetArg("-d", "xxx") == "e");
BOOST_CHECK(test_args.GetArgs("-ccc").size() == 2);
BOOST_CHECK(test_args.GetArg("-h", "xxx") == "0");
Expand Down
25 changes: 3 additions & 22 deletions src/util/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class ArgsManagerHelper {
* See also comments around ArgsManager::ArgsManager() below. */
static inline bool UseDefaultSection(const ArgsManager& am, const std::string& arg) EXCLUSIVE_LOCKS_REQUIRED(am.cs_args)
{
return (am.m_network == CBaseChainParams::MAIN || am.m_network_only_args.count(arg) == 0);
return (am.m_network == CBaseChainParams::DEFAULT || am.m_network_only_args.count(arg) == 0);
}

/** Convert regular argument into the network-specific setting */
Expand Down Expand Up @@ -336,7 +336,7 @@ const std::set<std::string> ArgsManager::GetUnsuitableSectionOnlyArgs() const
if (m_network.empty()) return std::set<std::string> {};

// if it's okay to use the default section for this network, don't worry
if (m_network == CBaseChainParams::MAIN) return std::set<std::string> {};
if (m_network == CBaseChainParams::DEFAULT) return std::set<std::string> {};

for (const auto& arg : m_network_only_args) {
std::pair<bool, std::string> found_result;
Expand All @@ -359,25 +359,6 @@ const std::set<std::string> ArgsManager::GetUnsuitableSectionOnlyArgs() const
return unsuitables;
}


const std::set<std::string> ArgsManager::GetUnrecognizedSections() const
{
// Section names to be recognized in the config file.
static const std::set<std::string> available_sections{
CBaseChainParams::REGTEST,
CBaseChainParams::TESTNET,
CBaseChainParams::MAIN
};
std::set<std::string> diff;

LOCK(cs_args);
std::set_difference(
m_config_sections.begin(), m_config_sections.end(),
available_sections.begin(), available_sections.end(),
std::inserter(diff, diff.end()));
return diff;
}

void ArgsManager::SelectConfigNetwork(const std::string& network)
{
LOCK(cs_args);
Expand Down Expand Up @@ -1001,7 +982,7 @@ std::string ArgsManager::GetChainName() const
if (fTestNet)
return CBaseChainParams::TESTNET;

std::string default_chain = "liquidv1";
std::string default_chain = CBaseChainParams::DEFAULT;
return GetArg("-chain", default_chain);
}

Expand Down
9 changes: 2 additions & 7 deletions src/util/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,6 @@ class ArgsManager
*/
const std::set<std::string> GetUnsuitableSectionOnlyArgs() const;

/**
* Log warnings for unrecognized section names in the config file.
*/
const std::set<std::string> GetUnrecognizedSections() const;

/**
* Return a vector of strings of the given argument
*
Expand Down Expand Up @@ -251,8 +246,8 @@ class ArgsManager
void ForceSetArg(const std::string& strArg, const std::string& strValue);

/**
* Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
* @return CBaseChainParams::MAIN by default; raises runtime error if an invalid combination is given.
* Returns the chain name based on the parameters.
* @return CBaseChainParams::DEFAULT by default.
*/
std::string GetChainName() const;

Expand Down