Bitcoin Core  21.99.0
P2P Digital Currency
external_signer.h
Go to the documentation of this file.
1 // Copyright (c) 2018-2021 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_WALLET_EXTERNAL_SIGNER_H
6 #define BITCOIN_WALLET_EXTERNAL_SIGNER_H
7 
8 #include <stdexcept>
9 #include <string>
10 #include <univalue.h>
11 #include <util/system.h>
12 
14 
15 class ExternalSignerException : public std::runtime_error {
16 public:
17  using std::runtime_error::runtime_error;
18 };
19 
23 {
24 private:
26  std::string m_command;
27 
28 public:
33  ExternalSigner(const std::string& command, const std::string& fingerprint, std::string chain, std::string name);
34 
36  std::string m_fingerprint;
37 
39  std::string m_chain;
40 
42  std::string m_name;
43 
44  const std::string NetworkArg() const;
45 
46 #ifdef ENABLE_EXTERNAL_SIGNER
47  static bool Enumerate(const std::string& command, std::vector<ExternalSigner>& signers, std::string chain, bool ignore_errors = false);
53 
57  UniValue DisplayAddress(const std::string& descriptor) const;
58 
63  UniValue GetDescriptors(int account);
64 
68  bool SignTransaction(PartiallySignedTransaction& psbt, std::string& error);
69 
70 #endif
71 };
72 
73 #endif // BITCOIN_WALLET_EXTERNAL_SIGNER_H
ExternalSigner::DisplayAddress
UniValue DisplayAddress(const std::string &descriptor) const
Display address on the device.
Definition: external_signer.cpp:62
ExternalSigner::m_chain
std::string m_chain
Bitcoin mainnet, testnet, etc.
Definition: external_signer.h:39
ExternalSignerException
Definition: external_signer.h:15
UniValue
Definition: univalue.h:19
ExternalSigner::SignTransaction
bool SignTransaction(PartiallySignedTransaction &psbt, std::string &error)
Sign PartiallySignedTransaction on the device.
Definition: external_signer.cpp:72
univalue.h
ExternalSigner::GetDescriptors
UniValue GetDescriptors(int account)
Get receive and change Descriptor(s) from device for a given account.
Definition: external_signer.cpp:67
ExternalSigner
Enables interaction with an external signing device or service, such as a hardware wallet.
Definition: external_signer.h:22
ExternalSigner::ExternalSigner
ExternalSigner(const std::string &command, const std::string &fingerprint, std::string chain, std::string name)
Definition: external_signer.cpp:12
name
const char * name
Definition: rest.cpp:42
system.h
ExternalSigner::Enumerate
static bool Enumerate(const std::string &command, std::vector< ExternalSigner > &signers, std::string chain, bool ignore_errors=false)
Obtain a list of signers.
Definition: external_signer.cpp:21
PartiallySignedTransaction
A version of CTransaction with the PSBT format.
Definition: psbt.h:391
ExternalSigner::m_command
std::string m_command
The command which handles interaction with the external signer.
Definition: external_signer.h:26
ExternalSigner::NetworkArg
const std::string NetworkArg() const
Definition: external_signer.cpp:14
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:50
ExternalSigner::m_fingerprint
std::string m_fingerprint
Master key fingerprint of the signer.
Definition: external_signer.h:36
ExternalSigner::m_name
std::string m_name
Name of signer.
Definition: external_signer.h:42