GUI: fix immature display in GUI / add balance updates on block change #1475

pull Diapolo wants to merge 1 commits into bitcoin:master from Diapolo:GUI_fix_immature changing 8 files +93 −30
  1. Diapolo commented at 1:36 PM on June 17, 2012: none

    As no one responds in #1432, I decided to create a pull for further discussion!

    • add GetImmatureCredit() function in CWalletTx
    • include clientModel in overviewpage and sendcoinsdialog
    • rename model to walletModel in overviewpage and sendcoinsdialog
    • update displayed balances when numBlocksChanged() SIGNAL occurs (as an immature balance matures via new blocks and not new Tx) on overviewpage and sendcoinsdialog
    • optimize handling of cached balances in walletmodell
  2. GUI: fix immature display in GUI / add balance updates on block change
    - add GetImmatureCredit() function in CWalletTx
    - include clientModel in overviewpage and sendcoinsdialog
    - rename model to walletModel in overviewpage and sendcoinsdialog
    - update displayed balances when numBlocksChanged() SIGNAL occurs (as
      an immature balance matures via new blocks and not new Tx) on
      overviewpage and sendcoinsdialog
    - optimize handling of cached balances in walletmodell
    de85dc35a1
  3. burger2 commented at 6:07 PM on June 17, 2012: contributor

    It's hard to test when testnet isn't working that good on my computer.

  4. laanwj commented at 6:34 PM on June 17, 2012: member

    I don't think this is the right solution. The view classes (Overviewpage, SendCoinsDialog, ...) should not be burdened with implementation details such as new blocks coming in. As I understand, there is a problem with WalletModel not sending the BalanceUpdated signal every time the Balance changes. Hence, this should be fixed in WalletModel.

    The problem seems to be that some kind of transactions (the "mined" ones) need to be baby-sitted for at least 120 blocks until they mature (normal transactions for 6, but this is correctly handled). However, re-computing the balance and updating the UI every time a block comes in also isn't a good solution as this may go very fast. This needs a timer (invoked only a few times per second) that recomputes the balance and issues a BalanceChanged signal if needed...

    Tangential: Can you try to keep 1) changes in which you rename all kinds of stuff and 2) functional changes separate? Mixing these makes it very hard to review code changes. Commits of type 1 can be verbose, whereas commits of type 2 should be as minimal as possible, especially if you make changes to the core as well as the UI.

  5. Diapolo commented at 7:41 PM on June 17, 2012: none

    @burger2 To fix your testnet problems try out #1477. Current master has a bug, which gives all testnet nodes on IRC the same NICK, which causes the current testnet3 troubles. @laanwj I think the immature balance, which then matures after 120 blocks is not taken correctly into account in terms of the balanceChanged signal. The state change from immature to mature, which also changes the current balance then, is not triggered by a transaction, so the emited balanceChanged signal in WalletModel::updateTransaction() does not help here. That's why I introduced a mechanism, which uses block-changes for this. If you have a cleaner / better idea I'm fine with a simpler patch :). The re-name was a logical thing for me here, because there are now 2 models in overviepage and sendcoinsdialog, so only e.g. setModel is missleading. I guess a timer is not needed if I add a check for IsInitialBlockDownload() in the code, as with a catched-up chain the processing won't happen that often.

  6. laanwj commented at 7:51 PM on June 17, 2012: member

    Yes, I'm going to implement this differently. This should really be restricted to WalletModel. It's indeed true that the balanceChanged signal in updateTransaction does not help here, but it could be emitted from different places as well. Having a non-functional balanceChanged signal and working around that means confusion for future updates, you should simply be able to connect to balanceChanged and have the most recent balance.

    Then, OverviewPage and SendcoinsDialog don't need the client model and everything there can be kept the same.

  7. Diapolo commented at 8:50 PM on June 17, 2012: none

    That's fine, if you are currently working on a patch I'm going to stop further progress here. What about the changes to wallet and walletmodel? I'll quote myself:

    I'm sure the current call to GetCredit(pcoin) can't be correct, as it does:

    <pre> if (IsCoinBase() && GetBlocksToMaturity() > 0) return 0; </pre>

    And this is the opposite of what we need for the immature coins, right?

  8. laanwj commented at 9:02 PM on June 17, 2012: member

    I'm not particularly known with that part of the code, but what do you think is wrong? To me, it reads like "If this is a coin-base (mined), and there are more than 0 blocks left to maturity, the credit is 0". Which makes sense to me.

  9. Diapolo commented at 9:09 PM on June 17, 2012: none

    It does a return 0; for the conditions we want to be true for adding immature coins together. Need to double check...

  10. Diapolo commented at 9:19 PM on June 17, 2012: none

    The current master code uses GetCredit() from CWallet, while I added GetImmatureCredit() into CWalletTx, which I think fit's better in there, as it's similar to CWallet::GetBalance() and CWallet::GetUnconfirmedBalance(). But you are probably right and the current code works.

  11. Diapolo commented at 9:33 PM on June 17, 2012: none

    @laanwj I showed sipa the code, who also thinks the new function (CWallet::GetUnconfirmedBalance()) is cleaner ... but as this is unrelated to fixing the base-issue, I will create another pull and close this one!

  12. Diapolo closed this on Jun 17, 2012

  13. laanwj commented at 5:38 AM on June 18, 2012: member

    The change in WalletModel also makes sense (makes it somewhat more readable). The only thing I don't agree with are the changes in the views.

  14. Diapolo commented at 6:13 AM on June 18, 2012: none

    That's fine, I'll open a new one and you patch the signal thing :).

  15. Diapolo commented at 1:16 PM on June 20, 2012: none

    @laanwj Is your fix on track for 0.7, any branch you want me to test?

  16. lateminer referenced this in commit 5dfcf187af on Jan 22, 2019
  17. lateminer referenced this in commit 3dddd25def on May 6, 2020
  18. lateminer referenced this in commit 172387aad5 on May 6, 2020
  19. DrahtBot 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-04-15 18:16 UTC

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