[#wallet-ScriptPubKeyMan]
= xref:wallet.adoc[wallet]::ScriptPubKeyMan
:relfileprefix: ../
:mrdocs:

A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet&period; It contains the scripts and keys related to the scriptPubKeys it manages&period; A ScriptPubKeyMan will be able to give out scriptPubKeys to be used, as well as marking when a scriptPubKey has been used&period; It also handles when and how to store a scriptPubKey and its related scripts and keys, including encryption&period;

== Synopsis

Declared in `&lt;wallet&sol;scriptpubkeyman&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class ScriptPubKeyMan;
----

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:wallet/ScriptPubKeyMan/2constructor-0f.adoc[`ScriptPubKeyMan`]         [.small]#[constructor]#
| Constructors
| xref:wallet/ScriptPubKeyMan/2destructor.adoc[`&#126;ScriptPubKeyMan`] [.small]#[destructor]# [.small]#[virtual]#
| Destroys the ScriptPubKeyMan&period;
| xref:wallet/ScriptPubKeyMan/CanGetAddresses.adoc[`CanGetAddresses`]  [.small]#[virtual]#
| Returns true if the wallet can give out new addresses&period; This means it has keys in the keypool or can generate new keys
| xref:wallet/ScriptPubKeyMan/CanProvide.adoc[`CanProvide`]  [.small]#[virtual]#
| Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that, combined with sigdata, can produce solving data&period;
| xref:wallet/ScriptPubKeyMan/CheckDecryptionKey.adoc[`CheckDecryptionKey`]  [.small]#[virtual]#
| Check that the given decryption key is valid for this ScriptPubKeyMan, i&period;e&period; it decrypts all of the keys handled by it&period;
| xref:wallet/ScriptPubKeyMan/Encrypt.adoc[`Encrypt`]  [.small]#[virtual]#
| Encrypts this ScriptPubKeyMan&apos;s keys with the given master key, writing changes to the batch&period;
| xref:wallet/ScriptPubKeyMan/FillPSBT.adoc[`FillPSBT`]  [.small]#[virtual]#
| Adds script and derivation path information to a PSBT, and optionally signs it&period;
| xref:wallet/ScriptPubKeyMan/GetID.adoc[`GetID`]  [.small]#[virtual]#
| Returns a stable identifier for this ScriptPubKeyMan&period;
| xref:wallet/ScriptPubKeyMan/GetKeyPoolSize.adoc[`GetKeyPoolSize`]  [.small]#[virtual]#
| Returns the number of keys currently available in the keypool&period;
| xref:wallet/ScriptPubKeyMan/GetMetadata.adoc[`GetMetadata`]  [.small]#[virtual]#
| Returns the key metadata for the given destination, or nullptr if none is known&period;
| xref:wallet/ScriptPubKeyMan/GetNewDestination.adoc[`GetNewDestination`]  [.small]#[virtual]#
| Returns a new destination of the given output type, or an error if unsupported&period;
| xref:wallet/ScriptPubKeyMan/GetReservedDestination.adoc[`GetReservedDestination`]  [.small]#[virtual]#
| Reserves a destination from the keypool and returns it, keeping the reservation index&period;
| xref:wallet/ScriptPubKeyMan/GetScriptPubKeys.adoc[`GetScriptPubKeys`]  [.small]#[virtual]#
| Returns a set of all the scriptPubKeys that this ScriptPubKeyMan watches
| xref:wallet/ScriptPubKeyMan/GetSolvingProvider.adoc[`GetSolvingProvider`]  [.small]#[virtual]#
| Returns a SigningProvider able to solve the given script, or nullptr if none is available&period;
| xref:wallet/ScriptPubKeyMan/GetTimeFirstKey.adoc[`GetTimeFirstKey`]  [.small]#[virtual]#
| Returns the creation time of the earliest key, used as the wallet&apos;s birth time&period;
| xref:wallet/ScriptPubKeyMan/HaveCryptedKeys.adoc[`HaveCryptedKeys`]  [.small]#[virtual]#
| Returns whether this ScriptPubKeyMan holds any encrypted private keys&period;
| xref:wallet/ScriptPubKeyMan/HavePrivateKeys.adoc[`HavePrivateKeys`]  [.small]#[virtual]#
| Returns whether this ScriptPubKeyMan holds any unencrypted private keys&period;
| xref:wallet/ScriptPubKeyMan/IsHDEnabled.adoc[`IsHDEnabled`]  [.small]#[virtual]#
| Returns true if HD is enabled
| xref:wallet/ScriptPubKeyMan/IsMine.adoc[`IsMine`]  [.small]#[virtual]#
| Returns whether the given script is owned by this ScriptPubKeyMan&period;
| xref:wallet/ScriptPubKeyMan/KeepDestination.adoc[`KeepDestination`]  [.small]#[virtual]#
| Marks a previously reserved destination as used so it is not handed out again&period;
| xref:wallet/ScriptPubKeyMan/MarkUnusedAddresses.adoc[`MarkUnusedAddresses`]  [.small]#[virtual]#
| Mark unused addresses as being used Affects all keys up to and including the one determined by provided script&period;
| xref:wallet/ScriptPubKeyMan/ReturnDestination.adoc[`ReturnDestination`]  [.small]#[virtual]#
| Returns a previously reserved destination to the keypool for reuse&period;
| xref:wallet/ScriptPubKeyMan/SignMessage.adoc[`SignMessage`]  [.small]#[virtual]#
| Sign a message with the given script
| xref:wallet/ScriptPubKeyMan/SignTransaction.adoc[`SignTransaction`]  [.small]#[virtual]#
| Creates new signatures and adds them to the transaction&period; Returns whether all inputs were signed
| xref:wallet/ScriptPubKeyMan/TopUp.adoc[`TopUp`]  [.small]#[virtual]#
| Fills internal address pool&period; Use within ScriptPubKeyMan implementations should be used sparingly and only when something from the address pool is removed, excluding GetNewDestination and GetReservedDestination&period; External wallet code is primarily responsible for topping up prior to fetching new addresses
| xref:wallet/ScriptPubKeyMan/WalletLogPrintf.adoc[`WalletLogPrintf`] 
| Prepends the wallet name in logging output to ease debugging in multi&hyphen;wallet use cases
|===


== Data Members

[cols="1,4"]
|===
| Name| Description
| xref:wallet/ScriptPubKeyMan/NotifyCanGetAddressesChanged.adoc[`NotifyCanGetAddressesChanged`] 
| Keypool has new keys
| xref:wallet/ScriptPubKeyMan/NotifyFirstKeyTimeChanged.adoc[`NotifyFirstKeyTimeChanged`] 
| Birth time changed
|===


== Protected Data Members

[cols="1,4"]
|===
| Name| Description
| xref:wallet/ScriptPubKeyMan/m_storage.adoc[`m&lowbar;storage`] 
| The wallet storage this ScriptPubKeyMan uses to persist and query wallet&hyphen;wide state&period;
|===


== Derived Classes

[cols="1,4"]
|===
| Name| Description
| xref:wallet/DescriptorScriptPubKeyMan.adoc[`DescriptorScriptPubKeyMan`] 
| A ScriptPubKeyMan backed by a single output descriptor&period;
| xref:wallet/LegacyDataSPKM.adoc[`LegacyDataSPKM`] 
| Manages the minimum data needed to load and migrate a legacy wallet&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
