aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2021-06-16 14:49:09 -0400
committerRussell Yanofsky <russ@yanofsky.org>2021-10-05 11:10:47 -0400
commita032fa30d282fa69c304e0afd1f95f67c55d22e3 (patch)
treec4aea56786decc54ff8474a67c604530097d8b96 /src/node
parent113b863f0773999497f952daa6539a03a66a9de3 (diff)
downloadbitcoin-a032fa30d282fa69c304e0afd1f95f67c55d22e3.tar.xz
multiprocess: add interfaces::ExternalSigner class
Add interfaces::ExternalSigner to let signer objects be passed between processes and signer code to run in the original process, without multiple processes linking and running signer code.
Diffstat (limited to 'src/node')
-rw-r--r--src/node/interfaces.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index 5b6d8416a7..24959f385e 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -67,6 +67,17 @@ using interfaces::WalletClient;
namespace node {
namespace {
+#ifdef ENABLE_EXTERNAL_SIGNER
+class ExternalSignerImpl : public interfaces::ExternalSigner
+{
+public:
+ ExternalSignerImpl(::ExternalSigner signer) : m_signer(std::move(signer)) {}
+ std::string getName() override { return m_signer.m_name; }
+private:
+ ::ExternalSigner m_signer;
+};
+#endif
+
class NodeImpl : public Node
{
private:
@@ -172,14 +183,18 @@ public:
}
return false;
}
- std::vector<ExternalSigner> externalSigners() override
+ std::vector<std::unique_ptr<interfaces::ExternalSigner>> listExternalSigners() override
{
#ifdef ENABLE_EXTERNAL_SIGNER
std::vector<ExternalSigner> signers = {};
const std::string command = gArgs.GetArg("-signer", "");
- if (command == "") return signers;
+ if (command == "") return {};
ExternalSigner::Enumerate(command, signers, Params().NetworkIDString());
- return signers;
+ std::vector<std::unique_ptr<interfaces::ExternalSigner>> result;
+ for (auto& signer : signers) {
+ result.emplace_back(std::make_unique<ExternalSignerImpl>(std::move(signer)));
+ }
+ return result;
#else
// This result is indistinguishable from a successful call that returns
// no signers. For the current GUI this doesn't matter, because the wallet