5#include <chainparams.h>
30 int64_t creation_time =
GetTime();
34 m_wallet_descriptor = w_desc;
38 throw std::runtime_error(std::string(__func__) +
": writing descriptor failed");
50 if (
command ==
"")
throw std::runtime_error(std::string(__func__) +
": restart bitcoind with -signer=<cmd>");
51 std::vector<ExternalSigner> signers;
53 if (signers.empty())
throw std::runtime_error(std::string(__func__) +
": No external signers found");
55 if (signers.size() > 1)
throw std::runtime_error(std::string(__func__) +
": More than one external signer found. Please connect only one at a time.");
66 const UniValue& result =
signer.DisplayAddress(descriptor->ToString());
90 for (
const auto& input : psbt.
inputs) {
94 if (complete)
return {};
96 std::string strFailReason;
98 tfm::format(std::cerr,
"Failed to sign: %s\n", strFailReason);
99 return PSBTError::EXTERNAL_SIGNER_FAILED;
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
const CChainParams & Params()
Return the currently selected parameters.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Serialized script, used inside transaction inputs and outputs.
Enables interaction with an external signing device or service, such as a hardware wallet.
static bool Enumerate(const std::string &command, std::vector< ExternalSigner > &signers, const std::string chain)
Obtain a list of signers.
const UniValue & find_value(std::string_view key) const
const std::string & getValStr() const
std::optional< common::PSBTError > FillPSBT(PartiallySignedTransaction &psbt, const PrecomputedTransactionData &txdata, int sighash_type=SIGHASH_DEFAULT, bool sign=true, bool bip32derivs=false, int *n_signed=nullptr, bool finalize=true) const override
Adds script and derivation path information to a PSBT, and optionally signs it.
bool SignTransaction(CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, int sighash, std::map< int, bilingual_str > &input_errors) const override
Creates new signatures and adds them to the transaction.
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const override
bool TopUpWithDB(WalletBatch &batch, unsigned int size=0)
Same as 'TopUp' but designed for use within a batch transaction context.
RecursiveMutex cs_desc_man
uint256 GetID() const override
bool SetupDescriptor(WalletBatch &batch, std::unique_ptr< Descriptor >desc)
Provide a descriptor at setup time Returns false if already setup or setup fails, true if setup is su...
std::optional< common::PSBTError > FillPSBT(PartiallySignedTransaction &psbt, const PrecomputedTransactionData &txdata, int sighash_type=1, bool sign=true, bool bip32derivs=false, int *n_signed=nullptr, bool finalize=true) const override
Adds script and derivation path information to a PSBT, and optionally signs it.
static ExternalSigner GetExternalSigner()
util::Result< void > DisplayAddress(const CTxDestination &dest, const ExternalSigner &signer) const
Display address on the device and verify that the returned value matches.
WalletStorage & m_storage
Access to the wallet database.
bool WriteDescriptor(const uint256 &desc_id, const WalletDescriptor &descriptor)
Descriptor with some wallet metadata.
virtual bool IsWalletFlagSet(uint64_t) const =0
virtual void UnsetBlankWalletFlag(WalletBatch &)=0
std::string EncodeDestination(const CTxDestination &dest)
static int sign(const secp256k1_context *ctx, struct signer_secrets *signer_secrets, struct signer *signer, const secp256k1_musig_keyagg_cache *cache, const unsigned char *msg32, unsigned char *sig64)
@ WALLET_FLAG_EXTERNAL_SIGNER
Indicates that the wallet needs an external signer.
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
is a home for public enum and struct type definitions that are used by internally by node code,...
bool PSBTInputSigned(const PSBTInput &input)
Checks whether a PSBTInput is already signed by checking for non-null finalized fields.
bool FinalizePSBT(PartiallySignedTransaction &psbtx)
Finalizes a PSBT if possible, combining partial signatures.
std::unique_ptr< Descriptor > InferDescriptor(const CScript &script, const SigningProvider &provider)
Find a descriptor for the specified script, using information from provider where possible.
A version of CTransaction with the PSBT format.
std::vector< PSBTInput > inputs
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
bilingual_str _(ConstevalStringLiteral str)
Translation function.