wallet: fix blank legacy detection #30621

pull furszy wants to merge 1 commits into bitcoin:master from furszy:2024_fix_blank_legacy_detection changing 1 files +24 −24
  1. furszy commented at 11:34 pm on August 9, 2024: member

    Blank legacy wallets do not have active SPKM. They can only be detected by checking the descriptors’ flag or the db format.

    This enables the migration of blank legacy wallets in the GUI.

    To test this:

    1. Create a blank legacy wallet.
    2. Try to migrate it using the GUI’s toolbar “Migrate Wallet” button. -> In master: The button will be disabled because CWallet::IsLegacy() returns false for blank legacy wallet. -> In this PR: the button will be enabled, allowing the migration of legacy wallets.
  2. DrahtBot commented at 11:34 pm on August 9, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK achow101, tdb3, glozow

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Wallet on Aug 9, 2024
  4. DrahtBot added the label CI failed on Aug 10, 2024
  5. DrahtBot commented at 0:25 am on August 10, 2024: contributor

    🚧 At least one of the CI tasks failed. Debug: https://github.com/bitcoin/bitcoin/runs/28591532781

    Make sure to run all tests locally, according to the documentation.

    The failure may happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  6. furszy force-pushed on Aug 10, 2024
  7. DrahtBot removed the label CI failed on Aug 10, 2024
  8. tdb3 approved
  9. tdb3 commented at 11:19 pm on August 11, 2024: contributor

    ACK 30f701317b4a674fea422766ac3ee179c9c6f554

    Light code review. On the PR branch, created a blank legacy wallet, opened in bitcoin-qt. Saw that the migrate option was available and performed the migration.

    before_migration after_migration

  10. achow101 added this to the milestone 28.0 on Aug 12, 2024
  11. in src/wallet/wallet.cpp:1628 in 30f701317b outdated
    1624@@ -1625,7 +1625,11 @@ isminetype CWallet::IsMine(const CScript& script) const
    1625     }
    1626 
    1627     // Legacy wallet
    1628-    if (IsLegacy()) return GetLegacyScriptPubKeyMan()->IsMine(script);
    1629+    if (IsLegacy()) { // Blank legacy wallets have a null spkm
    


    achow101 commented at 6:40 pm on August 12, 2024:

    In 30f701317b4a674fea422766ac3ee179c9c6f554 “wallet: fix, detect blank legacy wallets in IsLegacy”

    IsLegacy() is unnecessary here now since GetLegacyScriptPubKeyMan() also checks for WALLET_FLAG_DESCRIPTORS.


    furszy commented at 9:19 pm on August 12, 2024:
    done
  12. in src/wallet/wallet.cpp:3596 in 30f701317b outdated
    3592@@ -3588,7 +3593,10 @@ std::unique_ptr<SigningProvider> CWallet::GetSolvingProvider(const CScript& scri
    3593     }
    3594 
    3595     // Legacy wallet
    3596-    if (IsLegacy() && GetLegacyScriptPubKeyMan()->CanProvide(script, sigdata)) return GetLegacyScriptPubKeyMan()->GetSolvingProvider(script);
    3597+    if (IsLegacy()) {
    


    achow101 commented at 6:41 pm on August 12, 2024:

    In 30f701317b4a674fea422766ac3ee179c9c6f554 “wallet: fix, detect blank legacy wallets in IsLegacy”

    IsLegacy() is unnecessary, same as above.


    furszy commented at 9:19 pm on August 12, 2024:
    done
  13. wallet: fix, detect blank legacy wallets in IsLegacy
    Blank legacy wallets do not have active SPKM. They can
    only be detected by checking the descriptors' flag or
    the db format.
    
    This enables the migration of blank legacy wallets in
    the GUI.
    6ed424f2db
  14. furszy force-pushed on Aug 12, 2024
  15. tdb3 commented at 11:03 pm on August 12, 2024: contributor

    Approach ACK

    Nice simplifications.

    Retested (https://github.com/bitcoin/bitcoin/pull/30621#pullrequestreview-2231909317) with same result (migration allowed).

    Saw some may be used uninitialized warnings when building, e.g.

    0 inlined from bool wallet::CWallet::IsSpentKey(const CScript&) const at wallet/wallet.cpp:1046:37:
    1./prevector.h:175:37: warning: *(const prevector<28, unsigned char, unsigned int, int>*)((char*)&<unnamed> + offsetof(const std::CTxDestination, std::variant<CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown>::<unnamed>.std::__detail::__variant::_Variant_base<CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown>::<unnamed>.std::__detail::__variant::_Move_assign_base<false, CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown>::<unnamed>.std::__detail::__variant::_Copy_assign_base<false, CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown>::<unnamed>.std::__detail::__variant::_Move_ctor_base<false, CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown>::<unnamed>.std::__detail::__variant::_Copy_ctor_base<false, CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown>::<unnamed>.std::__detail::__variant::_Variant_storage<false, CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown>::_M_u)).prevector<28, unsigned char>::_size may be used uninitialized [-Wmaybe-uninitialized]
    2  175 |     bool is_direct() const { return _size <= N; }
    3      |                                     ^~~~~
    4wallet/wallet.cpp: In member function bool wallet::CWallet::IsSpentKey(const CScript&) const:
    5wallet/wallet.cpp:1046:37: note: <anonymous> declared here
    6 1046 |         if (IsAddressPreviouslySpent(wpkh_dest)) {
    
  16. achow101 commented at 3:45 pm on August 14, 2024: member

    Saw some may be used uninitialized warnings when building, e.g.

    What compiler? I don’t see those warnings.

  17. achow101 commented at 3:48 pm on August 14, 2024: member
    ACK 6ed424f2db609f9f39ec1d1da2077c7616f3a0c2
  18. DrahtBot requested review from tdb3 on Aug 14, 2024
  19. maflcko commented at 6:28 am on August 15, 2024: member

    What compiler? I don’t see those warnings.

    Probably the known false positives, see https://cirrus-ci.com/task/5429325778911232?logs=ci#L2365 and https://github.com/bitcoin/bitcoin/issues/29359

  20. tdb3 commented at 11:13 am on August 15, 2024: contributor

    Saw some may be used uninitialized warnings when building, e.g.

    What compiler? I don’t see those warnings.

    gcc/g++ (Debian 12.2.0-14) 12.2.0

    Looks like it’s on my end. Did a fresh clone and build and didn’t see the same warnings.

  21. tdb3 approved
  22. tdb3 commented at 11:13 am on August 15, 2024: contributor
    ACK 6ed424f2db609f9f39ec1d1da2077c7616f3a0c2
  23. glozow commented at 3:52 pm on August 16, 2024: member
    ACK 6ed424f2db609f9f39ec1d1da2077c7616f3a0c2
  24. glozow merged this on Aug 16, 2024
  25. glozow closed this on Aug 16, 2024


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-21 09:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me