mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
wallet: Lock address type in ReserveDestination
This commit is contained in:
parent
bbc9e4133c
commit
55295fba4c
@ -2490,7 +2490,8 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
|
||||
int& nChangePosInOut, std::string& strFailReason, const CCoinControl& coin_control, bool sign)
|
||||
{
|
||||
CAmount nValue = 0;
|
||||
ReserveDestination reservedest(this);
|
||||
const OutputType change_type = TransactionChangeType(coin_control.m_change_type ? *coin_control.m_change_type : m_default_change_type, vecSend);
|
||||
ReserveDestination reservedest(this, change_type);
|
||||
int nChangePosRequest = nChangePosInOut;
|
||||
unsigned int nSubtractFeeFromAmount = 0;
|
||||
for (const auto& recipient : vecSend)
|
||||
@ -2549,8 +2550,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
|
||||
return false;
|
||||
}
|
||||
CTxDestination dest;
|
||||
const OutputType change_type = TransactionChangeType(coin_control.m_change_type ? *coin_control.m_change_type : m_default_change_type, vecSend);
|
||||
bool ret = reservedest.GetReservedDestination(change_type, dest, true);
|
||||
bool ret = reservedest.GetReservedDestination(dest, true);
|
||||
if (!ret)
|
||||
{
|
||||
strFailReason = "Keypool ran out, please call keypoolrefill first";
|
||||
@ -3069,8 +3069,8 @@ bool CWallet::GetNewChangeDestination(const OutputType type, CTxDestination& des
|
||||
|
||||
m_spk_man->TopUp();
|
||||
|
||||
ReserveDestination reservedest(this);
|
||||
if (!reservedest.GetReservedDestination(type, dest, true)) {
|
||||
ReserveDestination reservedest(this, type);
|
||||
if (!reservedest.GetReservedDestination(dest, true)) {
|
||||
error = "Error: Keypool ran out, please call keypoolrefill first";
|
||||
return false;
|
||||
}
|
||||
@ -3235,7 +3235,7 @@ std::set<CTxDestination> CWallet::GetLabelAddresses(const std::string& label) co
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ReserveDestination::GetReservedDestination(const OutputType type, CTxDestination& dest, bool internal)
|
||||
bool ReserveDestination::GetReservedDestination(CTxDestination& dest, bool internal)
|
||||
{
|
||||
m_spk_man = pwallet->GetLegacyScriptPubKeyMan();
|
||||
if (!m_spk_man) {
|
||||
|
@ -140,8 +140,9 @@ class ReserveDestination
|
||||
{
|
||||
protected:
|
||||
//! The wallet to reserve from
|
||||
CWallet* pwallet;
|
||||
CWallet* const pwallet;
|
||||
LegacyScriptPubKeyMan* m_spk_man{nullptr};
|
||||
OutputType const type;
|
||||
//! The index of the address's key in the keypool
|
||||
int64_t nIndex{-1};
|
||||
//! The public key for the address
|
||||
@ -153,10 +154,9 @@ protected:
|
||||
|
||||
public:
|
||||
//! Construct a ReserveDestination object. This does NOT reserve an address yet
|
||||
explicit ReserveDestination(CWallet* pwalletIn)
|
||||
{
|
||||
pwallet = pwalletIn;
|
||||
}
|
||||
explicit ReserveDestination(CWallet* pwallet, OutputType type)
|
||||
: pwallet(pwallet)
|
||||
, type(type) { }
|
||||
|
||||
ReserveDestination(const ReserveDestination&) = delete;
|
||||
ReserveDestination& operator=(const ReserveDestination&) = delete;
|
||||
@ -168,7 +168,7 @@ public:
|
||||
}
|
||||
|
||||
//! Reserve an address
|
||||
bool GetReservedDestination(const OutputType type, CTxDestination& pubkey, bool internal);
|
||||
bool GetReservedDestination(CTxDestination& pubkey, bool internal);
|
||||
//! Return reserved address
|
||||
void ReturnDestination();
|
||||
//! Keep the address. Do not return it's key to the keypool when this object goes out of scope
|
||||
|
Loading…
Reference in New Issue
Block a user