Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | |||||
* transaction and that transaction was not completed and needed to be aborted). | * transaction and that transaction was not completed and needed to be aborted). | ||||
* | * | ||||
* If an address is reserved and KeepDestination() is not called, then the | * If an address is reserved and KeepDestination() is not called, then the | ||||
* address will be returned when the ReserveDestination goes out of scope. | * address will be returned when the ReserveDestination goes out of scope. | ||||
*/ | */ | ||||
class ReserveDestination { | class ReserveDestination { | ||||
protected: | protected: | ||||
//! The wallet to reserve from | //! The wallet to reserve from | ||||
CWallet *pwallet; | CWallet *const pwallet; | ||||
LegacyScriptPubKeyMan *m_spk_man{nullptr}; | LegacyScriptPubKeyMan *m_spk_man{nullptr}; | ||||
OutputType const type; | |||||
//! The index of the address's key in the keypool | //! The index of the address's key in the keypool | ||||
int64_t nIndex{-1}; | int64_t nIndex{-1}; | ||||
//! The public key for the address | //! The public key for the address | ||||
CPubKey vchPubKey; | CPubKey vchPubKey; | ||||
//! The destination | //! The destination | ||||
CTxDestination address; | CTxDestination address; | ||||
//! Whether this is from the internal (change output) keypool | //! Whether this is from the internal (change output) keypool | ||||
bool fInternal{false}; | bool fInternal{false}; | ||||
public: | public: | ||||
//! Construct a ReserveDestination object. This does NOT reserve an address | //! Construct a ReserveDestination object. This does NOT reserve an address | ||||
//! yet | //! yet | ||||
explicit ReserveDestination(CWallet *pwalletIn) { pwallet = pwalletIn; } | explicit ReserveDestination(CWallet *_pwallet, OutputType _type) | ||||
: pwallet(_pwallet), type(_type) {} | |||||
ReserveDestination(const ReserveDestination &) = delete; | ReserveDestination(const ReserveDestination &) = delete; | ||||
ReserveDestination &operator=(const ReserveDestination &) = delete; | ReserveDestination &operator=(const ReserveDestination &) = delete; | ||||
//! Destructor. If a key has been reserved and not KeepKey'ed, it will be | //! Destructor. If a key has been reserved and not KeepKey'ed, it will be | ||||
//! returned to the keypool | //! returned to the keypool | ||||
~ReserveDestination() { ReturnDestination(); } | ~ReserveDestination() { ReturnDestination(); } | ||||
//! Reserve an address | //! Reserve an address | ||||
bool GetReservedDestination(const OutputType type, CTxDestination &pubkey, | bool GetReservedDestination(CTxDestination &pubkey, bool internal); | ||||
bool internal); | |||||
//! Return reserved address | //! Return reserved address | ||||
void ReturnDestination(); | void ReturnDestination(); | ||||
//! Keep the address. Do not return it's key to the keypool when this object | //! Keep the address. Do not return it's key to the keypool when this object | ||||
//! goes out of scope | //! goes out of scope | ||||
void KeepDestination(); | void KeepDestination(); | ||||
}; | }; | ||||
/** Address book data */ | /** Address book data */ | ||||
▲ Show 20 Lines • Show All 1,277 Lines • Show Last 20 Lines |