Bitcoin Core  0.18.99
P2P Digital Currency
Public Member Functions | Protected Attributes | List of all members
CReserveKey Class Reference

A wrapper to reserve a key from a wallet keypool. More...

#include <wallet.h>

Collaboration diagram for CReserveKey:
[legend]

Public Member Functions

 CReserveKey (CWallet *pwalletIn)
 Construct a CReserveKey object. This does NOT reserve a key from the keypool yet. More...
 
 CReserveKey (const CReserveKey &)=delete
 
CReserveKeyoperator= (const CReserveKey &)=delete
 
 ~CReserveKey ()
 Destructor. If a key has been reserved and not KeepKey'ed, it will be returned to the keypool. More...
 
bool GetReservedKey (CPubKey &pubkey, bool internal=false)
 Reserve a key from the keypool. More...
 
void ReturnKey ()
 Return a key to the keypool. More...
 
void KeepKey ()
 Keep the key. Do not return it to the keypool when this object goes out of scope. More...
 

Protected Attributes

CWalletpwallet
 The wallet to reserve the keypool key from. More...
 
int64_t nIndex {-1}
 The index of the key in the keypool. More...
 
CPubKey vchPubKey
 The public key. More...
 
bool fInternal {false}
 Whether this is from the internal (change output) keypool. More...
 

Detailed Description

A wrapper to reserve a key from a wallet keypool.

CReserveKey is used to reserve a key from the keypool. It is passed around during the CreateTransaction/CommitTransaction procedure.

Instantiating a CReserveKey does not reserve a keypool key. To do so, GetReservedKey() needs to be called on the object. Once a key has been reserved, call KeepKey() on the CReserveKey object to make sure it is not returned to the keypool. Call ReturnKey() to return the key to the keypool so it can be re-used (for example, if the key was used in a new transaction and that transaction was not completed and needed to be aborted).

If a key is reserved and KeepKey() is not called, then the key will be returned to the keypool when the CReserveObject goes out of scope.

Definition at line 272 of file wallet.h.

Constructor & Destructor Documentation

◆ CReserveKey() [1/2]

CReserveKey::CReserveKey ( CWallet pwalletIn)
inlineexplicit

Construct a CReserveKey object. This does NOT reserve a key from the keypool yet.

Definition at line 286 of file wallet.h.

◆ CReserveKey() [2/2]

CReserveKey::CReserveKey ( const CReserveKey )
delete

◆ ~CReserveKey()

CReserveKey::~CReserveKey ( )
inline

Destructor. If a key has been reserved and not KeepKey'ed, it will be returned to the keypool.

Definition at line 295 of file wallet.h.

Member Function Documentation

◆ operator=()

CReserveKey& CReserveKey::operator= ( const CReserveKey )
delete

Member Data Documentation

◆ fInternal

bool CReserveKey::fInternal {false}
protected

Whether this is from the internal (change output) keypool.

Definition at line 282 of file wallet.h.

◆ nIndex

int64_t CReserveKey::nIndex {-1}
protected

The index of the key in the keypool.

Definition at line 278 of file wallet.h.

◆ pwallet

CWallet* CReserveKey::pwallet
protected

The wallet to reserve the keypool key from.

Definition at line 276 of file wallet.h.

◆ vchPubKey

CPubKey CReserveKey::vchPubKey
protected

The public key.

Definition at line 280 of file wallet.h.


The documentation for this class was generated from the following files: