 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
29 throw std::runtime_error(
strprintf(
"'%s' received invalid response, expected array of signers", command));
34 if (!
error.isNull()) {
36 throw std::runtime_error(
strprintf(
"'%s' error", command));
38 throw std::runtime_error(
strprintf(
"'%s' error: %s", command,
error.getValStr()));
42 if (fingerprint.
isNull()) {
43 throw std::runtime_error(
strprintf(
"'%s' received invalid response, missing signer fingerprint", command));
45 const std::string fingerprintStr = fingerprint.
get_str();
47 bool duplicate =
false;
49 if (signer.m_fingerprint.compare(fingerprintStr) == 0) duplicate =
true;
52 std::string
name =
"";
79 auto matches_signer_fingerprint = [&](
const PSBTInput& input) {
80 for (
const auto& entry : input.hd_keypaths) {
86 if (!std::any_of(psbtx.inputs.begin(), psbtx.inputs.end(), matches_signer_fingerprint)) {
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;
UniValue DisplayAddress(const std::string &descriptor) const
Display address on the device.
std::string m_chain
Bitcoin mainnet, testnet, etc.
UniValue RunCommandParseJSON(const std::string &str_command, const std::string &str_std_in)
Execute a command which returns JSON, and parse the result.
static bool Enumerate(const std::string &command, std::vector< ExternalSigner > &signers, const std::string chain)
Obtain a list of signers.
static uint32_t ReadBE32(const unsigned char *ptr)
std::string EncodeBase64(Span< const unsigned char > input)
bool DecodeBase64PSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
const std::string & get_str() const
bool SignTransaction(PartiallySignedTransaction &psbt, std::string &error)
Sign PartiallySignedTransaction on the device.
UniValue GetDescriptors(const int account)
Get receive and change Descriptor(s) from device for a given account.
ExternalSigner(const std::string &command, const std::string chain, const std::string &fingerprint, const std::string name)
Enables interaction with an external signing device or service, such as a hardware wallet.
const std::string & getValStr() const
A version of CTransaction with the PSBT format.
std::string m_command
The command which handles interaction with the external signer.
const std::vector< UniValue > & getValues() const
Double ended buffer combining vector and stream-like interfaces.
const std::string NetworkArg() const
const UniValue & find_value(const UniValue &obj, const std::string &name)
bool error(const char *fmt, const Args &... args)
std::string m_fingerprint
Master key fingerprint of the signer.
static const int PROTOCOL_VERSION
network protocol versioning