mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Refactor: Copy CWallet signals and print function to LegacyScriptPubKeyMan
This commit does not change behavior.
This commit is contained in:
parent
c729afd0a3
commit
e2f02aa59e
6 changed files with 28 additions and 21 deletions
|
|
@ -9,7 +9,6 @@
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/translation.h>
|
#include <util/translation.h>
|
||||||
#include <wallet/scriptpubkeyman.h>
|
#include <wallet/scriptpubkeyman.h>
|
||||||
#include <wallet/wallet.h>
|
|
||||||
|
|
||||||
bool LegacyScriptPubKeyMan::GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error)
|
bool LegacyScriptPubKeyMan::GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error)
|
||||||
{
|
{
|
||||||
|
|
@ -1427,12 +1426,3 @@ std::set<CKeyID> LegacyScriptPubKeyMan::GetKeys() const
|
||||||
}
|
}
|
||||||
return set_address;
|
return set_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary CWallet accessors and aliases.
|
|
||||||
LegacyScriptPubKeyMan::LegacyScriptPubKeyMan(CWallet& wallet)
|
|
||||||
: ScriptPubKeyMan(wallet),
|
|
||||||
m_wallet(wallet) {}
|
|
||||||
|
|
||||||
void LegacyScriptPubKeyMan::NotifyWatchonlyChanged(bool fHaveWatchOnly) const { return m_wallet.NotifyWatchonlyChanged(fHaveWatchOnly); }
|
|
||||||
void LegacyScriptPubKeyMan::NotifyCanGetAddressesChanged() const { return m_wallet.NotifyCanGetAddressesChanged(); }
|
|
||||||
template<typename... Params> void LegacyScriptPubKeyMan::WalletLogPrintf(const std::string& fmt, const Params&... parameters) const { return m_wallet.WalletLogPrintf(fmt, parameters...); }
|
|
||||||
|
|
|
||||||
|
|
@ -206,6 +206,18 @@ public:
|
||||||
virtual bool CanProvide(const CScript& script, SignatureData& sigdata) { return false; }
|
virtual bool CanProvide(const CScript& script, SignatureData& sigdata) { return false; }
|
||||||
|
|
||||||
virtual uint256 GetID() const { return uint256(); }
|
virtual uint256 GetID() const { return uint256(); }
|
||||||
|
|
||||||
|
/** Prepends the wallet name in logging output to ease debugging in multi-wallet use cases */
|
||||||
|
template<typename... Params>
|
||||||
|
void WalletLogPrintf(std::string fmt, Params... parameters) const {
|
||||||
|
LogPrintf(("%s " + fmt).c_str(), m_storage.GetDisplayName(), parameters...);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Watch-only address added */
|
||||||
|
boost::signals2::signal<void (bool fHaveWatchOnly)> NotifyWatchonlyChanged;
|
||||||
|
|
||||||
|
/** Keypool has new keys */
|
||||||
|
boost::signals2::signal<void ()> NotifyCanGetAddressesChanged;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProvider
|
class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProvider
|
||||||
|
|
@ -290,6 +302,8 @@ private:
|
||||||
bool ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool, bool fRequestedInternal);
|
bool ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool, bool fRequestedInternal);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using ScriptPubKeyMan::ScriptPubKeyMan;
|
||||||
|
|
||||||
bool GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error) override;
|
bool GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error) override;
|
||||||
isminetype IsMine(const CScript& script) const override;
|
isminetype IsMine(const CScript& script) const override;
|
||||||
|
|
||||||
|
|
@ -426,14 +440,6 @@ public:
|
||||||
const std::map<CKeyID, int64_t>& GetAllReserveKeys() const { return m_pool_key_to_index; }
|
const std::map<CKeyID, int64_t>& GetAllReserveKeys() const { return m_pool_key_to_index; }
|
||||||
|
|
||||||
std::set<CKeyID> GetKeys() const override;
|
std::set<CKeyID> GetKeys() const override;
|
||||||
// Temporary CWallet accessors and aliases.
|
|
||||||
friend class CWallet;
|
|
||||||
friend class ReserveDestination;
|
|
||||||
LegacyScriptPubKeyMan(CWallet& wallet);
|
|
||||||
void NotifyWatchonlyChanged(bool fHaveWatchOnly) const;
|
|
||||||
void NotifyCanGetAddressesChanged() const;
|
|
||||||
template<typename... Params> void WalletLogPrintf(const std::string& fmt, const Params&... parameters) const;
|
|
||||||
CWallet& m_wallet;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_WALLET_SCRIPTPUBKEYMAN_H
|
#endif // BITCOIN_WALLET_SCRIPTPUBKEYMAN_H
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ bool AddWallet(const std::shared_ptr<CWallet>& wallet)
|
||||||
std::vector<std::shared_ptr<CWallet>>::const_iterator i = std::find(vpwallets.begin(), vpwallets.end(), wallet);
|
std::vector<std::shared_ptr<CWallet>>::const_iterator i = std::find(vpwallets.begin(), vpwallets.end(), wallet);
|
||||||
if (i != vpwallets.end()) return false;
|
if (i != vpwallets.end()) return false;
|
||||||
vpwallets.push_back(wallet);
|
vpwallets.push_back(wallet);
|
||||||
|
wallet->ConnectScriptPubKeyManNotifiers();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4218,3 +4219,11 @@ bool CWallet::HasEncryptionKeys() const
|
||||||
{
|
{
|
||||||
return !mapMasterKeys.empty();
|
return !mapMasterKeys.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CWallet::ConnectScriptPubKeyManNotifiers()
|
||||||
|
{
|
||||||
|
for (const auto& spk_man : GetActiveScriptPubKeyMans()) {
|
||||||
|
spk_man->NotifyWatchonlyChanged.connect(NotifyWatchonlyChanged);
|
||||||
|
spk_man->NotifyCanGetAddressesChanged.connect(NotifyCanGetAddressesChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1181,6 +1181,9 @@ public:
|
||||||
m_last_block_processed_height = block_height;
|
m_last_block_processed_height = block_height;
|
||||||
m_last_block_processed = block_hash;
|
m_last_block_processed = block_hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! Connect the signals from ScriptPubKeyMans to the signals in CWallet
|
||||||
|
void ConnectScriptPubKeyManNotifiers();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ EXPECTED_CIRCULAR_DEPENDENCIES=(
|
||||||
"wallet/fees -> wallet/wallet -> wallet/fees"
|
"wallet/fees -> wallet/wallet -> wallet/fees"
|
||||||
"wallet/wallet -> wallet/walletdb -> wallet/wallet"
|
"wallet/wallet -> wallet/walletdb -> wallet/wallet"
|
||||||
"policy/fees -> txmempool -> validation -> policy/fees"
|
"policy/fees -> txmempool -> validation -> policy/fees"
|
||||||
"wallet/scriptpubkeyman -> wallet/wallet -> wallet/scriptpubkeyman"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
EXIT_CODE=0
|
EXIT_CODE=0
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,10 @@ FALSE_POSITIVES = [
|
||||||
("src/validationinterface.cpp", "LogPrint(BCLog::VALIDATION, fmt \"\\n\", __VA_ARGS__)"),
|
("src/validationinterface.cpp", "LogPrint(BCLog::VALIDATION, fmt \"\\n\", __VA_ARGS__)"),
|
||||||
("src/wallet/wallet.h", "WalletLogPrintf(std::string fmt, Params... parameters)"),
|
("src/wallet/wallet.h", "WalletLogPrintf(std::string fmt, Params... parameters)"),
|
||||||
("src/wallet/wallet.h", "LogPrintf((\"%s \" + fmt).c_str(), GetDisplayName(), parameters...)"),
|
("src/wallet/wallet.h", "LogPrintf((\"%s \" + fmt).c_str(), GetDisplayName(), parameters...)"),
|
||||||
|
("src/wallet/scriptpubkeyman.h", "WalletLogPrintf(std::string fmt, Params... parameters)"),
|
||||||
|
("src/wallet/scriptpubkeyman.h", "LogPrintf((\"%s \" + fmt).c_str(), m_storage.GetDisplayName(), parameters...)"),
|
||||||
("src/logging.h", "LogPrintf(const char* fmt, const Args&... args)"),
|
("src/logging.h", "LogPrintf(const char* fmt, const Args&... args)"),
|
||||||
("src/wallet/scriptpubkeyman.h", "WalletLogPrintf(const std::string& fmt, const Params&... parameters)"),
|
("src/wallet/scriptpubkeyman.h", "WalletLogPrintf(const std::string& fmt, const Params&... parameters)"),
|
||||||
("src/wallet/scriptpubkeyman.cpp", "WalletLogPrintf(fmt, parameters...)"),
|
|
||||||
("src/wallet/scriptpubkeyman.cpp", "WalletLogPrintf(const std::string& fmt, const Params&... parameters)"),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue