28 throw std::runtime_error(
strprintf(
"'%s' received invalid response, expected array of signers", command));
33 if (!
error.isNull()) {
35 throw std::runtime_error(
strprintf(
"'%s' error", command));
37 throw std::runtime_error(
strprintf(
"'%s' error: %s", command,
error.getValStr()));
41 if (fingerprint.
isNull()) {
42 throw std::runtime_error(
strprintf(
"'%s' received invalid response, missing signer fingerprint", command));
44 const std::string fingerprintStr = fingerprint.
get_str();
46 bool duplicate =
false;
48 if (signer.m_fingerprint.compare(fingerprintStr) == 0) duplicate =
true;
51 std::string
name =
"";
79 for (
unsigned int i = 0; i < psbtx.inputs.size(); ++i) {
92 const std::string stdinStr =
"signtx \"" +
EncodeBase64(ssTx.
str()) +
"\"";
96 if (
find_value(signer_result,
"error").isStr()) {
101 if (!
find_value(signer_result,
"psbt").isStr()) {
102 error =
"Unexpected result from signer";
107 std::string signer_psbt_error;
113 psbtx = signer_psbtx;
Enables interaction with an external signing device or service, such as a hardware wallet...
const std::vector< UniValue > & getValues() const
std::string m_command
The command which handles interaction with the external signer.
ExternalSigner(const std::string &command, const std::string chain, const std::string &fingerprint, const std::string name)
const std::string & get_str() const
A version of CTransaction with the PSBT format.
Double ended buffer combining vector and stream-like interfaces.
std::string m_fingerprint
Master key fingerprint of the signer.
const std::string & getValStr() const
std::string m_chain
Bitcoin mainnet, testnet, etc.
const UniValue & find_value(const UniValue &obj, const std::string &name)
std::string EncodeBase64(Span< const unsigned char > input)
UniValue DisplayAddress(const std::string &descriptor) const
Display address on the device.
const std::string NetworkArg() const
bool DecodeBase64PSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
static uint32_t ReadBE32(const unsigned char *ptr)
static bool Enumerate(const std::string &command, std::vector< ExternalSigner > &signers, const std::string chain)
Obtain a list of signers.
UniValue GetDescriptors(const int account)
Get receive and change Descriptor(s) from device for a given account.
bool SignTransaction(PartiallySignedTransaction &psbt, std::string &error)
Sign PartiallySignedTransaction on the device.
static const int PROTOCOL_VERSION
network protocol versioning
UniValue RunCommandParseJSON(const std::string &str_command, const std::string &str_std_in)
Execute a command which returns JSON, and parse the result.
bool error(const char *fmt, const Args &... args)