mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 15:50:07 +01:00
wallet/migration: use HavePrivateKeys in place of ToPrivateString
ToPrivateString() behaviour will be modified in the following commits. In order to keep the scope of this PR limited to the RPC behaviour, this commit updates wallet migration to use 'Descriptor::HavePrivateKeys()' in place of 'Descriptor::ToPrivateString()' to determine watchonly descriptors. A follow-up PR can be opened to update migration logic to exclude descriptors with some private keys from the watchonly migration wallet.
This commit is contained in:
@@ -717,10 +717,9 @@ std::optional<MigrationData> LegacyDataSPKM::MigrateToDescriptor()
|
||||
|
||||
std::vector<CScript> desc_spks;
|
||||
|
||||
// Make the descriptor string with private keys
|
||||
std::string desc_str;
|
||||
bool watchonly = !desc->ToPrivateString(*this, desc_str);
|
||||
if (watchonly && !m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
|
||||
// If we can't provide all private keys for this inferred descriptor,
|
||||
// but this wallet is not watch-only, migrate it to the watch-only wallet.
|
||||
if (!desc->HavePrivateKeys(*this) && !m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
|
||||
out.watch_descs.emplace_back(desc->ToString(), creation_time);
|
||||
|
||||
// Get the scriptPubKeys without writing this to the wallet
|
||||
|
||||
Reference in New Issue
Block a user