Skip to content

Conversation

@morcos
Copy link
Contributor

@morcos morcos commented Mar 18, 2016

No longer consider coins which aren't in our mempool as adding to our spendable but unconfirmed balance. Add testing of this in abandonconflict.py.
Fixes #7690 (sort of)

This PR only changes the result of GetUnconfirmedBalance and AvailableCoins. Balances returned via GetAccountBalance such as the rpc call getbalance "" 0 were already unreliable in 0.11 and suffered a further regression in 0.12. It is recommended to use rpc call getunconfirmedbalance to get the unconfirmed portion of the balance.

Summary of effect on balances for various transaction types:
✅ - Reduces balance for coins spent and increases balance for coins received.
☑️ - Reduces balance for coins spent and increases unconfirmed balance for coins received
⬇️ - Reduces balance for coins spent, does not affect balance for any coins received
😨 - Increases unconfirmed balance for coins received, but does not reduce balance for coins spent
➖ - no effect on balance

tx status 0.11 0.12 #7715
Confirmed
Unconfirmed, in mempool ☑️ ☑️ ☑️
Unconfirmed, not in mempool ☑️ ⬇️
Unconfirmed, not in mempool, abandoned 😨
Unconfirmed, not in mempool, known to conflict
Unconfirmed, not in mempool, non-final 😨 ☑️ ⬇️
Unconfirmed, not in mempool, non-final, abandoned 😨 😨
Unconfirmed, not in mempool, non-final, known to conflict 😨 😨

No longer consider coins which aren't in our mempool.

Add test for regression in abandonconflict.py
@morcos
Copy link
Contributor Author

morcos commented Mar 21, 2016

@laanwj I think this PR is small enough and a clear enough improvement to a regression that it should be backported for 0.12.1.

@bittylicious
Copy link

I can confirm that this no longer shows the transaction that were abandoned on my client, so the patch seems to work as expected - thank you.

As you stated, getbalance doesn't work, and I can confirm "listaccounts 0" also doesn't work (it still shows this abandoned amount). Is there any possibility of allowing these commands to discount the abandoned transactions in another patch as I sadly rely on some deprecated accounting functionality at the moment (yes, I know I shouldn't).

@laanwj
Copy link
Member

laanwj commented Mar 23, 2016

utACK 68d4282

@laanwj laanwj merged commit 68d4282 into bitcoin:master Mar 23, 2016
laanwj added a commit that referenced this pull request Mar 23, 2016
68d4282 Fix calculation of balances and available coins. (Alex Morcos)
laanwj pushed a commit that referenced this pull request Mar 23, 2016
No longer consider coins which aren't in our mempool.

Add test for regression in abandonconflict.py

Github-Pull: #7715
Rebased-From: 68d4282
@morcos
Copy link
Contributor Author

morcos commented Mar 23, 2016

@bittylicious Unfortunately I don't see the situation improving for the account balance calculations. It's not related to abandontransaction technically, which was never meant to affect whether or not new coins are considered received, but it is related to whether newly received coins are countable in unconfirmed balance or not based on whether they are in the mempool which changed for 0.12. It's very difficult, maybe even impossible, to do account balance calculations properly, so I would expect them to just get more unreliable until they finally disappear. This particular problem should only affect balances for 0 confirms.

@laanwj
Copy link
Member

laanwj commented Mar 24, 2016

Unfortunately I don't see the situation improving for the account balance calculations

Unfortunately, I don't see so either.

Going forward on the account deprecation is #7729, which adds a label API. Labels behave almost as accounts do, except that they have no balance. I'd like to include that for 0.13. Then at some later time (possibly 0.14), the old account API, along with everything to do with account balance computation is going to be removed.

There's not much chance of anyone maintaining it in the mean time - some of the reasons for removing it in the first place are that the code is a mess, no one knows exactly how it behaves (nor should behave), it has some long-running problems, and thus no one wants to maintain it.

Accounts have been marked DEPRECATED since 0.11, and there was talk of doing so far before that. I'd urge you to start working on an implementation that doesn't need them.

If there is specific functionality that doesn't involve computing balances, but that you feel you cannot achieve without making use of accounts, do let us know (comment in #7729 or so).

@bittylicious
Copy link

Thanks @morcos and @laanwj for the analysis on this one. Naturally it's a shame the unconfirmed balance will seemingly always be off, but it's not a showstopper.

Thanks also for the estimated timescale for accounts being removed. I'm well aware of the deprecation of this functionality and there is an internal accounting mechanism there. It just needs more testing as it has a few bugs.

Ultimately, accounts are used indeed mainly for their balance. It also serves as a last chance emergency stop in case a user tries to send more coins than they have, enforced by bitcoind because the account balance would drop to zero. These can, of course, both be coded for outside of bitcoind, but it's always been nice having this emergency. Issues like this one though do show how the accounting functionality has suffered bit rot though so I understand the need to remove it eventually.

@maflcko
Copy link
Member

maflcko commented Apr 25, 2016

Backported in 19866c1; Removing label; Assuming this is not meant to be backported to 0.11?

thokon00 pushed a commit to faircoin/faircoin that referenced this pull request Jun 28, 2016
No longer consider coins which aren't in our mempool.

Add test for regression in abandonconflict.py

Github-Pull: bitcoin#7715
Rebased-From: 68d4282
codablock pushed a commit to codablock/dash that referenced this pull request Dec 19, 2017
68d4282 Fix calculation of balances and available coins. (Alex Morcos)
random-zebra added a commit to PIVX-Project/PIVX that referenced this pull request Oct 9, 2019
91b48c7 [Build] Add new merkle files to CMake lists (warrows)
48a3aff [Wallet] Ignore coinbase and zc tx "conflicts" (warrows)
3572354 [Wallet] Fix an error in tx depth computation (warrows)
6928369 [Tests] Enable abandonconflict functional test (warrows)
34cd496 Fix that CWallet::AbandonTransaction would only traverse one level (Ben Woosley)
aba5b75 Fix calculation of balances and available coins. (Alex Morcos)
48d705f Remove stale wallet transactions on initial load. (presstab)
12985ae Flush wallet after abandontransaction (Alex Morcos)
8f87956 [Wallet] sort pending wallet transactions before reaccepting (dexX7)
9c2f445 [Wallet] Call notification signal when a transaction is abandoned (Jonas Schnelli)
778ebf3 Add new rpc call: abandontransaction (Alex Morcos)
0e86c3e Make wallet descendant searching more efficient (Alex Morcos)
d0083a8 Make sure conflicted wallet tx's update balances (Alex Morcos)
6a50e03 [Wallet] Keep track of explicit wallet conflicts instead of using mempool (warrows)
7ccb2b5 [Wallet] Do not flush the wallet in AddToWalletIfInvolvingMe(..) (warrows)
47345be [Refactor] Move wallet functions out of header (warrows)
ab9efb8 [Wallet] Switch to a constant-space Merkle root/branch algorithm (warrows)
5447622 [Wallet] Do not store Merkle branches in the wallet (warrows)

Pull request description:

  This pull request is a happy melting pot of improvements regarding transactions handling. Most of them are backports from bitcoin. I advise reviewers to check the code of the different commits independently to understand them more easily. However, testing is probably better done all at once.
  I am making a single pull request because these changes are all entangled and introducing some of them without others would probably introduce temporary bugs.

  ## Commits details ##
  - 6c3e2ac backport of bitcoin#6550
  - 5304fdf backport of bitcoin#6508
  - c3eeeac simple code move from the header to the cpp file. It contains no functional change.
  - 6cc4d37 backport of bitcoin#4805
  - 10be1db backport of bitcoin#7105
  - 8a34c32 backport of bitcoin#7306
  - 3caf123, 9e17178 and 240f5b4 are the backport for bitcoin#7312
  - ad6d0b1 backport of bitcoin#5511
  - fcc07c3 backport of bitcoin#9311
  - 5ed5e26 is an update of #825
  - 392d504 backport of bitcoin#7715
  - 7199f3a backport of bitcoin#13652
  - f09d999 enables and fixes the test from bitcoin#7312
  - 4fd43c5 fixes an oversight in bitcoin#7105 backport

ACKs for top commit:
  random-zebra:
    ACK 91b48c7
  Fuzzbawls:
    ACK 91b48c7

Tree-SHA512: 2628cebe98805b8048b920b51ee26fd4f0c53643d78da9b8cb265aede52dfe1d40c8c19d34293c232c5c35be7f1ab89ff5b4a07073a4b27c371ea70eb8708669
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unconfirmedbalance shows fake amount (50.xxxxx btcs)

4 participants