refactor: Avoid copies by using const references or by move-construction
This commit is contained in:
10 files changed
+15
-13
No files matched your search
@@ -15,14 +15,15 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
ExternalSigner::ExternalSigner(const std::string& command, const std::string chain, const std::string& fingerprint, const std::string name): m_command(command), m_chain(chain), m_fingerprint(fingerprint), m_name(name) {}
|
ExternalSigner::ExternalSigner(std::string command, std::string chain, std::string fingerprint, std::string name)
|
||||||
|
: m_command{std::move(command)}, m_chain{std::move(chain)}, m_fingerprint{std::move(fingerprint)}, m_name{std::move(name)} {}
|
||||||
|
|
||||||
std::string ExternalSigner::NetworkArg() const
|
std::string ExternalSigner::NetworkArg() const
|
||||||
{
|
{
|
||||||
return " --chain " + m_chain;
|
return " --chain " + m_chain;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExternalSigner::Enumerate(const std::string& command, std::vector<ExternalSigner>& signers, const std::string chain)
|
bool ExternalSigner::Enumerate(const std::string& command, std::vector<ExternalSigner>& signers, const std::string& chain)
|
||||||
{
|
{
|
||||||
// Call <command> enumerate
|
// Call <command> enumerate
|
||||||
const UniValue result = RunCommandParseJSON(command + " enumerate");
|
const UniValue result = RunCommandParseJSON(command + " enumerate");
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public:
|
|||||||
//! @param[in] fingerprint master key fingerprint of the signer
|
//! @param[in] fingerprint master key fingerprint of the signer
|
||||||
//! @param[in] chain "main", "test", "regtest" or "signet"
|
//! @param[in] chain "main", "test", "regtest" or "signet"
|
||||||
//! @param[in] name device name
|
//! @param[in] name device name
|
||||||
ExternalSigner(const std::string& command, const std::string chain, const std::string& fingerprint, const std::string name);
|
ExternalSigner(std::string command, std::string chain, std::string fingerprint, std::string name);
|
||||||
|
|
||||||
//! Master key fingerprint of the signer
|
//! Master key fingerprint of the signer
|
||||||
std::string m_fingerprint;
|
std::string m_fingerprint;
|
||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
//! @param[in,out] signers vector to which new signers (with a unique master key fingerprint) are added
|
//! @param[in,out] signers vector to which new signers (with a unique master key fingerprint) are added
|
||||||
//! @param chain "main", "test", "regtest" or "signet"
|
//! @param chain "main", "test", "regtest" or "signet"
|
||||||
//! @returns success
|
//! @returns success
|
||||||
static bool Enumerate(const std::string& command, std::vector<ExternalSigner>& signers, const std::string chain);
|
static bool Enumerate(const std::string& command, std::vector<ExternalSigner>& signers, const std::string& chain);
|
||||||
|
|
||||||
//! Display address on the device. Calls `<command> displayaddress --desc <descriptor>`.
|
//! Display address on the device. Calls `<command> displayaddress --desc <descriptor>`.
|
||||||
//! @param[in] descriptor Descriptor specifying which address to display.
|
//! @param[in] descriptor Descriptor specifying which address to display.
|
||||||
|
|||||||
+2
-1
@@ -60,7 +60,8 @@ class Proxy
|
|||||||
public:
|
public:
|
||||||
Proxy() : m_is_unix_socket(false), m_tor_stream_isolation(false) {}
|
Proxy() : m_is_unix_socket(false), m_tor_stream_isolation(false) {}
|
||||||
explicit Proxy(const CService& _proxy, bool tor_stream_isolation = false) : proxy(_proxy), m_is_unix_socket(false), m_tor_stream_isolation(tor_stream_isolation) {}
|
explicit Proxy(const CService& _proxy, bool tor_stream_isolation = false) : proxy(_proxy), m_is_unix_socket(false), m_tor_stream_isolation(tor_stream_isolation) {}
|
||||||
explicit Proxy(const std::string path, bool tor_stream_isolation = false) : m_unix_socket_path(path), m_is_unix_socket(true), m_tor_stream_isolation(tor_stream_isolation) {}
|
explicit Proxy(std::string path, bool tor_stream_isolation = false)
|
||||||
|
: m_unix_socket_path(std::move(path)), m_is_unix_socket(true), m_tor_stream_isolation(tor_stream_isolation) {}
|
||||||
|
|
||||||
CService proxy;
|
CService proxy;
|
||||||
std::string m_unix_socket_path;
|
std::string m_unix_socket_path;
|
||||||
|
|||||||
+1
-1
@@ -322,7 +322,7 @@ bool PSBTInputSigned(const PSBTInput& input)
|
|||||||
return !input.final_script_sig.empty() || !input.final_script_witness.IsNull();
|
return !input.final_script_sig.empty() || !input.final_script_witness.IsNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PSBTInputSignedAndVerified(const PartiallySignedTransaction psbt, unsigned int input_index, const PrecomputedTransactionData* txdata)
|
bool PSBTInputSignedAndVerified(const PartiallySignedTransaction& psbt, unsigned int input_index, const PrecomputedTransactionData* txdata)
|
||||||
{
|
{
|
||||||
CTxOut utxo;
|
CTxOut utxo;
|
||||||
assert(input_index < psbt.inputs.size());
|
assert(input_index < psbt.inputs.size());
|
||||||
|
|||||||
+1
-1
@@ -1413,7 +1413,7 @@ PrecomputedTransactionData PrecomputePSBTData(const PartiallySignedTransaction&
|
|||||||
bool PSBTInputSigned(const PSBTInput& input);
|
bool PSBTInputSigned(const PSBTInput& input);
|
||||||
|
|
||||||
/** Checks whether a PSBTInput is already signed by doing script verification using final fields. */
|
/** Checks whether a PSBTInput is already signed by doing script verification using final fields. */
|
||||||
bool PSBTInputSignedAndVerified(const PartiallySignedTransaction psbt, unsigned int input_index, const PrecomputedTransactionData* txdata);
|
bool PSBTInputSignedAndVerified(const PartiallySignedTransaction& psbt, unsigned int input_index, const PrecomputedTransactionData* txdata);
|
||||||
|
|
||||||
/** Signs a PSBTInput, verifying that all provided data matches what is being signed.
|
/** Signs a PSBTInput, verifying that all provided data matches what is being signed.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(util_datadir)
|
|||||||
struct TestArgsManager : public ArgsManager
|
struct TestArgsManager : public ArgsManager
|
||||||
{
|
{
|
||||||
TestArgsManager() { m_network_only_args.clear(); }
|
TestArgsManager() { m_network_only_args.clear(); }
|
||||||
void ReadConfigString(const std::string str_config)
|
void ReadConfigString(const std::string& str_config)
|
||||||
{
|
{
|
||||||
std::istringstream streamConfig(str_config);
|
std::istringstream streamConfig(str_config);
|
||||||
{
|
{
|
||||||
@@ -63,7 +63,7 @@ struct TestArgsManager : public ArgsManager
|
|||||||
std::string error;
|
std::string error;
|
||||||
BOOST_REQUIRE(ReadConfigStream(streamConfig, "", error));
|
BOOST_REQUIRE(ReadConfigStream(streamConfig, "", error));
|
||||||
}
|
}
|
||||||
void SetNetworkOnlyArg(const std::string arg)
|
void SetNetworkOnlyArg(const std::string& arg)
|
||||||
{
|
{
|
||||||
LOCK(cs_args);
|
LOCK(cs_args);
|
||||||
m_network_only_args.insert(arg);
|
m_network_only_args.insert(arg);
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ void PushParentDescriptors(const CWallet& wallet, const CScript& script_pubkey,
|
|||||||
entry.pushKV("parent_descs", std::move(parent_descs));
|
entry.pushKV("parent_descs", std::move(parent_descs));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleWalletError(const std::shared_ptr<CWallet> wallet, DatabaseStatus& status, bilingual_str& error)
|
void HandleWalletError(const std::shared_ptr<CWallet>& wallet, DatabaseStatus& status, bilingual_str& error)
|
||||||
{
|
{
|
||||||
if (!wallet) {
|
if (!wallet) {
|
||||||
// Map bad format to not found, since bad format is returned when the
|
// Map bad format to not found, since bad format is returned when the
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ std::string LabelFromValue(const UniValue& value);
|
|||||||
//! Fetch parent descriptors of this scriptPubKey.
|
//! Fetch parent descriptors of this scriptPubKey.
|
||||||
void PushParentDescriptors(const CWallet& wallet, const CScript& script_pubkey, UniValue& entry);
|
void PushParentDescriptors(const CWallet& wallet, const CScript& script_pubkey, UniValue& entry);
|
||||||
|
|
||||||
void HandleWalletError(const std::shared_ptr<CWallet> wallet, DatabaseStatus& status, bilingual_str& error);
|
void HandleWalletError(const std::shared_ptr<CWallet>& wallet, DatabaseStatus& status, bilingual_str& error);
|
||||||
void AppendLastProcessedBlock(UniValue& entry, const CWallet& wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
void AppendLastProcessedBlock(UniValue& entry, const CWallet& wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
||||||
} // namespace wallet
|
} // namespace wallet
|
||||||
|
|
||||||
|
|||||||
@@ -2534,7 +2534,7 @@ bool CWallet::TopUpKeyPool(unsigned int kpSize)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
util::Result<CTxDestination> CWallet::GetNewDestination(const OutputType type, const std::string label)
|
util::Result<CTxDestination> CWallet::GetNewDestination(const OutputType type, const std::string& label)
|
||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
auto spk_man = GetScriptPubKeyMan(type, /*internal=*/false);
|
auto spk_man = GetScriptPubKeyMan(type, /*internal=*/false);
|
||||||
|
|||||||
+1
-1
@@ -783,7 +783,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void MarkDestinationsDirty(const std::set<CTxDestination>& destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
void MarkDestinationsDirty(const std::set<CTxDestination>& destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
|
|
||||||
util::Result<CTxDestination> GetNewDestination(const OutputType type, const std::string label);
|
util::Result<CTxDestination> GetNewDestination(const OutputType type, const std::string& label);
|
||||||
util::Result<CTxDestination> GetNewChangeDestination(const OutputType type);
|
util::Result<CTxDestination> GetNewChangeDestination(const OutputType type);
|
||||||
|
|
||||||
bool IsMine(const CTxDestination& dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
bool IsMine(const CTxDestination& dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
|
|||||||
Reference in new issue
Block a user