Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetBalance fix #1192

Merged
merged 1 commit into from
Jul 18, 2018
Merged

GetBalance fix #1192

merged 1 commit into from
Jul 18, 2018

Conversation

iFoggz
Copy link
Member

@iFoggz iFoggz commented Jun 26, 2018

Here is a simple fix to issue #1175

What happened in GUI is we check if IsTrusted() which in the case where if the input fFromMe its automatically trusted as it in a in wallet transaction only allowing u to use those inputs without the minimum required confirmations.

With sendtoaddress it pulls data from GetBalance()

In GetBalance() it does use IsTrusted() but also checks is IsConfirmed() (requires 10 confirmations to be true) this breaks the rule allowance from IsTrusted() resulting in the issue quez had in #1175 . The fix is to use (pcoin->IsConfirmed() || pcoin->fFromMe) which respects the 10 confirmation required from received transactions from outside the wallet while respecting the in wallet -> in wallet transactions.

This could also explain the occasional erroneous balance numbers when the case of available balance + unconfirmed balance != Total Balance. As unconfirmed does not include fFromMe as the rule considers it trusted as it is in-wallet->in-wallet transaction. and Available Balance did not show the right value as it did not include the in-wallet->in-wallet transaction.

Ive tested both scenarios with complete success.

  1. sent a tx to my test wallet and tried to sendtoaddress with that being less then 10 confirmations and resulted in a fail.
  2. sent a tx in-wallet -> in-wallet with less the 3 confirmations and worked correctly as it should
  3. getbalance rpc now shows the available balance in wallet properly to include if it is a in-wallet->in-wallet transaction while respecting incoming transactions from foreign addresses as unconfirmed. and gui balance shows correctly as well now.

@iFoggz
Copy link
Member Author

iFoggz commented Jun 26, 2018

note IsTrusted() would of returned false if a in-wallet->in-wallet transaction ended up conflicted as confirms -1 are no trusted so no worries about that side

@jamescowens
Copy link
Member

jamescowens commented Jul 2, 2018

@denravonska I believe this applies to more than just the GUI and also fixes one of the three core issues remaining with Bittrex. I just tested it and it appears to fix the short term balance hole problem. (The tests Paul did above and my tests cover the situation that would have affected Bittrex and caused the balance trip.) We need to merge this to staging.

@denravonska
Copy link
Member

denravonska commented Jul 7, 2018

It looks like they moved these conditions into IsTrusted in the Bitcoin tree. That might have a larger implication but it combines all the conditions into one place. Blackcoin does the same thing.

@iFoggz
Copy link
Member Author

iFoggz commented Jul 8, 2018 via email

@iFoggz
Copy link
Member Author

iFoggz commented Jul 9, 2018

ive looked at the tree we would have to add a condition thou since with bitcoin its one 1 confirm to be confirmed period. so likely
if (nDepth >= 1)
return true;
would become something around:

`if (nDepth >= 1 && IsFromMe)
return true;

if (nDepth >= 10)
return true;
`

the rest of bitcoins code there evaluates when confirms is 0

@jamescowens
Copy link
Member

Let's stick to a narrow change for this PR. We need to get this in production to fix one of the Bittrex issues. This really needs to go in Annie. We can align Gridcoin to Bitcoin's enum and other changes in a later milestone, where we have more time to test the implications.

@denravonska
Copy link
Member

Can you rebase this to staging?

Copy link
Contributor

@TheCharlatan TheCharlatan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like to see it in IsTrusted as well though.

@denravonska denravonska added this to the Annie Sue milestone Jul 18, 2018
@denravonska denravonska changed the base branch from development to staging July 18, 2018 05:47
@denravonska denravonska merged commit 5a40cde into gridcoin-community:staging Jul 18, 2018
@iFoggz
Copy link
Member Author

iFoggz commented Jul 18, 2018 via email

denravonska added a commit that referenced this pull request Jul 18, 2018
Changed
 - Balance now includes unconfirmed coins sent by self, #1192 (@Foggyx420).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants