31 throw std::runtime_error(
strprintf(
"'%s' received invalid response, expected array of signers",
command));
44 if (fingerprint.
isNull()) {
45 throw std::runtime_error(
strprintf(
"'%s' received invalid response, missing signer fingerprint",
command));
47 const std::string& fingerprintStr{fingerprint.
get_str()};
49 bool duplicate =
false;
51 if (
signer.m_fingerprint.compare(fingerprintStr) == 0) duplicate =
true;
59 signers.emplace_back(
command, chain, fingerprintStr,
name);
82 auto matches_signer_fingerprint = [&](
const PSBTInput& input) {
83 for (
const auto& entry : input.hd_keypaths) {
84 if (std::ranges::equal(parsed_m_fingerprint, entry.second.fingerprint))
return true;
86 for (
const auto& entry : input.m_tap_bip32_paths) {
87 if (std::ranges::equal(parsed_m_fingerprint, entry.second.second.fingerprint))
return true;
92 if (!std::any_of(psbtx.
inputs.begin(), psbtx.
inputs.end(), matches_signer_fingerprint)) {
98 const std::string stdinStr =
"signtx " +
EncodeBase64(ssTx.str());
108 error =
"Unexpected result from signer";
113 std::string signer_psbt_error;
115 error =
strprintf(
"TX decode failed %s", signer_psbt_error);
119 psbtx = signer_psbtx;
Double ended buffer combining vector and stream-like interfaces.
Enables interaction with an external signing device or service, such as a hardware wallet.
std::string m_chain
Bitcoin mainnet, testnet, etc.
static bool Enumerate(const std::string &command, std::vector< ExternalSigner > &signers, const std::string &chain)
Obtain a list of signers.
UniValue DisplayAddress(const std::string &descriptor) const
Display address on the device.
bool SignTransaction(PartiallySignedTransaction &psbt, std::string &error)
Sign PartiallySignedTransaction on the device.
std::string NetworkArg() const
UniValue GetDescriptors(int account)
Get receive and change Descriptor(s) from device for a given account.
std::string m_fingerprint
Master key fingerprint of the signer.
std::string m_command
The command which handles interaction with the external signer.
ExternalSigner(std::string command, std::string chain, std::string fingerprint, std::string name)
const std::string & get_str() const
const UniValue & find_value(std::string_view key) const
const std::string & getValStr() const
const std::vector< UniValue > & getValues() const
bool DecodeBase64PSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
UniValue RunCommandParseJSON(const std::string &str_command, const std::string &str_std_in)
Execute a command which returns JSON, and parse the result.
std::vector< Byte > ParseHex(std::string_view hex_str)
Like TryParseHex, but returns an empty vector on invalid input.
A version of CTransaction with the PSBT format.
std::vector< PSBTInput > inputs
std::string EncodeBase64(std::span< const unsigned char > input)