Skip to content

Commit

Permalink
Move CopyrightHolders() and LicenseInfo() into libbitcoin_common
Browse files Browse the repository at this point in the history
After bitcoin#26645, this change is
required to be able to `#include clientversion.h` in the
`libbitcoinconsensus` code without dependency on `util/translation.h`.
  • Loading branch information
hebasto committed Dec 12, 2022
1 parent 6061eb6 commit 1b176d1
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 36 deletions.
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ libbitcoin_common_a_SOURCES = \
coins.cpp \
common/bloom.cpp \
common/interfaces.cpp \
common/license.cpp \
common/run_command.cpp \
compressor.cpp \
core_read.cpp \
Expand Down
1 change: 1 addition & 0 deletions src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <chainparamsbase.h>
#include <clientversion.h>
#include <common/license.h>
#include <common/url.h>
#include <compat/compat.h>
#include <compat/stdin.h>
Expand Down
1 change: 1 addition & 0 deletions src/bitcoin-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <clientversion.h>
#include <coins.h>
#include <common/license.h>
#include <compat/compat.h>
#include <consensus/amount.h>
#include <consensus/consensus.h>
Expand Down
1 change: 1 addition & 0 deletions src/bitcoin-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#endif

#include <arith_uint256.h>
#include <common/license.h>
#include <chain.h>
#include <chainparams.h>
#include <chainparamsbase.h>
Expand Down
1 change: 1 addition & 0 deletions src/bitcoin-wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <chainparams.h>
#include <chainparamsbase.h>
#include <clientversion.h>
#include <common/license.h>
#include <common/url.h>
#include <compat/compat.h>
#include <interfaces/init.h>
Expand Down
1 change: 1 addition & 0 deletions src/bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <chainparams.h>
#include <clientversion.h>
#include <common/license.h>
#include <common/url.h>
#include <compat/compat.h>
#include <init.h>
Expand Down
30 changes: 0 additions & 30 deletions src/clientversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <clientversion.h>
#include <util/translation.h>

#include <tinyformat.h>

Expand Down Expand Up @@ -76,32 +75,3 @@ std::string FormatSubVersion(const std::string& name, int nClientVersion, const
ss << "/";
return ss.str();
}

std::string CopyrightHolders(const std::string& strPrefix)
{
const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION);
std::string strCopyrightHolders = strPrefix + copyright_devs;

// Make sure Bitcoin Core copyright is not removed by accident
if (copyright_devs.find("Bitcoin Core") == std::string::npos) {
strCopyrightHolders += "\n" + strPrefix + "The Bitcoin Core developers";
}
return strCopyrightHolders;
}

std::string LicenseInfo()
{
const std::string URL_SOURCE_CODE = "<https://github.com/bitcoin/bitcoin>";

return CopyrightHolders(strprintf(_("Copyright (C) %i-%i").translated, 2009, COPYRIGHT_YEAR) + " ") + "\n" +
"\n" +
strprintf(_("Please contribute if you find %s useful. "
"Visit %s for further information about the software.").translated, PACKAGE_NAME, "<" PACKAGE_URL ">") +
"\n" +
strprintf(_("The source code is available from %s.").translated, URL_SOURCE_CODE) +
"\n" +
"\n" +
_("This is experimental software.").translated + "\n" +
strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s").translated, "COPYING", "<https://opensource.org/licenses/MIT>") +
"\n";
}
5 changes: 0 additions & 5 deletions src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ extern const std::string CLIENT_NAME;
std::string FormatFullVersion();
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments);

std::string CopyrightHolders(const std::string& strPrefix);

/** Returns licensing information (for -version) */
std::string LicenseInfo();

#endif // WINDRES_PREPROC

#endif // BITCOIN_CLIENTVERSION_H
43 changes: 43 additions & 0 deletions src/common/license.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) 2015-2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <common/license.h>

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif // HAVE_CONFIG_H

#include <tinyformat.h>
#include <util/translation.h>

#include <string>

std::string CopyrightHolders(const std::string& strPrefix)
{
const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION);
std::string strCopyrightHolders = strPrefix + copyright_devs;

// Make sure Bitcoin Core copyright is not removed by accident
if (copyright_devs.find("Bitcoin Core") == std::string::npos) {
strCopyrightHolders += "\n" + strPrefix + "The Bitcoin Core developers";
}
return strCopyrightHolders;
}

std::string LicenseInfo()
{
const std::string URL_SOURCE_CODE = "<https://github.com/bitcoin/bitcoin>";

return CopyrightHolders(strprintf(_("Copyright (C) %i-%i").translated, 2009, COPYRIGHT_YEAR) + " ") + "\n" +
"\n" +
strprintf(_("Please contribute if you find %s useful. "
"Visit %s for further information about the software.").translated, PACKAGE_NAME, "<" PACKAGE_URL ">") +
"\n" +
strprintf(_("The source code is available from %s.").translated, URL_SOURCE_CODE) +
"\n" +
"\n" +
_("This is experimental software.").translated + "\n" +
strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s").translated, "COPYING", "<https://opensource.org/licenses/MIT>") +
"\n";
}
15 changes: 15 additions & 0 deletions src/common/license.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) 2015-2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_COMMON_LICENSE_H
#define BITCOIN_COMMON_LICENSE_H

#include <string>

std::string CopyrightHolders(const std::string& strPrefix);

/** Returns licensing information (for -version) */
std::string LicenseInfo();

#endif // BITCOIN_COMMON_LICENSE_H
1 change: 1 addition & 0 deletions src/qt/splashscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <qt/splashscreen.h>

#include <clientversion.h>
#include <common/license.h>
#include <interfaces/handler.h>
#include <interfaces/node.h>
#include <interfaces/wallet.h>
Expand Down
1 change: 1 addition & 0 deletions src/qt/utilitydialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <qt/guiutil.h>

#include <clientversion.h>
#include <common/license.h>
#include <init.h>
#include <util/system.h>
#include <util/strencodings.h>
Expand Down
1 change: 1 addition & 0 deletions src/test/fuzz/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <blockfilter.h>
#include <clientversion.h>
#include <common/license.h>
#include <common/url.h>
#include <logging.h>
#include <netaddress.h>
Expand Down
2 changes: 1 addition & 1 deletion test/lint/run-lint-format-strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import sys

FALSE_POSITIVES = [
("src/common/license.cpp", "strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION)"),
("src/dbwrapper.cpp", "vsnprintf(p, limit - p, format, backup_ap)"),
("src/index/base.cpp", "FatalError(const char* fmt, const Args&... args)"),
("src/netbase.cpp", "LogConnectFailure(bool manual_connection, const char* fmt, const Args&... args)"),
("src/clientversion.cpp", "strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION)"),
("src/validationinterface.cpp", "LogPrint(BCLog::VALIDATION, fmt \"\\n\", __VA_ARGS__)"),
("src/wallet/wallet.h", "WalletLogPrintf(std::string fmt, Params... parameters)"),
("src/wallet/wallet.h", "LogPrintf((\"%s \" + fmt).c_str(), GetDisplayName(), parameters...)"),
Expand Down

0 comments on commit 1b176d1

Please sign in to comment.