aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.h
diff options
context:
space:
mode:
authorSamuel Dobson <dobsonsa68@gmail.com>2019-11-23 09:26:13 +1300
committerSamuel Dobson <dobsonsa68@gmail.com>2019-11-23 09:26:58 +1300
commit7127c310204787f1b981ef40a530fb22ccc7fc11 (patch)
tree2d6d997209dc25750a0478299dcc47680c6fce09 /src/wallet/wallet.h
parent0aa72061e5d651373449bdfa8d9463dcfe7b1ad4 (diff)
parent3958295bc8a3787b66b0269190218a3764088f79 (diff)
downloadbitcoin-7127c310204787f1b981ef40a530fb22ccc7fc11.tar.xz
Merge #17237: wallet: LearnRelatedScripts only if KeepDestination
3958295bc8a3787b66b0269190218a3764088f79 wallet: LearnRelatedScripts only if KeepDestination (João Barbosa) 55295fba4cbff36e9a8c3fed9c38e82ebe3c48b7 wallet: Lock address type in ReserveDestination (João Barbosa) Pull request description: Only mutates the wallet if the reserved key is kept. First commit is a refactor that makes the address type a class member. The second commit moves `LearnRelatedScripts` from `GetReservedDestination` to `KeepDestination` to avoid an unnecessary call to `AddCScript` - which in turn prevents multiple entries of the same script in the wallet DB. ACKs for top commit: achow101: Re-ACK 3958295bc8a3787b66b0269190218a3764088f79 Sjors: ACK 3958295bc8a3787b66b0269190218a3764088f79 ryanofsky: Code review ACK 3958295bc8a3787b66b0269190218a3764088f79. I like this change. The new behavior makes more sense, and the change makes the code clearer, since the current LearnRelatedScripts call is hard to understand and explain. (Personally, I'd like it if this PR were merged before #17373 or that PR was rebased on top of this one so it would be less confusing.) meshcollider: utACK 3958295bc8a3787b66b0269190218a3764088f79 Tree-SHA512: 49a5f4b022b28042ad37ea309b28378a3983cb904e234a25795b5a360356652e0f8e60f15e3e64d85094ea63af9be01812d90ccfc08ca4f1dd927fdd8566e33f
Diffstat (limited to 'src/wallet/wallet.h')
-rw-r--r--src/wallet/wallet.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 3349091835..fce49ec56c 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -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