5#include <chainparams.h>
32 error =
_(
"Error: Keypool ran out, please call keypoolrefill first")
51enum class IsMineSigVersion {
61enum class IsMineResult {
68bool HaveKeys(
const std::vector<valtype> &pubkeys,
70 for (
const valtype &pubkey : pubkeys) {
92 IsMineResult
ret = IsMineResult::NO;
105 ret = std::max(
ret, IsMineResult::SPENDABLE);
111 ret = std::max(
ret, IsMineResult::SPENDABLE);
117 return IsMineResult::INVALID;
124 IsMineSigVersion::P2SH)
125 : IsMineResult::SPENDABLE);
141 std::vector<valtype> keys(
vSolutions.begin() + 1,
145 ret = std::max(
ret, IsMineResult::SPENDABLE);
151 if (
ret == IsMineResult::NO &&
keystore.HaveWatchOnly(scriptPubKey)) {
152 ret = std::max(
ret, IsMineResult::WATCH_ONLY);
160 switch (
IsMineInner(*
this, script, IsMineSigVersion::TOP)) {
161 case IsMineResult::INVALID:
162 case IsMineResult::NO:
164 case IsMineResult::WATCH_ONLY:
166 case IsMineResult::SPENDABLE:
184 const CPubKey &vchPubKey = (*mi).second.first;
201 LogPrintf(
"The wallet is probably corrupted: Some keys decrypt but "
203 throw std::runtime_error(
204 "Error unlocking wallet: some keys decrypt but not all. Your "
205 "wallet file may be corrupt.");
312 std::map<CKeyID, int64_t>::const_iterator
mi =
316 "keys up to this key as used\n",
322 "%s: Topping up keypool failed (locked wallet)\n",
333 if (!
meta.hd_seed_id.IsNull() &&
361 if (!
meta.hd_seed_id.IsNull() && !
meta.has_key_origin &&
362 meta.hdKeypath !=
"s") {
370 meta.key_origin.fingerprint);
372 throw std::runtime_error(
"Invalid stored hdKeypath");
374 meta.has_key_origin =
true;
382 batch->WriteKeyMetadata(
meta, pubkey,
true);
446 error =
_(
"Unable to generate keys");
477 throw std::runtime_error(std::string(
__func__) +
478 ": read oldest key in keypool failed");
521std::unique_ptr<SigningProvider>
523 return std::make_unique<LegacySigningProvider>(*
this);
530 if (
ismine == IsMineResult::SPENDABLE ||
531 ismine == IsMineResult::WATCH_ONLY) {
576 for (
size_t i = 0; i <
psbtx.tx->vin.size(); ++i) {
601 for (
size_t i = 0; i <
psbtx.tx->vout.size(); ++i) {
609std::unique_ptr<CKeyMetadata>
617 return std::make_unique<CKeyMetadata>(it->second);
624 return std::make_unique<CKeyMetadata>(it->second);
640 if (nCreateTime <= 1) {
716 "of size %i which exceeds maximum size %i thus can "
717 "never be redeemed. Do not use address %s.\n",
755 return EncryptSecret(encryption_key, vchSecret,
756 pubkey.GetHash(), vchCryptedSecret);
815 std::vector<std::vector<uint8_t>>
solutions;
852 const CScript &dest) {
894 throw std::runtime_error(std::string(
__func__) +
895 ": writing chain failed");
928 const CPubKey &vchPubKey = (*mi).second.first;
949 if (
meta.has_key_origin) {
950 std::copy(
meta.key_origin.fingerprint,
meta.key_origin.fingerprint + 4,
963 WatchKeyMap::const_iterator it =
mapWatchKeys.find(address);
1013 secret.MakeNewKey(fCompressed);
1028 throw std::runtime_error(std::string(
__func__) +
": AddKey failed");
1052 throw std::runtime_error(std::string(
__func__) +
": seed not found");
1104 throw std::runtime_error(std::string(
__func__) +
1105 ": writing HD chain model failed");
1114 }
else if (
keypool.fInternal) {
1165 throw std::runtime_error(std::string(
__func__) +
1166 ": AddKeyPubKey failed");
1219 WalletLogPrintf(
"LegacyScriptPubKeyMan::NewKeyPool rewrote keypool\n");
1267 "keypool added %d keys (%d internal), size=%u (%u internal)\n",
1286 throw std::runtime_error(std::string(
__func__) +
1287 ": writing imported pubkey failed");
1386 throw std::runtime_error(std::string(
__func__) +
": read failed");
1390 throw std::runtime_error(std::string(
__func__) +
1391 ": unknown key in key pool");
1395 throw std::runtime_error(std::string(
__func__) +
1396 ": keypool entry misclassified");
1398 if (!
keypool.vchPubKey.IsValid()) {
1399 throw std::runtime_error(std::string(
__func__) +
1400 ": keypool entry invalid");
1457 std::vector<CScript> dummy;
1461 std::vector<CKeyID>
ret;
1462 for (
const auto &entry : out.
pubkeys) {
1463 ret.push_back(entry.first);
1475 throw std::runtime_error(std::string(
__func__) +
1476 ": read keypool entry failed");
1480 throw std::runtime_error(std::string(
__func__) +
1481 ": writing modified keypool entry failed");
1520 for (
const auto &entry : scripts) {
1546 const CKey &key = entry.second;
1548 const CKeyID &
id = entry.first;
1569 const std::map<
CKeyID, std::pair<CPubKey, KeyOriginInfo>> &key_origins,
1572 for (
const auto &entry : key_origins) {
1580 const CPubKey &pubkey = entry->second;
1634 std::string &
error) {
1639 error =
"No addresses available";
1650 throw std::runtime_error(std::string(
__func__) +
1651 ": Types are inconsistent");
1661 error =
"Error: Keypool ran out, please call keypoolrefill first";
1668 error =
"Error: Keypool ran out, please call keypoolrefill first";
1677 throw std::runtime_error(
1679 ": Types are inconsistent. Stored type does not match type of "
1680 "newly generated address");
1708 const CPubKey &pubkey =
mi.second.first;
1721 LogPrintf(
"The wallet is probably corrupted: Some keys decrypt but not "
1723 throw std::runtime_error(
1724 "Error unlocking wallet: some keys decrypt but not all. Your "
1725 "wallet file may be corrupt.");
1794 keys[pubkey.
GetID()] = key;
1863 throw std::runtime_error(
1865 ": New cached parent xpub does not match already "
1866 "cached parent xpub");
1872 throw std::runtime_error(std::string(
__func__) +
1873 ": writing cache item failed");
1886 throw std::runtime_error(
1888 ": New cached derived xpub does not match already "
1889 "cached derived xpub");
1896 throw std::runtime_error(std::string(
__func__) +
1897 ": writing cache item failed");
1922 "mark all keypool items up to this item as used\n",
1938 throw std::runtime_error(std::string(
__func__) +
1939 ": writing descriptor private key failed");
1964 return EncryptSecret(encryption_key, secret,
1965 pubkey.GetHash(), crypted_secret);
2024 throw std::runtime_error(
2026 ": writing descriptor master private key failed");
2029 throw std::runtime_error(std::string(
__func__) +
2030 ": writing descriptor failed");
2085std::unique_ptr<FlatSigningProvider>
2100std::unique_ptr<FlatSigningProvider>
2116std::unique_ptr<FlatSigningProvider>
2121 std::unique_ptr<FlatSigningProvider>
out_keys =
2122 std::make_unique<FlatSigningProvider>();
2139std::unique_ptr<SigningProvider>
2152 std::unique_ptr<FlatSigningProvider> keys =
2153 std::make_unique<FlatSigningProvider>();
2155 std::unique_ptr<FlatSigningProvider>
coin_keys =
2170 std::unique_ptr<FlatSigningProvider> keys =
2191 for (
size_t i = 0; i <
psbtx.tx->vin.size(); ++i) {
2215 std::unique_ptr<FlatSigningProvider> keys =
2216 std::make_unique<FlatSigningProvider>();
2217 std::unique_ptr<FlatSigningProvider>
script_keys =
2223 script_keys = std::make_unique<FlatSigningProvider>();
2226 std::unique_ptr<FlatSigningProvider>
pk_keys =
2235 psbtx, i, sighash_type);
2240 for (
size_t i = 0; i <
psbtx.tx->vout.size(); ++i) {
2241 std::unique_ptr<SigningProvider> keys =
2253std::unique_ptr<CKeyMetadata>
2255 std::unique_ptr<SigningProvider> provider =
2262 std::unique_ptr<CKeyMetadata>
meta =
2263 std::make_unique<CKeyMetadata>();
2265 meta->has_key_origin =
true;
2296 throw std::runtime_error(
2297 "Error: Unable to expand wallet descriptor from cache");
2302 throw std::runtime_error(
2303 strprintf(
"Error: Already loaded script at index %d as "
2304 "being at index %d",
2346 desc.descriptor !=
nullptr &&
2348 desc.descriptor->ToString();
2355 throw std::runtime_error(std::string(
__func__) +
2356 ": writing descriptor failed");
2380 throw std::runtime_error(std::string(
__func__) +
": " +
error);
2393 error =
"can only update matching descriptor";
2400 error =
strprintf(
"new range must include current range = [%d,%d]",
@ TOP
Top-level scriptPubKey.
bool ParseHDKeypath(const std::string &keypath_str, std::vector< uint32_t > &keypath)
Parse an HD keypaths like "m/7/0'/2000".
std::string WriteHDKeypath(const std::vector< uint32_t > &keypath)
Write HD keypaths as strings.
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
bool IsTestChain() const
If this chain is exclusively used for testing.
static const int VERSION_HD_BASE
uint32_t nInternalChainCounter
CKeyID seed_id
seed hash160
static const int VERSION_HD_CHAIN_SPLIT
uint32_t nExternalChainCounter
An encapsulated secp256k1 private key.
const uint8_t * begin() const
CPrivKey GetPrivKey() const
Convert the private key to a CPrivKey (serialized OpenSSL private key data).
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
CPubKey GetPubKey() const
Compute the public key from a private key.
bool VerifyPubKey(const CPubKey &vchPubKey) const
Verify thoroughly whether a private key and a public key match.
const uint8_t * end() const
A reference to a CKey: the Hash160 of its serialized public key.
A key from a CWallet's keypool.
A mutable version of CTransaction.
An encapsulated public key.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
uint256 GetHash() const
Get the 256-bit hash of this public key.
A hasher class for SHA-256.
CSHA256 & Write(const uint8_t *data, size_t len)
void Finalize(uint8_t hash[OUTPUT_SIZE])
Serialized script, used inside transaction inputs and outputs.
A reference to a CScript: the Hash160 of its serialization (see script.h)
Cache for single descriptor's derived extended pubkeys.
int64_t GetOldestKeyPoolTime() const override
void ReturnDestination(int64_t index, bool internal, const CTxDestination &addr) override
bool AddKey(const CKeyID &key_id, const CKey &key)
void MarkUnusedAddresses(const CScript &script) override
Mark unused addresses as being used.
bool HavePrivateKeys() const override
bool AddCryptedKey(const CKeyID &key_id, const CPubKey &pubkey, const std::vector< uint8_t > &crypted_key)
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const override
Sign a message with the given script.
bool CanUpdateToWalletDescriptor(const WalletDescriptor &descriptor, std::string &error)
TransactionError FillPSBT(PartiallySignedTransaction &psbt, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=false) const override
Adds script and derivation path information to a PSBT, and optionally signs it.
bool TopUp(unsigned int size=0) override
Fills internal address pool.
void SetInternal(bool internal) override
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const override
bool HasWalletDescriptor(const WalletDescriptor &desc) const
int64_t GetTimeFirstKey() const override
bool CanProvide(const CScript &script, SignatureData &sigdata) override
Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that,...
bool GetReservedDestination(const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool) override
bool GetNewDestination(const OutputType type, CTxDestination &dest, std::string &error) override
RecursiveMutex cs_desc_man
unsigned int GetKeyPoolSize() const override
bool SetupDescriptorGeneration(const CExtKey &master_key, OutputType addr_type)
Setup descriptors based on the given CExtkey.
void AddDescriptorKey(const CKey &key, const CPubKey &pubkey)
std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const override
size_t KeypoolCountExternalKeys() const override
int32_t m_max_cached_index
bool SignTransaction(CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, SigHashType sighash, std::map< int, std::string > &input_errors) const override
Creates new signatures and adds them to the transaction.
bool m_decryption_thoroughly_checked
keeps track of whether Unlock has run a thorough check before
KeyMap GetKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
std::unique_ptr< FlatSigningProvider > GetSigningProvider(const CScript &script, bool include_private=false) const
const std::vector< CScript > GetScriptPubKeys() const
std::map< CKeyID, CKey > KeyMap
bool Encrypt(const CKeyingMaterial &master_key, WalletBatch *batch) override
bool AddDescriptorKeyWithDB(WalletBatch &batch, const CKey &key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
void UpdateWalletDescriptor(WalletDescriptor &descriptor)
void SetCache(const DescriptorCache &cache)
uint256 GetID() const override
const WalletDescriptor GetWalletDescriptor() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
isminetype IsMine(const CScript &script) const override
bool CheckDecryptionKey(const CKeyingMaterial &master_key, bool accept_no_keys=false) override
Check that the given decryption key is valid for this ScriptPubKeyMan, i.e.
bool IsHDEnabled() const override
bool CanGetAddresses(bool internal=false) const override
Returns true if the wallet can give out new addresses.
virtual bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey)
virtual bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
virtual bool GetKey(const CKeyID &address, CKey &keyOut) const override
virtual bool AddCScript(const CScript &redeemScript)
virtual std::set< CKeyID > GetKeys() const
std::map< CKeyID, CKey > KeyMap
virtual bool HaveCScript(const CScriptID &hash) const override
RecursiveMutex cs_KeyStore
virtual bool HaveKey(const CKeyID &address) const override
bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override
std::map< int64_t, CKeyID > m_index_to_reserved_key
void UpgradeKeyMetadata()
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
bool AddCryptedKeyInner(const CPubKey &vchPubKey, const std::vector< uint8_t > &vchCryptedSecret)
bool fDecryptionThoroughlyChecked
keeps track of whether Unlock has run a thorough check before
int64_t GetOldestKeyPoolTime() const override
bool GetReservedDestination(const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool) override
uint256 GetID() const override
bool LoadWatchOnly(const CScript &dest)
Adds a watch-only address to the store, without saving it to disk (used by LoadWallet)
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const override
void MarkUnusedAddresses(const CScript &script) override
Mark unused addresses as being used.
bool HaveWatchOnly() const
Returns whether there are any watch-only things in the wallet.
bool RemoveWatchOnly(const CScript &dest)
Remove a watch only script from the keystore.
bool GetNewDestination(const OutputType type, CTxDestination &dest, std::string &error) override
bool AddWatchOnlyInMem(const CScript &dest)
void UpdateTimeFirstKey(int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Update wallet first key creation time.
void AddKeypoolPubkeyWithDB(const CPubKey &pubkey, const bool internal, WalletBatch &batch)
size_t KeypoolCountExternalKeys() const override
void ReturnDestination(int64_t index, bool internal, const CTxDestination &) override
void SetHDSeed(const CPubKey &key)
bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector< uint8_t > &vchCryptedSecret, bool checksum_valid)
Adds an encrypted key to the store, without saving it to disk (used by LoadWallet)
std::unordered_map< CKeyID, CHDChain, SaltedSipHasher > m_inactive_hd_chains
bool GetKey(const CKeyID &address, CKey &keyOut) const override
void LearnAllRelatedScripts(const CPubKey &key)
Same as LearnRelatedScripts, but when the OutputType is not known (and could be anything).
bool Encrypt(const CKeyingMaterial &master_key, WalletBatch *batch) override
isminetype IsMine(const CScript &script) const override
bool ImportScripts(const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const override
bool HaveKey(const CKeyID &address) const override
bool ImportPrivKeys(const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
bool TopUpInactiveHDChain(const CKeyID seed_id, int64_t index, bool internal)
Like TopUp() but adds keys for inactive HD chains.
bool CanGetAddresses(bool internal=false) const override
Returns true if the wallet can give out new addresses.
bool AddKeyPubKeyInner(const CKey &key, const CPubKey &pubkey)
void AddHDChain(const CHDChain &chain)
Set the HD chain model (chain child index counters) and writes it to the database.
bool CheckDecryptionKey(const CKeyingMaterial &master_key, bool accept_no_keys=false) override
Check that the given decryption key is valid for this ScriptPubKeyMan, i.e.
bool CanGenerateKeys() const
void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool)
Load a keypool entry.
bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector< uint8_t > &vchCryptedSecret)
Adds an encrypted key to the store, and saves it to disk.
bool Upgrade(int prev_version, bilingual_str &error) override
Upgrades the wallet to the specified version.
bool IsHDEnabled() const override
bool AddWatchOnlyWithDB(WalletBatch &batch, const CScript &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
bool LoadKey(const CKey &key, const CPubKey &pubkey)
Adds a key to the store, without saving it to disk (used by LoadWallet)
bool ImportPubKeys(const std::vector< CKeyID > &ordered_pubkeys, const std::map< CKeyID, CPubKey > &pubkey_map, const std::map< CKeyID, std::pair< CPubKey, KeyOriginInfo > > &key_origins, const bool add_keypool, const bool internal, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
bool AddKeyOriginWithDB(WalletBatch &batch, const CPubKey &pubkey, const KeyOriginInfo &info)
Add a KeyOriginInfo to the wallet.
bool AddWatchOnly(const CScript &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Private version of AddWatchOnly method which does not accept a timestamp, and which will reset the wa...
bool TopUp(unsigned int size=0) override
Fills internal address pool.
void LoadKeyMetadata(const CKeyID &keyID, const CKeyMetadata &metadata)
Load metadata (used by LoadWallet)
void MarkReserveKeysAsUsed(int64_t keypool_id) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Marks all keys in the keypool up to and including reserve_key as used.
void LoadHDChain(const CHDChain &chain)
Load a HD chain model (used by LoadWallet)
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
void AddInactiveHDChain(const CHDChain &chain)
bool GetWatchPubKey(const CKeyID &address, CPubKey &pubkey_out) const
Fetches a pubkey from mapWatchKeys if it exists there.
TransactionError FillPSBT(PartiallySignedTransaction &psbt, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=false) const override
Adds script and derivation path information to a PSBT, and optionally signs it.
void LearnRelatedScripts(const CPubKey &key, OutputType)
Explicitly make the wallet learn the related scripts for outputs to the given key.
bool NewKeyPool()
Mark old keypool keys as used, and generate all new keys.
bool ReserveKeyFromKeyPool(int64_t &nIndex, CKeyPool &keypool, bool fRequestedInternal)
Reserves a key from the keypool and sets nIndex to its index.
std::set< CKeyID > GetKeys() const override
void KeepDestination(int64_t index, const OutputType &type) override
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override
Adds a key to the store, and saves it to disk.
CPubKey GenerateNewKey(WalletBatch &batch, CHDChain &hd_chain, bool internal=false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Generate a new key.
void MarkPreSplitKeys() EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
unsigned int GetKeyPoolSize() const override
bool HavePrivateKeys() const override
void SetInternal(bool internal) override
bool SetupGeneration(bool force=false) override
Sets up the key generation stuff, i.e.
CPubKey GenerateNewSeed()
bool ImportScriptPubKeys(const std::set< CScript > &script_pub_keys, const bool have_solving_data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
bool AddKeyPubKeyWithDB(WalletBatch &batch, const CKey &key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Adds a key to the store, and saves it to disk.
void RewriteDB() override
The action to do when the DB needs rewrite.
CPubKey DeriveNewSeed(const CKey &key)
bool CanProvide(const CScript &script, SignatureData &sigdata) override
Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that,...
int64_t GetTimeFirstKey() const override
bool SignTransaction(CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, SigHashType sighash, std::map< int, std::string > &input_errors) const override
Creates new signatures and adds them to the transaction.
void LoadScriptMetadata(const CScriptID &script_id, const CKeyMetadata &metadata)
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const override
Sign a message with the given script.
bool LoadCScript(const CScript &redeemScript)
Adds a CScript to the store.
bool AddCScript(const CScript &redeemScript) override
bool AddCScriptWithDB(WalletBatch &batch, const CScript &script)
Adds a script to the store and saves it to disk.
std::map< CKeyID, int64_t > m_pool_key_to_index
bool GetKeyFromPool(CPubKey &key, const OutputType type, bool internal=false)
Fetches a key from the keypool.
void DeriveNewChildKey(WalletBatch &batch, CKeyMetadata &metadata, CKey &secret, CHDChain &hd_chain, bool internal=false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
WalletStorage & m_storage
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
void WalletLogPrintf(std::string fmt, Params... parameters) const
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases.
Signature hash type wrapper class.
uint32_t getRawSigHashType() const
An interface to be implemented by keystores that support signing.
Access to the wallet database.
bool WriteDescriptor(const uint256 &desc_id, const WalletDescriptor &descriptor)
bool WriteDescriptorDerivedCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index, uint32_t der_index)
bool ErasePool(int64_t nPool)
bool WriteDescriptorParentCache(const CExtPubKey &xpub, const uint256 &desc_id, uint32_t key_exp_index)
bool WriteCScript(const uint160 &hash, const CScript &redeemScript)
bool EraseWatchOnly(const CScript &script)
bool WriteDescriptorKey(const uint256 &desc_id, const CPubKey &pubkey, const CPrivKey &privkey)
bool ReadPool(int64_t nPool, CKeyPool &keypool)
bool WriteKey(const CPubKey &vchPubKey, const CPrivKey &vchPrivKey, const CKeyMetadata &keyMeta)
bool WriteHDChain(const CHDChain &chain)
write the hdchain model (external chain child index counter)
bool WriteKeyMetadata(const CKeyMetadata &meta, const CPubKey &pubkey, const bool overwrite)
bool WriteWatchOnly(const CScript &script, const CKeyMetadata &keymeta)
bool WritePool(int64_t nPool, const CKeyPool &keypool)
bool WriteCryptedKey(const CPubKey &vchPubKey, const std::vector< uint8_t > &vchCryptedSecret, const CKeyMetadata &keyMeta)
bool WriteCryptedDescriptorKey(const uint256 &desc_id, const CPubKey &pubkey, const std::vector< uint8_t > &secret)
Descriptor with some wallet metadata.
virtual bool IsWalletFlagSet(uint64_t) const =0
virtual bool HasEncryptionKeys() const =0
virtual bool WithEncryptionKey(const std::function< bool(const CKeyingMaterial &)> &cb) const =0
Pass the encryption key to cb().
virtual WalletDatabase & GetDatabase()=0
virtual bool IsLocked() const =0
virtual void UnsetBlankWalletFlag(WalletBatch &)=0
virtual void SetMinVersion(enum WalletFeature, WalletBatch *=nullptr, bool=false)=0
virtual const CChainParams & GetChainParams() const =0
virtual bool CanSupportFeature(enum WalletFeature) const =0
static UniValue Parse(std::string_view raw)
Parse string to UniValue or throw runtime_error if string contains invalid JSON.
const Config & GetConfig()
bool DecryptKey(const CKeyingMaterial &vMasterKey, const std::vector< uint8_t > &vchCryptedSecret, const CPubKey &vchPubKey, CKey &key)
bool EncryptSecret(const CKeyingMaterial &vMasterKey, const CKeyingMaterial &vchPlaintext, const uint256 &nIV, std::vector< uint8_t > &vchCiphertext)
std::vector< uint8_t, secure_allocator< uint8_t > > CKeyingMaterial
std::unique_ptr< Descriptor > InferDescriptor(const CScript &script, const SigningProvider &provider)
Find a descriptor for the specified script, using information from provider where possible.
uint160 Hash160(const T1 &in1)
Compute the 160-bit hash an object.
isminetype
IsMine() return codes.
std::string EncodeDestination(const CTxDestination &dest, const Config &config)
std::string EncodeExtPubKey(const CExtPubKey &key)
bool error(const char *fmt, const Args &...args)
bool MessageSign(const CKey &privkey, const std::string &message, std::string &signature)
Sign a message.
@ PRIVATE_KEY_NOT_AVAILABLE
CTxDestination GetDestinationForKey(const CPubKey &key, OutputType type)
Get a destination of the requested type (if possible) to the specified key.
void UpdatePSBTOutput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
Updates a PSBTOutput with information from provider.
bool PSBTInputSigned(const PSBTInput &input)
Checks whether a PSBTInput is already signed.
bool SignPSBTInput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, SigHashType sighash, SignatureData *out_sigdata, bool use_dummy)
Signs a PSBTInput, verifying that all provided data matches what is being signed.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE
std::vector< uint8_t > valtype
static bool ExtractPubKey(const CScript &dest, CPubKey &pubKeyOut)
std::vector< CKeyID > GetAffectedKeys(const CScript &spk, const SigningProvider &provider)
const uint32_t BIP32_HARDENED_KEY_LIMIT
Value for the first BIP 32 hardened derivation.
static int64_t GetOldestKeyTimeInPool(const std::set< int64_t > &setKeyPool, WalletBatch &batch)
static const unsigned int DEFAULT_KEYPOOL_SIZE
Default for -keypool.
std::vector< CKeyID > GetAffectedKeys(const CScript &spk, const SigningProvider &provider)
static std::string ToString(const CService &ip)
std::vector< uint8_t > valtype
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
const BaseSignatureCreator & DUMMY_SIGNATURE_CREATOR
A signature creator that just produces 71-byte empty signatures.
const SigningProvider & DUMMY_SIGNING_PROVIDER
FlatSigningProvider Merge(const FlatSigningProvider &a, const FlatSigningProvider &b)
CKeyID GetKeyForDestination(const SigningProvider &store, const CTxDestination &dest)
Return the CKeyID of the key involved in a script (if there is a unique one).
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< uint8_t > > &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
CKeyID ToKeyID(const PKHash &key_hash)
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
bool Derive(CExtKey &out, unsigned int nChild) const
void SetSeed(Span< const std::byte > seed)
std::map< CKeyID, CPubKey > pubkeys
std::map< CKeyID, CKey > keys
std::vector< uint32_t > path
uint8_t fingerprint[4]
First 32 bits of the Hash160 of the public key at the root of the path.
A version of CTransaction with the PSBT format.
std::map< CKeyID, SigPair > signatures
BIP 174 style partial signatures for the input.
#define AssertLockHeld(cs)
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
bilingual_str _(const char *psz)
Translation function.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
@ WALLET_FLAG_KEY_ORIGIN_METADATA
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
@ WALLET_FLAG_BLANK_WALLET
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses,...
@ FEATURE_PRE_SPLIT_KEYPOOL