Skip to content

Commit

Permalink
Merge bitcoin#18782: wallet: Make sure no DescriptorScriptPubKeyMan o…
Browse files Browse the repository at this point in the history
…r WalletDescriptor members are left uninitialized after construction

2a78098 wallet: Make sure no WalletDescriptor members are uninitialized after construction (practicalswift)
ff046ae wallet: Make sure no DescriptorScriptPubKeyMan members are uninitialized after construction (practicalswift)

Pull request description:

  This is a small folllow-up to bitcoin#16528 ("Native Descriptor Wallets using DescriptorScriptPubKeyMan") which was merged in to `master` a couple of hours ago.

  Make sure no `DescriptorScriptPubKeyMan` or `WalletDescriptor` members are left uninitialized after construction.

  Before this change `bool m_internal` was left uninitialized when using the `DescriptorScriptPubKeyMan(WalletStorage&, WalletDescriptor&)` ctor.

  The same goes for the now initialized integers which were left uninitialized when using the `WalletDescriptor()` ctor.

ACKs for top commit:
  instagibbs:
    utACK  bitcoin@2a78098
  fjahr:
    Code review ACK 2a78098
  Sjors:
    utACK 2a78098
  achow101:
    ACK 2a78098
  brakmic:
    Code review ACK 2a78098
  meshcollider:
    utACK 2a78098

Tree-SHA512: c98e035268fdc7f65a423b73ac0cf010b0ef7c5e679b3cf170c1813efac8ab5c657dcbaf43c746770bea59e4772bfefe4caa834f1175260c39c7f35d92946ba5
  • Loading branch information
meshcollider authored and knst committed Mar 6, 2024
1 parent baa6959 commit 0949c08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/wallet/scriptpubkeyman.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ class DescriptorScriptPubKeyMan : public ScriptPubKeyMan
PubKeyMap m_map_pubkeys GUARDED_BY(cs_desc_man);
int32_t m_max_cached_index = -1;

bool m_internal;
bool m_internal = false;

KeyMap m_map_keys GUARDED_BY(cs_desc_man);
CryptedKeyMap m_map_crypted_keys GUARDED_BY(cs_desc_man);
Expand Down
8 changes: 4 additions & 4 deletions src/wallet/walletutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ class WalletDescriptor
{
public:
std::shared_ptr<Descriptor> descriptor;
uint64_t creation_time;
int32_t range_start; // First item in range; start of range, inclusive, i.e. [range_start, range_end). This never changes.
int32_t range_end; // Item after the last; end of range, exclusive, i.e. [range_start, range_end). This will increment with each TopUp()
int32_t next_index; // Position of the next item to generate
uint64_t creation_time = 0;
int32_t range_start = 0; // First item in range; start of range, inclusive, i.e. [range_start, range_end). This never changes.
int32_t range_end = 0; // Item after the last; end of range, exclusive, i.e. [range_start, range_end). This will increment with each TopUp()
int32_t next_index = 0; // Position of the next item to generate
DescriptorCache cache;

void DeserializeDescriptor(const std::string& str)
Expand Down

0 comments on commit 0949c08

Please sign in to comment.