Skip to content

Commit 46560dd

Browse files
committed
wallet: Delete LegacySPKM
Deletes LegacyScriptPubKeyMan and related tests
1 parent 5345d5a commit 46560dd

19 files changed

+125
-2820
lines changed

src/interfaces/wallet.h

-3
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,6 @@ class Wallet
282282
// Remove wallet.
283283
virtual void remove() = 0;
284284

285-
//! Return whether is a legacy wallet
286-
virtual bool isLegacy() = 0;
287-
288285
//! Register handler for unload message.
289286
using UnloadFn = std::function<void()>;
290287
virtual std::unique_ptr<Handler> handleUnload(UnloadFn fn) = 0;

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
@@ -707,9 +707,6 @@ void SendCoinsDialog::setBalance(const interfaces::WalletBalances& balances)
707707
CAmount balance = balances.balance;
708708
if (model->wallet().hasExternalSigner()) {
709709
ui->labelBalanceName->setText(tr("External balance:"));
710-
} else if (model->wallet().isLegacy() && model->wallet().privateKeysDisabled()) {
711-
balance = balances.watch_only_balance;
712-
ui->labelBalanceName->setText(tr("Watch-only balance:"));
713710
}
714711
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), balance));
715712
}

src/wallet/feebumper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWallet
5353
if (require_mine) {
5454
// check that original tx consists entirely of our inputs
5555
// 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)
56-
isminefilter filter = wallet.GetLegacyScriptPubKeyMan() && wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) ? ISMINE_WATCH_ONLY : ISMINE_SPENDABLE;
56+
isminefilter filter = ISMINE_SPENDABLE;
5757
if (!AllInputsMine(wallet, *wtx.tx, filter)) {
5858
errors.push_back(Untranslated("Transaction contains inputs that don't belong to this wallet"));
5959
return feebumper::Result::WALLET_ERROR;

src/wallet/interfaces.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,7 @@ class WalletImpl : public Wallet
177177
}
178178
bool haveWatchOnly() override
179179
{
180-
auto spk_man = m_wallet->GetLegacyScriptPubKeyMan();
181-
if (spk_man) {
182-
return spk_man->HaveWatchOnly();
183-
}
184-
return false;
180+
return m_wallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS);
185181
};
186182
bool setAddressBook(const CTxDestination& dest, const std::string& name, const std::optional<AddressPurpose>& purpose) override
187183
{
@@ -516,7 +512,6 @@ class WalletImpl : public Wallet
516512
bool hasExternalSigner() override { return m_wallet->IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER); }
517513
bool privateKeysDisabled() override { return m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS); }
518514
bool taprootEnabled() override {
519-
if (m_wallet->IsLegacy()) return false;
520515
auto spk_man = m_wallet->GetScriptPubKeyMan(OutputType::BECH32M, /*internal=*/false);
521516
return spk_man != nullptr;
522517
}
@@ -526,7 +521,6 @@ class WalletImpl : public Wallet
526521
{
527522
RemoveWallet(m_context, m_wallet, /*load_on_start=*/false);
528523
}
529-
bool isLegacy() override { return m_wallet->IsLegacy(); }
530524
std::unique_ptr<Handler> handleUnload(UnloadFn fn) override
531525
{
532526
return MakeSignalHandler(m_wallet->NotifyUnload.connect(fn));

src/wallet/rpc/addresses.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ RPCHelpMan getnewaddress()
5454
std::optional<OutputType> parsed = ParseOutputType(request.params[1].get_str());
5555
if (!parsed) {
5656
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[1].get_str()));
57-
} else if (parsed.value() == OutputType::BECH32M && pwallet->GetLegacyScriptPubKeyMan()) {
58-
throw JSONRPCError(RPC_INVALID_PARAMETER, "Legacy wallets cannot provide bech32m addresses");
5957
}
6058
output_type = parsed.value();
6159
}
@@ -101,8 +99,6 @@ RPCHelpMan getrawchangeaddress()
10199
std::optional<OutputType> parsed = ParseOutputType(request.params[0].get_str());
102100
if (!parsed) {
103101
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[0].get_str()));
104-
} else if (parsed.value() == OutputType::BECH32M && pwallet->GetLegacyScriptPubKeyMan()) {
105-
throw JSONRPCError(RPC_INVALID_PARAMETER, "Legacy wallets cannot provide bech32m addresses");
106102
}
107103
output_type = parsed.value();
108104
}
@@ -233,10 +229,6 @@ RPCHelpMan keypoolrefill()
233229
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
234230
if (!pwallet) return UniValue::VNULL;
235231

236-
if (pwallet->IsLegacy() && pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
237-
throw JSONRPCError(RPC_WALLET_ERROR, "Error: Private keys are disabled for this wallet");
238-
}
239-
240232
LOCK(pwallet->cs_wallet);
241233

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

src/wallet/rpc/coins.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -479,15 +479,6 @@ RPCHelpMan getbalances()
479479
}
480480
balances.pushKV("mine", std::move(balances_mine));
481481
}
482-
auto spk_man = wallet.GetLegacyScriptPubKeyMan();
483-
if (spk_man && spk_man->HaveWatchOnly()) {
484-
UniValue balances_watchonly{UniValue::VOBJ};
485-
balances_watchonly.pushKV("trusted", ValueFromAmount(bal.m_watchonly_trusted));
486-
balances_watchonly.pushKV("untrusted_pending", ValueFromAmount(bal.m_watchonly_untrusted_pending));
487-
balances_watchonly.pushKV("immature", ValueFromAmount(bal.m_watchonly_immature));
488-
balances.pushKV("watchonly", std::move(balances_watchonly));
489-
}
490-
491482
AppendLastProcessedBlock(balances, wallet);
492483
return balances;
493484
},

src/wallet/rpc/wallet.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,6 @@ static RPCHelpMan getwalletinfo()
107107
}
108108
obj.pushKV("keypoolsize", (int64_t)kpExternalSize);
109109

110-
LegacyScriptPubKeyMan* spk_man = pwallet->GetLegacyScriptPubKeyMan();
111-
if (spk_man) {
112-
CKeyID seed_id = spk_man->GetHDChain().seed_id;
113-
if (!seed_id.IsNull()) {
114-
obj.pushKV("hdseedid", seed_id.GetHex());
115-
}
116-
}
117-
118110
if (pwallet->CanSupportFeature(FEATURE_HD_SPLIT)) {
119111
obj.pushKV("keypoolsize_hd_internal", (int64_t)(pwallet->GetKeyPoolSize() - kpExternalSize));
120112
}

0 commit comments

Comments
 (0)