mirror of
https://github.com/dashpay/dash.git
synced 2024-12-29 05:49:11 +01:00
ae051bb6e0
* Move wallet enums to walletutil.h * MOVEONLY: Move key handling code out of wallet to keyman file Start moving wallet and ismine code to scriptpubkeyman.h, scriptpubkeyman.cpp The easiest way to review this commit is to run: git log -p -n1 --color-moved=dimmed_zebra And check that everything is a move (other than includes and copyrights comments). This commit is move-only and doesn't change code or affect behavior. * Refactor: Split up CWallet and LegacyScriptPubKeyMan and classes This moves CWallet members and methods dealing with keys to a new LegacyScriptPubKeyMan class, and updates calling code to reference the new class instead of CWallet. Most of the changes are simple text replacements and variable substitutions easily verified with: git log -p -n1 -U0 --word-diff-regex=. The only nontrivial chunk of code added is the new LegacyScriptPubKeyMan class declaration, but this code isn't new and is just selectively copied and moved from the previous CWallet class declaration. This can be verified with: git log -p -n1 --color-moved=dimmed_zebra src/wallet/scriptpubkeyman.h src/wallet/wallet.h or git diff HEAD~1:src/wallet/wallet.h HEAD:src/wallet/scriptpubkeyman.h This commit does not change behavior. * Renamed classes in scriptpubkeyman * Fixes for conflicts, compilation and linkage errors due to previous commits * Reordered methods in scriptpubkeyman to make further backports easier * Reordered methods in scriptpubkeyman to make further backports easier (part II) * Remove HDChain copy from SigningProvider class * fixes/suggestions Co-authored-by: Andrew Chow <achow101-github@achow101.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
65 lines
1.6 KiB
C++
65 lines
1.6 KiB
C++
// Copyright (c) 2019 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_UTIL_TRANSLATION_H
|
|
#define BITCOIN_UTIL_TRANSLATION_H
|
|
|
|
#include <tinyformat.h>
|
|
|
|
#include <functional>
|
|
#include <utility>
|
|
|
|
/**
|
|
* Bilingual messages:
|
|
* - in GUI: user's native language + untranslated (i.e. English)
|
|
* - in log and stderr: untranslated only
|
|
*/
|
|
struct bilingual_str {
|
|
std::string original;
|
|
std::string translated;
|
|
|
|
bilingual_str& operator+=(const bilingual_str& rhs)
|
|
{
|
|
original += rhs.original;
|
|
translated += rhs.translated;
|
|
return *this;
|
|
}
|
|
|
|
bool empty() const
|
|
{
|
|
return original.empty();
|
|
}
|
|
};
|
|
|
|
inline bilingual_str operator+(bilingual_str lhs, const bilingual_str& rhs)
|
|
{
|
|
lhs += rhs;
|
|
return lhs;
|
|
}
|
|
|
|
/** Mark a bilingual_str as untranslated */
|
|
inline bilingual_str Untranslated(std::string original) { return {original, original}; }
|
|
|
|
namespace tinyformat {
|
|
template <typename... Args>
|
|
bilingual_str format(const bilingual_str& fmt, const Args&... args)
|
|
{
|
|
return bilingual_str{format(fmt.original, args...), format(fmt.translated, args...)};
|
|
}
|
|
} // namespace tinyformat
|
|
|
|
/** Translate a message to the native language of the user. */
|
|
const extern std::function<std::string(const char*)> G_TRANSLATION_FUN;
|
|
|
|
/**
|
|
* Translation function.
|
|
* If no translation function is set, simply return the input.
|
|
*/
|
|
inline bilingual_str _(const char* psz)
|
|
{
|
|
return bilingual_str{psz, G_TRANSLATION_FUN ? (G_TRANSLATION_FUN)(psz) : psz};
|
|
}
|
|
|
|
#endif // BITCOIN_UTIL_TRANSLATION_H
|