[qt] Move some WalletModel functions into CWallet #10295

pull ryanofsky wants to merge 4 commits into bitcoin:master from ryanofsky:pr/ipc-move changing 6 files +235 −54
  1. ryanofsky commented at 9:51 PM on April 28, 2017: contributor

    Motivation for moving these is to make supporting IPC simpler (#10102), so these lookups can be one-shot IPC requests, instead of back-and-forth interactions over the IPC channel.

    Also these functions are potentially useful outside of the bitcoin GUI (e.g. for RPCs).

  2. ryanofsky cross-referenced this on Apr 28, 2017 from issue Refactor: separate gui from wallet and node by ryanofsky
  3. jonasschnelli commented at 10:28 PM on April 28, 2017: contributor

    Yes. They belong to CWallet rather then WalletModel. The coincontrol's ListCoins function can potentially be useful for non GUI features. My only nit is if we should rename ListCoins to something more meaningful.

    Concept ACK.

  4. jonasschnelli added the label Refactoring on Apr 28, 2017
  5. jonasschnelli added the label Wallet on Apr 28, 2017
  6. in src/wallet/wallet.cpp:1991 in 861be88fa2 outdated
    1989 | @@ -1983,6 +1990,19 @@ CAmount CWallet::GetLegacyBalance(const isminefilter& filter, int minDepth, cons
    1990 |      return balance;
    1991 |  }
    1992 |  
    1993 | +CAmount CWallet::GetAvailableBalance(const CCoinControl* coinControl) const
    1994 | +{
    1995 | +    CAmount balance = 0;
    


    TheBlueMatt commented at 9:22 PM on May 3, 2017:

    nit: might be nice to LOCK here.


    jonasschnelli commented at 6:18 PM on May 4, 2017:

    Not sure if a lock is required at this point. Do you want to protect const CCoinControl* coinControl? AvailableCoins() does protect via cs_main/cs_wallet.


    TheBlueMatt commented at 8:26 PM on May 4, 2017:

    We have pointers in the COutput to entires in mapWallet, which can (theoretically) be delted out from under us thanks to the zap rpc.


    ryanofsky commented at 8:44 PM on May 4, 2017:

    Added in 14c1174c9aadb446c9a9e16626611f476610f4ba

  7. in src/wallet/wallet.cpp:2150 in 861be88fa2 outdated
    2105 | +            if (depth >= 0 && output.n < it->second.tx->vout.size() &&
    2106 | +                IsMine(it->second.tx->vout[output.n]) == ISMINE_SPENDABLE) {
    2107 | +                CTxDestination address;
    2108 | +                if (ExtractDestination(FindNonChangeParentOutput(*it->second.tx, output.n).scriptPubKey, address)) {
    2109 | +                    result[address].emplace_back(
    2110 | +                        &it->second, output.n, depth, true /* spendable */, true /* solvable */, false /* safe */);
    


    TheBlueMatt commented at 5:02 PM on May 4, 2017:

    Why did you change to false for safe here...looks like the old code did true? Does that have any effect?


    ryanofsky commented at 8:44 PM on May 4, 2017:

    Why did you change to false for safe here...looks like the old code did true? Does that have any effect?

    It has no effect (I'm not even exposing it to Qt any more after 7a7795fdd5fe86b9918b8055666b8365e4342eb6 in #10244) and false seemed like a more correct value.

  8. in src/qt/walletmodel.cpp:591 in 861be88fa2 outdated
     588 | @@ -596,37 +589,11 @@ bool WalletModel::isSpent(const COutPoint& outpoint) const
     589 |  void WalletModel::listCoins(std::map<QString, std::vector<COutput> >& mapCoins) const
     590 |  {
     591 |      std::vector<COutput> vCoins;
    


    TheBlueMatt commented at 5:03 PM on May 4, 2017:

    We dont need vCoins anymore either, no?


    ryanofsky commented at 8:44 PM on May 4, 2017:

    Removed in f8bfecf09037f3c49594ddc1ccadb9f98a354a84.

  9. TheBlueMatt commented at 5:04 PM on May 4, 2017: contributor

    Looks good, seems reasonable, though I hope we can delete half the code here (see #10337).

  10. ryanofsky force-pushed on May 4, 2017
  11. ryanofsky commented at 9:26 PM on May 4, 2017: contributor

    Squashed 14c1174c9aadb446c9a9e16626611f476610f4ba -> b6a9cc48fb950d1f0daa6c3db1df2bbc2b591ab0 (pr/ipc-move.2 -> pr/ipc-move.3)

  12. in src/qt/test/wallettests.cpp:84 in b6a9cc48fb outdated
      78 | @@ -80,8 +79,9 @@ QModelIndex FindTx(const QAbstractItemModel& model, const uint256& txid)
      79 |  //     src/qt/test/test_bitcoin-qt -platform xcb      # Linux
      80 |  //     src/qt/test/test_bitcoin-qt -platform windows  # Windows
      81 |  //     src/qt/test/test_bitcoin-qt -platform cocoa    # macOS
      82 | -void WalletTests::walletTests()
      83 | +void TestSendCoins()
      84 |  {
      85 | +    return;
    


    TheBlueMatt commented at 3:16 PM on May 5, 2017:

    Were you planning on re-enabling this?


    ryanofsky commented at 3:47 PM on May 5, 2017:

    Wow, good catch. Fixed in 01f847bf2b0ea395f8533e4d52c9422807af0566. This was just an accident, I didn't mean to disable it at all.

  13. ryanofsky force-pushed on May 5, 2017
  14. ryanofsky force-pushed on May 5, 2017
  15. ryanofsky force-pushed on May 5, 2017
  16. ryanofsky force-pushed on May 5, 2017
  17. ryanofsky commented at 3:48 PM on May 5, 2017: contributor

    Squashed 01f847bf2b0ea395f8533e4d52c9422807af0566 -> 38d3864eccd6abbbcf22619c8109a1b6e015f901 (pr/ipc-move.4 -> pr/ipc-move.5)

  18. in src/qt/walletmodel.cpp:625 in 38d3864ecc outdated
     622 | @@ -657,10 +623,7 @@ void WalletModel::listLockedCoins(std::vector<COutPoint>& vOutpts)
     623 |  void WalletModel::loadReceiveRequests(std::vector<std::string>& vReceiveRequests)
     624 |  {
     625 |      LOCK(wallet->cs_wallet);
    


    TheBlueMatt commented at 5:18 PM on May 5, 2017:

    nit: maybe push this lock down into GetDestValues?


    ryanofsky commented at 2:57 PM on May 9, 2017:

    Done in e60a3110c12a47fdcf7fb488b17ae145058c020e

  19. in src/wallet/wallet.cpp:2125 in 38d3864ecc outdated
    2081 | @@ -2060,6 +2082,59 @@ void CWallet::AvailableCoins(std::vector<COutput>& vCoins, bool fOnlySafe, const
    2082 |      }
    2083 |  }
    2084 |  
    2085 | +std::map<CTxDestination, std::vector<COutput>> CWallet::ListCoins() const
    2086 | +{
    2087 | +    std::map<CTxDestination, std::vector<COutput>> result;
    


    TheBlueMatt commented at 5:19 PM on May 5, 2017:

    nit: might be nice to AssertLockHeld here (because you cant call this without cs_wallet due to the COutput returns).


    ryanofsky commented at 3:02 PM on May 9, 2017:

    Not currently possible to just add the assert because Qt doesn't acquire the lock, but I added a todo in fe8c036cb87c62bee653fe581544c714ce8808d2

  20. TheBlueMatt commented at 5:19 PM on May 5, 2017: contributor

    utACK 38d3864eccd6abbbcf22619c8109a1b6e015f901

  21. ryanofsky force-pushed on May 9, 2017
  22. ryanofsky commented at 7:21 PM on May 9, 2017: contributor

    Squashed fe8c036cb87c62bee653fe581544c714ce8808d2 -> a226c97c336c44b4b8320328debea69e576f0fa8 (pr/ipc-move.6 -> pr/ipc-move.7)

  23. ryanofsky cross-referenced this on May 9, 2017 from issue Multiprocess bitcoin by ryanofsky
  24. [test] Add tests for some walletmodel functions
    Add unit tests for some walletmodel functions that will be refactored & moved
    in the next commit.
    ef8ca179ef
  25. [qt] Move some WalletModel functions into CWallet
    Motivation for moving these is to make supporting IPC simpler (#10102), so
    these lookups can be one-shot IPC requests, instead of back-and-forth
    interactions over the IPC channel.
    
    Also these functions are potentially useful outside of the bitcoin GUI (e.g.
    for RPCs).
    d944bd7a27
  26. [test] Move some tests from qt -> wallet
    After previous refactoring, the tests make more sense here.
    429aa9eb51
  27. Add missing LOCK2 in CWallet::GetAvailableBalance 108f04f2d9
  28. ryanofsky force-pushed on May 17, 2017
  29. ryanofsky force-pushed on May 17, 2017
  30. ryanofsky commented at 3:34 PM on May 17, 2017: contributor

    Rebased a226c97c336c44b4b8320328debea69e576f0fa8 -> 108f04f2d973adac5313c7e4e17a59766a3cc1b6 (pr/ipc-move.7 -> pr/ipc-move.8) because of conflict with #8952.

  31. laanwj added this to the "Blockers" column in a project

  32. laanwj commented at 5:29 PM on May 23, 2017: member

    utACK 108f04f

  33. laanwj merged this on May 23, 2017
  34. laanwj closed this on May 23, 2017

  35. laanwj referenced this in commit ce8176d038 on May 23, 2017
  36. sipa removed this from the "Blockers" column in a project

  37. ryanofsky cross-referenced this on Apr 6, 2018 from issue Add AssertLockHeld assertions in CWallet::ListCoins by ryanofsky
  38. MarcoFalke referenced this in commit b012bbe358 on Aug 31, 2018
  39. PastaPastaPasta referenced this in commit b38543c673 on Jun 20, 2019
  40. PastaPastaPasta referenced this in commit dc7380243f on Jul 6, 2019
  41. PastaPastaPasta referenced this in commit e966163ecb on Jul 8, 2019
  42. PastaPastaPasta referenced this in commit 9424192419 on Jul 9, 2019
  43. PastaPastaPasta referenced this in commit 785fa07015 on Jul 11, 2019
  44. barrystyle referenced this in commit 6f326a9d83 on Jan 22, 2020
  45. random-zebra cross-referenced this on Apr 28, 2021 from issue [Wallet] Laggard wallet-related backports from btc 0.15 by random-zebra
  46. random-zebra referenced this in commit 2d50b6e3b9 on Jun 9, 2021
  47. PastaPastaPasta referenced this in commit 3ed39fb7e8 on Jun 27, 2021
  48. PastaPastaPasta referenced this in commit 3639112c81 on Jun 28, 2021
  49. PastaPastaPasta referenced this in commit 1bbf70330f on Jun 29, 2021
  50. PastaPastaPasta referenced this in commit c079031e99 on Jun 29, 2021
  51. PastaPastaPasta referenced this in commit 017708af12 on Jun 29, 2021
  52. PastaPastaPasta referenced this in commit f411978924 on Jun 29, 2021
  53. PastaPastaPasta referenced this in commit 4c80a5f989 on Jun 29, 2021
  54. PastaPastaPasta referenced this in commit 7c120a7124 on Jul 1, 2021
  55. Munkybooty referenced this in commit 90c89bbfe8 on Jul 1, 2021
  56. bitcoin 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-20 06:55 UTC