Skip to content

Commit 83af1a3

Browse files
committed
wallet: Delete LegacySPKM
Deletes LegacyScriptPubKeyMan and related tests Best reviewed with `git diff --patience` or `git diff --histogram`
1 parent 8ede6de commit 83af1a3

22 files changed

+149
-2551
lines changed

src/interfaces/wallet.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ class Wallet
107107
//! Return whether wallet has private key.
108108
virtual bool isSpendable(const CTxDestination& dest) = 0;
109109

110-
//! Return whether wallet has watch only keys.
111-
virtual bool haveWatchOnly() = 0;
112-
113110
//! Add or update address.
114111
virtual bool setAddressBook(const CTxDestination& dest, const std::string& name, const std::optional<wallet::AddressPurpose>& purpose) = 0;
115112

@@ -282,9 +279,6 @@ class Wallet
282279
// Remove wallet.
283280
virtual void remove() = 0;
284281

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

src/qt/overviewpage.cpp

Lines changed: 5 additions & 27 deletions
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;
@@ -281,11 +263,7 @@ void OverviewPage::setWalletModel(WalletModel *model)
281263

282264
connect(model->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &OverviewPage::updateDisplayUnit);
283265

284-
interfaces::Wallet& wallet = model->wallet();
285-
updateWatchOnlyLabels(wallet.haveWatchOnly() && !wallet.privateKeysDisabled());
286-
connect(model, &WalletModel::notifyWatchonlyChanged, [this](bool showWatchOnly) {
287-
updateWatchOnlyLabels(showWatchOnly && !walletModel->wallet().privateKeysDisabled());
288-
});
266+
updateWatchOnlyLabels(false);
289267
}
290268

291269
// update the display unit, to not use the default ("BTC")

src/qt/sendcoinsdialog.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,9 +711,6 @@ void SendCoinsDialog::setBalance(const interfaces::WalletBalances& balances)
711711
CAmount balance = balances.balance;
712712
if (model->wallet().hasExternalSigner()) {
713713
ui->labelBalanceName->setText(tr("External balance:"));
714-
} else if (model->wallet().isLegacy() && model->wallet().privateKeysDisabled()) {
715-
balance = balances.watch_only_balance;
716-
ui->labelBalanceName->setText(tr("Watch-only balance:"));
717714
}
718715
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), balance));
719716
}

src/qt/transactionview.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ void TransactionView::setModel(WalletModel *_model)
241241
}
242242
}
243243

244-
// show/hide column Watch-only
245-
updateWatchOnlyColumn(_model->wallet().haveWatchOnly());
244+
// hide column Watch-only
245+
updateWatchOnlyColumn(false);
246246

247247
// Watch-only signal
248248
connect(_model, &WalletModel::notifyWatchonlyChanged, this, &TransactionView::updateWatchOnlyColumn);
@@ -368,8 +368,6 @@ void TransactionView::exportClicked()
368368
// name, column, role
369369
writer.setModel(transactionProxyModel);
370370
writer.addColumn(tr("Confirmed"), 0, TransactionTableModel::ConfirmedRole);
371-
if (model->wallet().haveWatchOnly())
372-
writer.addColumn(tr("Watch-only"), TransactionTableModel::Watchonly);
373371
writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole);
374372
writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole);
375373
writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole);

src/qt/walletmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ WalletModel::WalletModel(std::unique_ptr<interfaces::Wallet> wallet, ClientModel
4545
optionsModel(client_model.getOptionsModel()),
4646
timer(new QTimer(this))
4747
{
48-
fHaveWatchOnly = m_wallet->haveWatchOnly();
48+
fHaveWatchOnly = false;
4949
addressTableModel = new AddressTableModel(this);
5050
transactionTableModel = new TransactionTableModel(platformStyle, this);
5151
recentRequestsTableModel = new RecentRequestsTableModel(this);

src/wallet/feebumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWallet
4848
if (require_mine) {
4949
// check that original tx consists entirely of our inputs
5050
// 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)
51-
isminefilter filter = wallet.GetLegacyScriptPubKeyMan() && wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) ? ISMINE_WATCH_ONLY : ISMINE_SPENDABLE;
51+
isminefilter filter = ISMINE_SPENDABLE;
5252
if (!AllInputsMine(wallet, *wtx.tx, filter)) {
5353
errors.emplace_back(Untranslated("Transaction contains inputs that don't belong to this wallet"));
5454
return feebumper::Result::WALLET_ERROR;

src/wallet/interfaces.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,6 @@ class WalletImpl : public Wallet
175175
LOCK(m_wallet->cs_wallet);
176176
return m_wallet->IsMine(dest) & ISMINE_SPENDABLE;
177177
}
178-
bool haveWatchOnly() override
179-
{
180-
auto spk_man = m_wallet->GetLegacyScriptPubKeyMan();
181-
if (spk_man) {
182-
return spk_man->HaveWatchOnly();
183-
}
184-
return false;
185-
};
186178
bool setAddressBook(const CTxDestination& dest, const std::string& name, const std::optional<AddressPurpose>& purpose) override
187179
{
188180
return m_wallet->SetAddressBook(dest, name, purpose);
@@ -407,12 +399,7 @@ class WalletImpl : public Wallet
407399
result.balance = bal.m_mine_trusted;
408400
result.unconfirmed_balance = bal.m_mine_untrusted_pending;
409401
result.immature_balance = bal.m_mine_immature;
410-
result.have_watch_only = haveWatchOnly();
411-
if (result.have_watch_only) {
412-
result.watch_only_balance = bal.m_watchonly_trusted;
413-
result.unconfirmed_watch_only_balance = bal.m_watchonly_untrusted_pending;
414-
result.immature_watch_only_balance = bal.m_watchonly_immature;
415-
}
402+
result.have_watch_only = false;
416403
return result;
417404
}
418405
bool tryGetBalances(WalletBalances& balances, uint256& block_hash) override
@@ -516,7 +503,6 @@ class WalletImpl : public Wallet
516503
bool hasExternalSigner() override { return m_wallet->IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER); }
517504
bool privateKeysDisabled() override { return m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS); }
518505
bool taprootEnabled() override {
519-
if (m_wallet->IsLegacy()) return false;
520506
auto spk_man = m_wallet->GetScriptPubKeyMan(OutputType::BECH32M, /*internal=*/false);
521507
return spk_man != nullptr;
522508
}
@@ -526,7 +512,6 @@ class WalletImpl : public Wallet
526512
{
527513
RemoveWallet(m_context, m_wallet, /*load_on_start=*/false);
528514
}
529-
bool isLegacy() override { return m_wallet->IsLegacy(); }
530515
std::unique_ptr<Handler> handleUnload(UnloadFn fn) override
531516
{
532517
return MakeSignalHandler(m_wallet->NotifyUnload.connect(fn));

src/wallet/rpc/addresses.cpp

Lines changed: 0 additions & 8 deletions
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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,6 @@ RPCHelpMan getbalances()
440440
{RPCResult::Type::STR_AMOUNT, "immature", "balance from immature coinbase outputs"},
441441
{RPCResult::Type::STR_AMOUNT, "used", /*optional=*/true, "(only present if avoid_reuse is set) balance from coins sent to addresses that were previously spent from (potentially privacy violating)"},
442442
}},
443-
{RPCResult::Type::OBJ, "watchonly", /*optional=*/true, "watchonly balances (not present if wallet does not watch anything)",
444-
{
445-
{RPCResult::Type::STR_AMOUNT, "trusted", "trusted balance (outputs created by the wallet or confirmed outputs)"},
446-
{RPCResult::Type::STR_AMOUNT, "untrusted_pending", "untrusted pending balance (outputs created by others that are in the mempool)"},
447-
{RPCResult::Type::STR_AMOUNT, "immature", "balance from immature coinbase outputs"},
448-
}},
449443
RESULT_LAST_PROCESSED_BLOCK,
450444
}
451445
},
@@ -479,15 +473,6 @@ RPCHelpMan getbalances()
479473
}
480474
balances.pushKV("mine", std::move(balances_mine));
481475
}
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-
491476
AppendLastProcessedBlock(balances, wallet);
492477
return balances;
493478
},

src/wallet/rpc/wallet.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ static RPCHelpMan getwalletinfo()
6060
{RPCResult::Type::NUM, "keypoolsize_hd_internal", /*optional=*/true, "how many new keys are pre-generated for internal use (used for change outputs, only appears if the wallet is using this feature, otherwise external keys are used)"},
6161
{RPCResult::Type::NUM_TIME, "unlocked_until", /*optional=*/true, "the " + UNIX_EPOCH_TIME + " until which the wallet is unlocked for transfers, or 0 if the wallet is locked (only present for passphrase-encrypted wallets)"},
6262
{RPCResult::Type::STR_AMOUNT, "paytxfee", "the transaction fee configuration, set in " + CURRENCY_UNIT + "/kvB"},
63-
{RPCResult::Type::STR_HEX, "hdseedid", /*optional=*/true, "the Hash160 of the HD seed (only present when HD is enabled)"},
6463
{RPCResult::Type::BOOL, "private_keys_enabled", "false if privatekeys are disabled for this wallet (enforced watch-only wallet)"},
6564
{RPCResult::Type::BOOL, "avoid_reuse", "whether this wallet tracks clean/dirty coins in terms of reuse"},
6665
{RPCResult::Type::OBJ, "scanning", "current scanning details, or false if no scan is in progress",
@@ -107,14 +106,6 @@ static RPCHelpMan getwalletinfo()
107106
}
108107
obj.pushKV("keypoolsize", (int64_t)kpExternalSize);
109108

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-
118109
if (pwallet->CanSupportFeature(FEATURE_HD_SPLIT)) {
119110
obj.pushKV("keypoolsize_hd_internal", (int64_t)(pwallet->GetKeyPoolSize() - kpExternalSize));
120111
}

0 commit comments

Comments
 (0)