wallet::LegacyDataSPKM

Manages the minimum data needed to load and migrate a legacy wallet.

Synopsis

Declared in <wallet/scriptpubkeyman.h>

class LegacyDataSPKM
    : public ScriptPubKeyMan
    , public FillableSigningProvider

Base Classes

NameDescription
ScriptPubKeyManA class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet. It contains the scripts and keys related to the scriptPubKeys it manages. A ScriptPubKeyMan will be able to give out scriptPubKeys to be used, as well as marking when a scriptPubKey has been used. It also handles when and how to store a scriptPubKey and its related scripts and keys, including encryption.
FillableSigningProviderFillable signing provider that keeps keys in an address->secret map

Member Functions

NameDescription
AddCScript [virtual]Add a redeem or witness script.
AddInactiveHDChain Stores an inactive HD chain, keyed by its seed id.
AddKey [virtual]Add a private key, deriving its public key.
AddKeyPubKey [virtual]Add a private key together with its public key.
CanGetAddresses [virtual]Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys
CanProvide [virtual]Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that, combined with sigdata, can produce solving data.
CheckDecryptionKey [virtual]Checks whether the given master key decrypts all keys handled by this spkm.
DeleteMuSig2Session [virtual]Delete the state stored for a MuSig2 signing session.
DeleteRecordsWithDB Delete the legacy wallet records from disk.
Encrypt [virtual]Encrypts this ScriptPubKeyMan's keys with the given master key, writing changes to the batch.
FillPSBT [virtual]Adds script and derivation path information to a PSBT, and optionally signs it.
GetAllMuSig2ParticipantPubkeys [virtual]Return all known MuSig2 aggregate pubkeys and their participants.
GetCScript Look up a script by its script id.
GetCScripts [virtual]Return the ids of all known scripts.
GetHDChain Returns the active HD chain model.
GetID [virtual]Returns the fixed identifier for the legacy spkm.
GetKey GetKey overloads
GetKeyByXOnly Look up a private key by any key id derived from an x-only pubkey.
GetKeyOrigin [virtual]Retrieves the key origin (derivation path and fingerprint) for the given key id.
GetKeyOriginByXOnly Look up key origin info by any key id derived from an x-only pubkey.
GetKeyPoolSize [virtual]Returns the number of keys currently available in the keypool.
GetKeys [virtual]Return the ids of all known private keys.
GetMetadata [virtual]Returns the key metadata for the given destination, or nullptr if none is known.
GetMuSig2ParticipantPubkeys [virtual]Return the MuSig2 participant pubkeys for an aggregate pubkey.
GetMuSig2SecNonce [virtual]Retrieve the MuSig2 secret nonce for a signing session.
GetNewDestination [virtual]Returns a new destination of the given output type, or an error if unsupported.
GetNotMineScriptPubKeys Retrieves scripts that were imported by bugs into the legacy spkm and are simply invalid, such as a sh(sh(pkh())) script, or not watched.
GetPubKey GetPubKey overloads
GetPubKeyByXOnly Look up a public key by any key id derived from an x-only pubkey.
GetReservedDestination [virtual]Reserves a destination from the keypool and returns it, keeping the reservation index.
GetScriptPubKeys [virtual]Returns the set of scriptPubKeys watched by this spkm.
GetSolvingProvider [virtual]Returns a SigningProvider able to solve the given script.
GetTaprootBuilder [virtual]Look up the Taproot builder for an output key.
GetTaprootSpendData [virtual]Look up the Taproot spend data for an output key.
GetTimeFirstKey [virtual]Returns the creation time of the earliest key, used as the wallet's birth time.
GetWatchPubKey Fetches a pubkey from mapWatchKeys if it exists there
HaveCScript Report whether a script with the given id is known.
HaveCryptedKeys [virtual]Returns whether this ScriptPubKeyMan holds any encrypted private keys.
HaveKey [virtual]Returns whether the private key for the given address is held.
HavePrivateKeys [virtual]Returns whether this ScriptPubKeyMan holds any unencrypted private keys.
HaveWatchOnly Returns whether the watch-only script is in the wallet
IsHDEnabled [virtual]Returns true if HD is enabled
IsMine [virtual]Returns whether the given script is owned by this ScriptPubKeyMan.
KeepDestination [virtual]Marks a previously reserved destination as used so it is not handed out again.
LoadCScript Adds a CScript to the store
LoadCryptedKey Adds an encrypted key to the store, without saving it to disk (used by LoadWallet)
LoadHDChain Load a HD chain model (used by LoadWallet)
LoadKey Adds a key to the store, without saving it to disk (used by LoadWallet)
LoadKeyMetadata [virtual]Load metadata (used by LoadWallet)
LoadScriptMetadata [virtual]Loads metadata for a watch-only script (used by LoadWallet).
LoadWatchOnly Adds a watch-only address to the store, without saving it to disk (used by LoadWallet)
MarkUnusedAddresses [virtual]Mark unused addresses as being used Affects all keys up to and including the one determined by provided script.
MigrateToDescriptor Get the DescriptorScriptPubKeyMans (with private keys) that have the same scriptPubKeys as this LegacyDataSPKM. Does not modify this LegacyDataSPKM.
ReturnDestination [virtual]Returns a previously reserved destination to the keypool for reuse.
SetMuSig2SecNonce [virtual]Store a MuSig2 secret nonce for a signing session.
SignMessage [virtual]Sign a message with the given script
SignTransaction [virtual]Creates new signatures and adds them to the transaction. Returns whether all inputs were signed
TopUp [virtual]Fills internal address pool. Use within ScriptPubKeyMan implementations should be used sparingly and only when something from the address pool is removed, excluding GetNewDestination and GetReservedDestination. External wallet code is primarily responsible for topping up prior to fetching new addresses
WalletLogPrintf Prepends the wallet name in logging output to ease debugging in multi-wallet use cases

Data Members

NameDescription
NotifyCanGetAddressesChanged Keypool has new keys
NotifyFirstKeyTimeChanged Birth time changed
cs_KeyStore Mutex guarding the key and script maps.
m_script_metadata Map from Script ID to key metadata (for watch-only keys).
mapKeyMetadata Map from Key ID to key metadata.

Using Declarations

NameDescription
LegacyDataSPKM Inherit the ScriptPubKeyMan constructors.

Protected Type Aliases

NameDescription
KeyMap Map of key id to private key.
ScriptMap Map of script id to script.

Protected Member Functions

NameDescription
ImplicitlyLearnRelatedKeyScripts Record the scripts implied by a public key without persisting them.

Protected Data Members

NameDescription
m_storage The wallet storage this ScriptPubKeyMan uses to persist and query wallet-wide state.
mapKeys Map of key id to unencrypted private keys known by the signing provider. Map may be empty if the provider has another source of keys, like an encrypted store.
mapScripts Map of script id to scripts known by the signing provider.

Non-Member Functions

NameDescription
::GetKeyForDestinationReturn the CKeyID of the key involved in a script (if there is a unique one).
::IsSegWitOutputCheck whether a scriptPubKey is known to be segwit.
::ProduceSignatureProduce a script signature using a generic signature creator.
::SignPSBTInputSigns a PSBTInput, verifying that all provided data matches what is being signed.
::UpdatePSBTOutputUpdates a PSBTOutput with information from provider.