Return used destinations from ScriptPubKeyMan::MarkUnusedAddresses

This commit is contained in:
S3RK
2021-09-08 10:00:18 +02:00
parent 03840c2064
commit c1b99c088c
2 changed files with 53 additions and 11 deletions

View File

@@ -148,6 +148,12 @@ public:
}
};
struct WalletDestination
{
CTxDestination dest;
std::optional<bool> internal;
};
/*
* A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet.
* It contains the scripts and keys related to the scriptPubKeys it manages.
@@ -180,8 +186,14 @@ public:
*/
virtual bool TopUp(unsigned int size = 0) { return false; }
//! Mark unused addresses as being used
virtual void MarkUnusedAddresses(const CScript& script) {}
/** Mark unused addresses as being used
* Affects all keys up to and including the one determined by provided script.
*
* @param script determines the last key to mark as used
*
* @return All of the addresses affected
*/
virtual std::vector<WalletDestination> MarkUnusedAddresses(const CScript& script) { return {}; }
/** Sets up the key generation stuff, i.e. generates new HD seeds and sets them as active.
* Returns false if already setup or setup fails, true if setup is successful
@@ -356,7 +368,7 @@ public:
bool TopUp(unsigned int size = 0) override;
void MarkUnusedAddresses(const CScript& script) override;
std::vector<WalletDestination> MarkUnusedAddresses(const CScript& script) override;
//! Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo
void UpgradeKeyMetadata();
@@ -481,9 +493,13 @@ public:
void LearnAllRelatedScripts(const CPubKey& key);
/**
* Marks all keys in the keypool up to and including reserve_key as used.
* Marks all keys in the keypool up to and including the provided key as used.
*
* @param keypool_id determines the last key to mark as used
*
* @return All affected keys
*/
void MarkReserveKeysAsUsed(int64_t keypool_id) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
std::vector<CKeyPool> MarkReserveKeysAsUsed(int64_t keypool_id) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore);
const std::map<CKeyID, int64_t>& GetAllReserveKeys() const { return m_pool_key_to_index; }
std::set<CKeyID> GetKeys() const override;
@@ -563,7 +579,7 @@ public:
// (with or without private keys), the "keypool" is a single xpub.
bool TopUp(unsigned int size = 0) override;
void MarkUnusedAddresses(const CScript& script) override;
std::vector<WalletDestination> MarkUnusedAddresses(const CScript& script) override;
bool IsHDEnabled() const override;