mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 23:07:59 +01:00
Limit LegacyScriptPubKeyMan address types
Make sure that LegacyScriptPubKeyMan can only be used for legacy, p2sh-segwit, and bech32 address types.
This commit is contained in:
parent
c93e123dc7
commit
177c15d2f7
3 changed files with 17 additions and 1 deletions
|
@ -22,6 +22,11 @@ const uint32_t BIP32_HARDENED_KEY_LIMIT = 0x80000000;
|
||||||
|
|
||||||
bool LegacyScriptPubKeyMan::GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error)
|
bool LegacyScriptPubKeyMan::GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error)
|
||||||
{
|
{
|
||||||
|
if (LEGACY_OUTPUT_TYPES.count(type) == 0) {
|
||||||
|
error = _("Error: Legacy wallets only support the \"legacy\", \"p2sh-segwit\", and \"bech32\" address types").translated;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
error.clear();
|
error.clear();
|
||||||
|
|
||||||
|
@ -291,6 +296,10 @@ bool LegacyScriptPubKeyMan::Encrypt(const CKeyingMaterial& master_key, WalletBat
|
||||||
|
|
||||||
bool LegacyScriptPubKeyMan::GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool)
|
bool LegacyScriptPubKeyMan::GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool)
|
||||||
{
|
{
|
||||||
|
if (LEGACY_OUTPUT_TYPES.count(type) == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!CanGetAddresses(internal)) {
|
if (!CanGetAddresses(internal)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -254,6 +254,13 @@ public:
|
||||||
boost::signals2::signal<void ()> NotifyCanGetAddressesChanged;
|
boost::signals2::signal<void ()> NotifyCanGetAddressesChanged;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** OutputTypes supported by the LegacyScriptPubKeyMan */
|
||||||
|
static const std::unordered_set<OutputType> LEGACY_OUTPUT_TYPES {
|
||||||
|
OutputType::LEGACY,
|
||||||
|
OutputType::P2SH_SEGWIT,
|
||||||
|
OutputType::BECH32,
|
||||||
|
};
|
||||||
|
|
||||||
class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProvider
|
class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProvider
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -3033,7 +3033,7 @@ void CWallet::SetupLegacyScriptPubKeyMan()
|
||||||
}
|
}
|
||||||
|
|
||||||
auto spk_manager = std::unique_ptr<ScriptPubKeyMan>(new LegacyScriptPubKeyMan(*this));
|
auto spk_manager = std::unique_ptr<ScriptPubKeyMan>(new LegacyScriptPubKeyMan(*this));
|
||||||
for (const auto& type : OUTPUT_TYPES) {
|
for (const auto& type : LEGACY_OUTPUT_TYPES) {
|
||||||
m_internal_spk_managers[type] = spk_manager.get();
|
m_internal_spk_managers[type] = spk_manager.get();
|
||||||
m_external_spk_managers[type] = spk_manager.get();
|
m_external_spk_managers[type] = spk_manager.get();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue