aboutsummaryrefslogtreecommitdiff
path: root/src/external_signer.cpp
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2021-04-13 19:41:50 +0800
committerfanquake <fanquake@gmail.com>2021-04-13 20:09:34 +0800
commit9e0b199b976617edeb1c58d4203df5f83a26c1e3 (patch)
tree484cc9e0faf1146d4e3d9d15d7518575c51ed53e /src/external_signer.cpp
parentaaa4e5a45bd9ec5563ffa7b9e0d46d2de3cb9242 (diff)
downloadbitcoin-9e0b199b976617edeb1c58d4203df5f83a26c1e3.tar.xz
external_signer: use const where appropriate
Diffstat (limited to 'src/external_signer.cpp')
-rw-r--r--src/external_signer.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/external_signer.cpp b/src/external_signer.cpp
index 4809c5abf2..9325daeab2 100644
--- a/src/external_signer.cpp
+++ b/src/external_signer.cpp
@@ -14,14 +14,14 @@
#ifdef ENABLE_EXTERNAL_SIGNER
-ExternalSigner::ExternalSigner(const std::string& command, const std::string& fingerprint, std::string chain, std::string name): m_command(command), m_fingerprint(fingerprint), m_chain(chain), m_name(name) {}
+ExternalSigner::ExternalSigner(const std::string& command, const std::string& fingerprint, const std::string chain, const std::string name): m_command(command), m_fingerprint(fingerprint), m_chain(chain), m_name(name) {}
const std::string ExternalSigner::NetworkArg() const
{
return " --chain " + m_chain;
}
-bool ExternalSigner::Enumerate(const std::string& command, std::vector<ExternalSigner>& signers, std::string chain)
+bool ExternalSigner::Enumerate(const std::string& command, std::vector<ExternalSigner>& signers, const std::string chain)
{
// Call <command> enumerate
const UniValue result = RunCommandParseJSON(command + " enumerate");
@@ -42,10 +42,10 @@ bool ExternalSigner::Enumerate(const std::string& command, std::vector<ExternalS
if (fingerprint.isNull()) {
throw ExternalSignerException(strprintf("'%s' received invalid response, missing signer fingerprint", command));
}
- std::string fingerprintStr = fingerprint.get_str();
+ const std::string fingerprintStr = fingerprint.get_str();
// Skip duplicate signer
bool duplicate = false;
- for (ExternalSigner signer : signers) {
+ for (const ExternalSigner& signer : signers) {
if (signer.m_fingerprint.compare(fingerprintStr) == 0) duplicate = true;
}
if (duplicate) break;
@@ -64,7 +64,7 @@ UniValue ExternalSigner::DisplayAddress(const std::string& descriptor) const
return RunCommandParseJSON(m_command + " --fingerprint \"" + m_fingerprint + "\"" + NetworkArg() + " displayaddress --desc \"" + descriptor + "\"");
}
-UniValue ExternalSigner::GetDescriptors(int account)
+UniValue ExternalSigner::GetDescriptors(const int account)
{
return RunCommandParseJSON(m_command + " --fingerprint \"" + m_fingerprint + "\"" + NetworkArg() + " getdescriptors --account " + strprintf("%d", account));
}
@@ -79,7 +79,7 @@ bool ExternalSigner::SignTransaction(PartiallySignedTransaction& psbtx, std::str
bool match = false;
for (unsigned int i = 0; i < psbtx.inputs.size(); ++i) {
const PSBTInput& input = psbtx.inputs[i];
- for (auto entry : input.hd_keypaths) {
+ for (const auto& entry : input.hd_keypaths) {
if (m_fingerprint == strprintf("%08x", ReadBE32(entry.second.fingerprint))) match = true;
}
}
@@ -89,8 +89,8 @@ bool ExternalSigner::SignTransaction(PartiallySignedTransaction& psbtx, std::str
return false;
}
- std::string command = m_command + " --stdin --fingerprint \"" + m_fingerprint + "\"" + NetworkArg();
- std::string stdinStr = "signtx \"" + EncodeBase64(ssTx.str()) + "\"";
+ const std::string command = m_command + " --stdin --fingerprint \"" + m_fingerprint + "\"" + NetworkArg();
+ const std::string stdinStr = "signtx \"" + EncodeBase64(ssTx.str()) + "\"";
const UniValue signer_result = RunCommandParseJSON(command, stdinStr);