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

merge bitcoin#16244...18699: translation backports #4735

Merged
merged 12 commits into from
Apr 7, 2022
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
3 changes: 2 additions & 1 deletion contrib/dash-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ FORMS += \
../src/qt/forms/sendcoinsdialog.ui \
../src/qt/forms/sendcoinsentry.ui \
../src/qt/forms/signverifymessagedialog.ui \
../src/qt/forms/transactiondescdialog.ui
../src/qt/forms/transactiondescdialog.ui \
../src/qt/forms/createwalletdialog.ui

RESOURCES += \
../src/qt/dash.qrc
4 changes: 4 additions & 0 deletions doc/release-notes-16394.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RPC changes
-----------
`createwallet` now returns a warning if an empty string is used as an encryption password, and does not encrypt the wallet, instead of raising an error.
This makes it easier to disable encryption but also specify other options when using the `bitcoin-cli` tool.
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ BITCOIN_CORE_H = \
util/string.h \
util/time.h \
util/threadnames.h \
util/translation.h \
util/vector.h \
util/url.h \
util/validation.h \
Expand Down
4 changes: 4 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ QT_FORMS_UI = \
qt/forms/appearancewidget.ui \
qt/forms/askpassphrasedialog.ui \
qt/forms/coincontroldialog.ui \
qt/forms/createwalletdialog.ui \
qt/forms/editaddressdialog.ui \
qt/forms/governancelist.ui \
qt/forms/helpmessagedialog.ui \
Expand All @@ -37,6 +38,7 @@ QT_MOC_CPP = \
qt/moc_addresstablemodel.cpp \
qt/moc_appearancewidget.cpp \
qt/moc_askpassphrasedialog.cpp \
qt/moc_createwalletdialog.cpp \
qt/moc_bantablemodel.cpp \
qt/moc_bitcoinaddressvalidator.cpp \
qt/moc_bitcoinamountfield.cpp \
Expand Down Expand Up @@ -125,6 +127,7 @@ BITCOIN_QT_H = \
qt/clientmodel.h \
qt/coincontroldialog.h \
qt/coincontroltreewidget.h \
qt/createwalletdialog.h \
qt/csvmodelwriter.h \
qt/dash.h \
qt/editaddressdialog.h \
Expand Down Expand Up @@ -240,6 +243,7 @@ BITCOIN_QT_WALLET_CPP = \
qt/askpassphrasedialog.cpp \
qt/coincontroldialog.cpp \
qt/coincontroltreewidget.cpp \
qt/createwalletdialog.cpp \
qt/editaddressdialog.cpp \
qt/governancelist.cpp \
qt/masternodelist.cpp \
Expand Down
3 changes: 2 additions & 1 deletion src/banman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
#include <ui_interface.h>
#include <util/system.h>
#include <util/time.h>
#include <util/translation.h>


BanMan::BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t default_ban_time)
: m_client_interface(client_interface), m_ban_db(std::move(ban_file)), m_default_ban_time(default_ban_time)
{
if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist..."));
if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist...").translated);

int64_t n_start = GetTimeMillis();
m_is_dirty = false;
Expand Down
2 changes: 1 addition & 1 deletion src/bench/bench_dash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int main(int argc, char** argv)
SetupBenchArgs();
std::string error;
if (!gArgs.ParseParameters(argc, argv, error)) {
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error.c_str());
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error);
return EXIT_FAILURE;
}

Expand Down
87 changes: 44 additions & 43 deletions src/coinjoin/client.cpp

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions src/coinjoin/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

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

#include <utility>
#include <atomic>
Expand Down Expand Up @@ -71,8 +72,8 @@ class CCoinJoinClientSession : public CCoinJoinBaseSession
private:
std::vector<COutPoint> vecOutPointLocked;

std::string strLastMessage;
std::string strAutoDenomResult;
bilingual_str strLastMessage;
bilingual_str strAutoDenomResult;

CDeterministicMNCPtr mixingMasternode;
CMutableTransaction txMyCollateral; // client side collateral
Expand Down Expand Up @@ -128,7 +129,7 @@ class CCoinJoinClientSession : public CCoinJoinBaseSession

void ResetPool();

std::string GetStatus(bool fWaitForBlock) const;
bilingual_str GetStatus(bool fWaitForBlock) const;

bool GetMixingMasternodeInfo(CDeterministicMNCPtr& ret) const;

Expand Down Expand Up @@ -171,7 +172,7 @@ class CCoinJoinClientManager

int nCachedLastSuccessBlock{0};
int nMinBlocksToWait{1}; // how many blocks to wait for after one successful mixing tx in non-multisession mode
std::string strAutoDenomResult;
bilingual_str strAutoDenomResult;

CWallet& mixingWallet;

Expand Down Expand Up @@ -201,7 +202,7 @@ class CCoinJoinClientManager
bool IsMixing() const;
void ResetPool();

std::string GetStatuses();
bilingual_str GetStatuses();
std::string GetSessionDenoms();

bool GetMixingMasternodesInfo(std::vector<CDeterministicMNCPtr>& vecDmnsRet) const;
Expand Down
3 changes: 2 additions & 1 deletion src/coinjoin/coinjoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <txmempool.h>
#include <util/moneystr.h>
#include <util/system.h>
#include <util/translation.h>
#include <validation.h>

#include <string>
Expand Down Expand Up @@ -374,7 +375,7 @@ std::string CCoinJoin::DenominationToString(int nDenom)
return "to-string-error";
}

std::string CCoinJoin::GetMessageByID(PoolMessage nMessageID)
bilingual_str CCoinJoin::GetMessageByID(PoolMessage nMessageID)
{
switch (nMessageID) {
case ERR_ALREADY_HAVE:
Expand Down
3 changes: 2 additions & 1 deletion src/coinjoin/coinjoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <tinyformat.h>
#include <univalue.h>
#include <util/ranges.h>
#include <util/translation.h>

#include <utility>

Expand Down Expand Up @@ -440,7 +441,7 @@ class CCoinJoin
*/
static std::string DenominationToString(int nDenom);

static std::string GetMessageByID(PoolMessage nMessageID);
static bilingual_str GetMessageByID(PoolMessage nMessageID);

/// Get the minimum/maximum number of participants for the pool
static int GetMinPoolParticipants();
Expand Down
2 changes: 1 addition & 1 deletion src/coinjoin/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ bool CCoinJoinServer::AddEntry(CConnman& connman, const CCoinJoinEntry& entry, P

bool fConsumeCollateral{false};
if (!IsValidInOuts(vin, entry.vecTxOut, nMessageIDRet, &fConsumeCollateral)) {
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::%s -- ERROR! IsValidInOuts() failed: %s\n", __func__, CCoinJoin::GetMessageByID(nMessageIDRet));
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::%s -- ERROR! IsValidInOuts() failed: %s\n", __func__, CCoinJoin::GetMessageByID(nMessageIDRet).translated);
if (fConsumeCollateral) {
ConsumeCollateral(connman, entry.txCollateral);
}
Expand Down
11 changes: 6 additions & 5 deletions src/coinjoin/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <validation.h>
#include <wallet/fees.h>
#include <wallet/wallet.h>
#include <util/translation.h>

#include <numeric>

Expand Down Expand Up @@ -254,7 +255,7 @@ bool CTransactionBuilder::IsDust(CAmount nAmount) const
return ::IsDust(CTxOut(nAmount, ::GetScriptForDestination(tallyItem.txdest)), coinControl.m_discard_feerate.get());
}

bool CTransactionBuilder::Commit(std::string& strResult)
bool CTransactionBuilder::Commit(bilingual_str& strResult)
{
CAmount nFeeRet = 0;
int nChangePosRet = -1;
Expand All @@ -278,13 +279,13 @@ bool CTransactionBuilder::Commit(std::string& strResult)
bool fDust = IsDust(nAmountLeft);
// If there is a either remainder which is considered to be dust (will be added to fee in this case) or no amount left there should be no change output, return if there is a change output.
if (nChangePosRet != -1 && fDust) {
strResult = strprintf("Unexpected change output %s at position %d", tx->vout[nChangePosRet].ToString(), nChangePosRet);
strResult = Untranslated(strprintf("Unexpected change output %s at position %d", tx->vout[nChangePosRet].ToString(), nChangePosRet));
return false;
}

// If there is a remainder which is not considered to be dust it should end up in a change output, return if not.
if (nChangePosRet == -1 && !fDust) {
strResult = strprintf("Change output missing: %d", nAmountLeft);
strResult = Untranslated(strprintf("Change output missing: %d", nAmountLeft));
return false;
}

Expand All @@ -301,15 +302,15 @@ bool CTransactionBuilder::Commit(std::string& strResult)
// If the calculated fee does not match the fee returned by CreateTransaction aka if this check fails something is wrong!
CAmount nFeeCalc = GetFee(GetBytesTotal() + nBytesAdditional) + nFeeAdditional;
if (nFeeRet != nFeeCalc) {
strResult = strprintf("Fee validation failed -> nFeeRet: %d, nFeeCalc: %d, nFeeAdditional: %d, nBytesAdditional: %d, %s", nFeeRet, nFeeCalc, nFeeAdditional, nBytesAdditional, ToString());
strResult = Untranslated(strprintf("Fee validation failed -> nFeeRet: %d, nFeeCalc: %d, nFeeAdditional: %d, nBytesAdditional: %d, %s", nFeeRet, nFeeCalc, nFeeAdditional, nBytesAdditional, ToString()));
return false;
}

pwallet->CommitTransaction(tx, {}, {});

fKeepKeys = true;

strResult = tx->GetHash().ToString();
strResult = Untranslated(tx->GetHash().ToString());

return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/coinjoin/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <wallet/wallet.h>

class CTransactionBuilder;
struct bilingual_str;

class CKeyHolder
{
Expand Down Expand Up @@ -116,7 +117,7 @@ class CTransactionBuilder
/// Get the total number of added outputs
int CountOutputs() const { LOCK(cs_outputs); return vecOutputs.size(); }
/// Create and Commit the transaction to the wallet
bool Commit(std::string& strResult);
bool Commit(bilingual_str& strResult);
/// Convert to a string
std::string ToString() const;

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/hkdf_sha256_32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

CHKDF_HMAC_SHA256_L32::CHKDF_HMAC_SHA256_L32(const unsigned char* ikm, size_t ikmlen, const std::string& salt)
{
CHMAC_SHA256((const unsigned char*)salt.c_str(), salt.size()).Write(ikm, ikmlen).Finalize(m_prk);
CHMAC_SHA256((const unsigned char*)salt.data(), salt.size()).Write(ikm, ikmlen).Finalize(m_prk);
}

void CHKDF_HMAC_SHA256_L32::Expand32(const std::string& info, unsigned char hash[OUTPUT_SIZE])
Expand Down
18 changes: 10 additions & 8 deletions src/dash-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
#include <rpc/protocol.h>
#include <rpc/request.h>
#include <stacktraces.h>
#include <util/system.h>
#include <util/strencodings.h>
#include <util/system.h>
#include <util/translation.h>

#include <functional>
#include <memory>
#include <stdio.h>
#include <tuple>
Expand Down Expand Up @@ -109,7 +111,7 @@ static int AppInitRPC(int argc, char* argv[])
SetupCliArgs();
std::string error;
if (!gArgs.ParseParameters(argc, argv, error)) {
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error.c_str());
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error);
return EXIT_FAILURE;
}

Expand All @@ -129,7 +131,7 @@ static int AppInitRPC(int argc, char* argv[])
strUsage += "\n" + gArgs.GetHelpMessage();
}

tfm::format(std::cout, "%s", strUsage.c_str());
tfm::format(std::cout, "%s", strUsage);
if (argc < 2) {
tfm::format(std::cerr, "Error: too few parameters\n");
return EXIT_FAILURE;
Expand All @@ -138,15 +140,15 @@ static int AppInitRPC(int argc, char* argv[])
}
bool datadirFromCmdLine = gArgs.IsArgSet("-datadir");
if (datadirFromCmdLine && !fs::is_directory(GetDataDir(false))) {
tfm::format(std::cerr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
tfm::format(std::cerr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", ""));
return EXIT_FAILURE;
}
if (!gArgs.ReadConfigFiles(error, true)) {
tfm::format(std::cerr, "Error reading configuration file: %s\n", error.c_str());
tfm::format(std::cerr, "Error reading configuration file: %s\n", error);
return EXIT_FAILURE;
}
if (!datadirFromCmdLine && !fs::is_directory(GetDataDir(false))) {
tfm::format(std::cerr, "Error: Specified data directory \"%s\" from config file does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
tfm::format(std::cerr, "Error: Specified data directory \"%s\" from config file does not exist.\n", gArgs.GetArg("-datadir", ""));
return EXIT_FAILURE;
}
// Check for -testnet or -regtest parameter (BaseParams() calls are only valid after this clause)
Expand Down Expand Up @@ -411,7 +413,7 @@ static UniValue CallRPC(BaseRequestHandler *rh, const std::string& strMethod, co
if (failedToGetAuthCookie) {
throw std::runtime_error(strprintf(
"Could not locate RPC credentials. No authentication cookie could be found, and RPC password is not set. See -rpcpassword and -stdinrpcpass. Configuration file: (%s)",
GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)).string().c_str()));
GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)).string()));
} else {
throw std::runtime_error("Authorization failed: Incorrect rpcuser or rpcpassword");
}
Expand Down Expand Up @@ -559,7 +561,7 @@ static int CommandLineRPC(int argc, char *argv[])
}

if (strPrint != "") {
tfm::format(nRet == 0 ? std::cout : std::cerr, "%s\n", strPrint.c_str());
tfm::format(nRet == 0 ? std::cout : std::cerr, "%s\n", strPrint);
}
return nRet;
}
Expand Down
16 changes: 9 additions & 7 deletions src/dash-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
#include <script/script.h>
#include <script/sign.h>
#include <univalue.h>
#include <util/system.h>
#include <util/moneystr.h>
#include <util/strencodings.h>
#include <util/system.h>
#include <util/translation.h>

#include <functional>
#include <memory>
#include <stdio.h>

Expand Down Expand Up @@ -81,7 +83,7 @@ static int AppInitRawTx(int argc, char* argv[])
SetupBitcoinTxArgs();
std::string error;
if (!gArgs.ParseParameters(argc, argv, error)) {
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error.c_str());
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error);
return EXIT_FAILURE;
}

Expand All @@ -108,7 +110,7 @@ static int AppInitRawTx(int argc, char* argv[])
"\n";
strUsage += gArgs.GetHelpMessage();

tfm::format(std::cout, "%s", strUsage.c_str());
tfm::format(std::cout, "%s", strUsage);

if (argc < 2) {
tfm::format(std::cerr, "Error: too few parameters\n");
Expand Down Expand Up @@ -679,21 +681,21 @@ static void OutputTxJSON(const CTransaction& tx)
TxToUniv(tx, uint256(), entry);

std::string jsonOutput = entry.write(4);
tfm::format(std::cout, "%s\n", jsonOutput.c_str());
tfm::format(std::cout, "%s\n", jsonOutput);
}

static void OutputTxHash(const CTransaction& tx)
{
std::string strHexHash = tx.GetHash().GetHex(); // the hex-encoded transaction hash (aka the transaction id)

tfm::format(std::cout, "%s\n", strHexHash.c_str());
tfm::format(std::cout, "%s\n", strHexHash);
}

static void OutputTxHex(const CTransaction& tx)
{
std::string strHex = EncodeHexTx(tx);

tfm::format(std::cout, "%s\n", strHex.c_str());
tfm::format(std::cout, "%s\n", strHex);
}

static void OutputTx(const CTransaction& tx)
Expand Down Expand Up @@ -784,7 +786,7 @@ static int CommandLineRawTx(int argc, char* argv[])
}

if (strPrint != "") {
tfm::format(nRet == 0 ? std::cout : std::cerr, "%s\n", strPrint.c_str());
tfm::format(nRet == 0 ? std::cout : std::cerr, "%s\n", strPrint);
}
return nRet;
}
Expand Down
3 changes: 2 additions & 1 deletion src/dash-wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#include <chainparams.h>
#include <chainparamsbase.h>
#include <logging.h>
#include <util/system.h>
#include <util/strencodings.h>
#include <util/system.h>
#include <util/translation.h>
#include <wallet/wallettool.h>

const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
Expand Down
Loading