[wallet] Modify change identification to use hdsplit keypath #12983

pull instagibbs wants to merge 2 commits into bitcoin:master from instagibbs:ischangesplit changing 2 files +45 −18
  1. instagibbs commented at 9:54 PM on April 13, 2018: member

    Keypath data is a much more reliable way of detecting change outputs.

    There are a number of cases where the legacy detection fails, leading to odd results, such as a wallet rescan that results in missed results in listtransactions with self-sends.

  2. instagibbs renamed this:
    Modify change identification to use hdsplit keypath
    [wallet] Modify change identification to use hdsplit keypath
    on Apr 13, 2018
  3. instagibbs commented at 9:55 PM on April 13, 2018: member

    I will add listtransaction test soon.

  4. fanquake added the label Wallet on Apr 14, 2018
  5. instagibbs force-pushed on Apr 14, 2018
  6. instagibbs commented at 10:12 PM on April 14, 2018: member

    pushed a test that covered a corner case this fixes

    I realize the test itself carries a comment describing yet another corner case I've stumbled on that doesn't have any super easy fix. For the purposes of the testing what we care about I just set keypool=2 for a single node near the end of the test, but I could also just have the entire test with this setting, as it changes nothing about the overarching tests in place.

  7. instagibbs force-pushed on Apr 15, 2018
  8. instagibbs force-pushed on Apr 15, 2018
  9. instagibbs referenced this in commit 564826435c on Apr 16, 2018
  10. instagibbs referenced this in commit 274104a0cb on Apr 16, 2018
  11. instagibbs referenced this in commit 28b1948ec7 on Apr 16, 2018
  12. instagibbs referenced this in commit 4bd035d0b5 on Apr 16, 2018
  13. in src/wallet/wallet.cpp:1344 in 843e07cd5f outdated
    1350 | +            CKeyID key_id = GetKeyForDestination(*this, dest);
    1351 | +            if (!key_id.IsNull()) {
    1352 | +                auto it = mapKeyMetadata.find(key_id);
    1353 | +                if (it != mapKeyMetadata.end()) {
    1354 | +                    // Check for path
    1355 | +                    if (it->second.hdKeypath.find("m/0'/1'/") != std::string::npos) {
    


    jonasschnelli commented at 8:51 AM on April 17, 2018:

    Not for this PR, but we should probably factor out the static key path strings... maybe add a IsChangeKeypath().


    instagibbs commented at 2:06 PM on April 17, 2018:

    Yes, I think we should be more systematic about our keypath string handling; would make it easier for people like me with various wallet forks and for Core as we move forward with additional derivation features.

  14. jonasschnelli commented at 8:52 AM on April 17, 2018: contributor

    utACK 843e07cd5ffb4c9f8d73ef0e2aeed03303122a5b Seems to not create any performance impacts.

  15. jonasschnelli approved
  16. instagibbs referenced this in commit b22e3138b5 on Apr 18, 2018
  17. instagibbs referenced this in commit 6a776a753e on Apr 18, 2018
  18. instagibbs referenced this in commit f62872c5d4 on Apr 18, 2018
  19. instagibbs referenced this in commit 82e1cdcd66 on Apr 18, 2018
  20. instagibbs referenced this in commit 20dc5dc5a9 on Apr 18, 2018
  21. instagibbs referenced this in commit 08a57cb3f2 on Apr 18, 2018
  22. sipa commented at 11:39 PM on May 3, 2018: member

    I'm afraid this is not sufficient. It's possible to import change keys/addresses using importmulti (see the "internal" field); these aren't identified by having a change-like keypath. Furthermore, this approach will become even less reliable if it's possible to upgrade from pre-hd or pre-hdsplit wallets, as the old keys should remain being treated as change.

    You could use being present in a change-like key path as a shortcut still and fall back to the other mechanism otherwise, but I doubt that's very useful.

  23. instagibbs commented at 1:39 AM on May 4, 2018: member

    @sipa actually that suggestion is just fine for my needs, even if you aren't too excited about it.

  24. instagibbs force-pushed on May 8, 2018
  25. Modify change identification to use hdsplit keypath 89eab914c4
  26. test hdplit change detection 10b18f48d4
  27. instagibbs force-pushed on May 8, 2018
  28. instagibbs commented at 6:13 PM on May 8, 2018: member

    oh hmm, I see why now. I'll just carry it downstream for now.

  29. instagibbs closed this on May 8, 2018

  30. instagibbs referenced this in commit bfc350117f on May 15, 2018
  31. instagibbs referenced this in commit 6ecda18587 on May 15, 2018
  32. instagibbs referenced this in commit 513d484c57 on Jul 29, 2018
  33. instagibbs referenced this in commit 0e97d4e25f on Jul 29, 2018
  34. instagibbs referenced this in commit bb02c5ecf6 on Aug 13, 2018
  35. instagibbs referenced this in commit 3e63e57e1a on Aug 13, 2018
  36. MarcoFalke locked this on Sep 8, 2021

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: 2026-05-11 18:15 UTC

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