Skip to content

Commit 3c2236e

Browse files
committed
wallet: Delete LegacySPKM
Deletes LegacyScriptPubKeyMan and related tests
1 parent 0ddb9c7 commit 3c2236e

19 files changed

+110
-2591
lines changed

src/Makefile.test.include

-2
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ BITCOIN_TESTS += \
180180
wallet/test/wallet_transaction_tests.cpp \
181181
wallet/test/coinselector_tests.cpp \
182182
wallet/test/init_tests.cpp \
183-
wallet/test/ismine_tests.cpp \
184183
wallet/test/rpc_util_tests.cpp \
185-
wallet/test/scriptpubkeyman_tests.cpp \
186184
wallet/test/walletload_tests.cpp \
187185
wallet/test/group_outputs_tests.cpp
188186

src/interfaces/wallet.h

-3
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,6 @@ class Wallet
277277
// Remove wallet.
278278
virtual void remove() = 0;
279279

280-
//! Return whether is a legacy wallet
281-
virtual bool isLegacy() = 0;
282-
283280
//! Register handler for unload message.
284281
using UnloadFn = std::function<void()>;
285282
virtual std::unique_ptr<Handler> handleUnload(UnloadFn fn) = 0;

src/qt/bitcoingui.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,6 @@ void BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)
768768
}
769769
}
770770
updateWindowTitle();
771-
m_migrate_wallet_action->setEnabled(wallet_model->wallet().isLegacy());
772771
}
773772

774773
void BitcoinGUI::setCurrentWalletBySelectorIndex(int index)

src/qt/overviewpage.cpp

+4-22
Original file line numberDiff line numberDiff line change
@@ -195,28 +195,10 @@ OverviewPage::~OverviewPage()
195195
void OverviewPage::setBalance(const interfaces::WalletBalances& balances)
196196
{
197197
BitcoinUnit unit = walletModel->getOptionsModel()->getDisplayUnit();
198-
if (walletModel->wallet().isLegacy()) {
199-
if (walletModel->wallet().privateKeysDisabled()) {
200-
ui->labelBalance->setText(BitcoinUnits::formatWithPrivacy(unit, balances.watch_only_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
201-
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithPrivacy(unit, balances.unconfirmed_watch_only_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
202-
ui->labelImmature->setText(BitcoinUnits::formatWithPrivacy(unit, balances.immature_watch_only_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
203-
ui->labelTotal->setText(BitcoinUnits::formatWithPrivacy(unit, balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
204-
} else {
205-
ui->labelBalance->setText(BitcoinUnits::formatWithPrivacy(unit, balances.balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
206-
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithPrivacy(unit, balances.unconfirmed_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
207-
ui->labelImmature->setText(BitcoinUnits::formatWithPrivacy(unit, balances.immature_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
208-
ui->labelTotal->setText(BitcoinUnits::formatWithPrivacy(unit, balances.balance + balances.unconfirmed_balance + balances.immature_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
209-
ui->labelWatchAvailable->setText(BitcoinUnits::formatWithPrivacy(unit, balances.watch_only_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
210-
ui->labelWatchPending->setText(BitcoinUnits::formatWithPrivacy(unit, balances.unconfirmed_watch_only_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
211-
ui->labelWatchImmature->setText(BitcoinUnits::formatWithPrivacy(unit, balances.immature_watch_only_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
212-
ui->labelWatchTotal->setText(BitcoinUnits::formatWithPrivacy(unit, balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
213-
}
214-
} else {
215-
ui->labelBalance->setText(BitcoinUnits::formatWithPrivacy(unit, balances.balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
216-
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithPrivacy(unit, balances.unconfirmed_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
217-
ui->labelImmature->setText(BitcoinUnits::formatWithPrivacy(unit, balances.immature_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
218-
ui->labelTotal->setText(BitcoinUnits::formatWithPrivacy(unit, balances.balance + balances.unconfirmed_balance + balances.immature_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
219-
}
198+
ui->labelBalance->setText(BitcoinUnits::formatWithPrivacy(unit, balances.balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
199+
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithPrivacy(unit, balances.unconfirmed_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
200+
ui->labelImmature->setText(BitcoinUnits::formatWithPrivacy(unit, balances.immature_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
201+
ui->labelTotal->setText(BitcoinUnits::formatWithPrivacy(unit, balances.balance + balances.unconfirmed_balance + balances.immature_balance, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
220202
// only show immature (newly mined) balance if it's non-zero, so as not to complicate things
221203
// for the non-mining users
222204
bool showImmature = balances.immature_balance != 0;

src/qt/sendcoinsdialog.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,6 @@ void SendCoinsDialog::setBalance(const interfaces::WalletBalances& balances)
706706
CAmount balance = balances.balance;
707707
if (model->wallet().hasExternalSigner()) {
708708
ui->labelBalanceName->setText(tr("External balance:"));
709-
} else if (model->wallet().isLegacy() && model->wallet().privateKeysDisabled()) {
710-
balance = balances.watch_only_balance;
711-
ui->labelBalanceName->setText(tr("Watch-only balance:"));
712709
}
713710
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), balance));
714711
}

src/wallet/feebumper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWallet
5252
if (require_mine) {
5353
// check that original tx consists entirely of our inputs
5454
// if not, we can't bump the fee, because the wallet has no way of knowing the value of the other inputs (thus the fee)
55-
isminefilter filter = wallet.GetLegacyScriptPubKeyMan() && wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) ? ISMINE_WATCH_ONLY : ISMINE_SPENDABLE;
55+
isminefilter filter = ISMINE_SPENDABLE;
5656
if (!AllInputsMine(wallet, *wtx.tx, filter)) {
5757
errors.push_back(Untranslated("Transaction contains inputs that don't belong to this wallet"));
5858
return feebumper::Result::WALLET_ERROR;

src/wallet/interfaces.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,7 @@ class WalletImpl : public Wallet
174174
}
175175
bool haveWatchOnly() override
176176
{
177-
auto spk_man = m_wallet->GetLegacyScriptPubKeyMan();
178-
if (spk_man) {
179-
return spk_man->HaveWatchOnly();
180-
}
181-
return false;
177+
return m_wallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS);
182178
};
183179
bool setAddressBook(const CTxDestination& dest, const std::string& name, const std::optional<AddressPurpose>& purpose) override
184180
{
@@ -513,7 +509,6 @@ class WalletImpl : public Wallet
513509
bool hasExternalSigner() override { return m_wallet->IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER); }
514510
bool privateKeysDisabled() override { return m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS); }
515511
bool taprootEnabled() override {
516-
if (m_wallet->IsLegacy()) return false;
517512
auto spk_man = m_wallet->GetScriptPubKeyMan(OutputType::BECH32M, /*internal=*/false);
518513
return spk_man != nullptr;
519514
}
@@ -523,7 +518,6 @@ class WalletImpl : public Wallet
523518
{
524519
RemoveWallet(m_context, m_wallet, /*load_on_start=*/false);
525520
}
526-
bool isLegacy() override { return m_wallet->IsLegacy(); }
527521
std::unique_ptr<Handler> handleUnload(UnloadFn fn) override
528522
{
529523
return MakeSignalHandler(m_wallet->NotifyUnload.connect(fn));

src/wallet/rpc/addresses.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ RPCHelpMan getnewaddress()
5252
std::optional<OutputType> parsed = ParseOutputType(request.params[1].get_str());
5353
if (!parsed) {
5454
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[1].get_str()));
55-
} else if (parsed.value() == OutputType::BECH32M && pwallet->GetLegacyScriptPubKeyMan()) {
56-
throw JSONRPCError(RPC_INVALID_PARAMETER, "Legacy wallets cannot provide bech32m addresses");
5755
}
5856
output_type = parsed.value();
5957
}
@@ -99,8 +97,6 @@ RPCHelpMan getrawchangeaddress()
9997
std::optional<OutputType> parsed = ParseOutputType(request.params[0].get_str());
10098
if (!parsed) {
10199
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[0].get_str()));
102-
} else if (parsed.value() == OutputType::BECH32M && pwallet->GetLegacyScriptPubKeyMan()) {
103-
throw JSONRPCError(RPC_INVALID_PARAMETER, "Legacy wallets cannot provide bech32m addresses");
104100
}
105101
output_type = parsed.value();
106102
}
@@ -231,10 +227,6 @@ RPCHelpMan keypoolrefill()
231227
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
232228
if (!pwallet) return UniValue::VNULL;
233229

234-
if (pwallet->IsLegacy() && pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
235-
throw JSONRPCError(RPC_WALLET_ERROR, "Error: Private keys are disabled for this wallet");
236-
}
237-
238230
LOCK(pwallet->cs_wallet);
239231

240232
// 0 is interpreted by TopUpKeyPool() as the default keypool size given by -keypool

src/wallet/rpc/coins.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -482,14 +482,6 @@ RPCHelpMan getbalances()
482482
}
483483
balances.pushKV("mine", balances_mine);
484484
}
485-
auto spk_man = wallet.GetLegacyScriptPubKeyMan();
486-
if (spk_man && spk_man->HaveWatchOnly()) {
487-
UniValue balances_watchonly{UniValue::VOBJ};
488-
balances_watchonly.pushKV("trusted", ValueFromAmount(bal.m_watchonly_trusted));
489-
balances_watchonly.pushKV("untrusted_pending", ValueFromAmount(bal.m_watchonly_untrusted_pending));
490-
balances_watchonly.pushKV("immature", ValueFromAmount(bal.m_watchonly_immature));
491-
balances.pushKV("watchonly", balances_watchonly);
492-
}
493485

494486
AppendLastProcessedBlock(balances, wallet);
495487
return balances;

src/wallet/rpc/wallet.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,6 @@ static RPCHelpMan getwalletinfo()
104104
}
105105
obj.pushKV("keypoolsize", (int64_t)kpExternalSize);
106106

107-
LegacyScriptPubKeyMan* spk_man = pwallet->GetLegacyScriptPubKeyMan();
108-
if (spk_man) {
109-
CKeyID seed_id = spk_man->GetHDChain().seed_id;
110-
if (!seed_id.IsNull()) {
111-
obj.pushKV("hdseedid", seed_id.GetHex());
112-
}
113-
}
114-
115107
if (pwallet->CanSupportFeature(FEATURE_HD_SPLIT)) {
116108
obj.pushKV("keypoolsize_hd_internal", (int64_t)(pwallet->GetKeyPoolSize() - kpExternalSize));
117109
}

0 commit comments

Comments
 (0)