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

Bring back "getunconfirmedbalance" #1463

Closed
NickP1 opened this issue May 13, 2019 · 10 comments
Closed

Bring back "getunconfirmedbalance" #1463

NickP1 opened this issue May 13, 2019 · 10 comments

Comments

@NickP1
Copy link

NickP1 commented May 13, 2019

Bring back the rpc command for getunconfirmedbalance so we can see that a transaction is received pending minimum confirmations.

@RoboticMind
Copy link
Contributor

RoboticMind commented May 13, 2019

Do you know what was the reason for removing it was?

@NickP1
Copy link
Author

NickP1 commented May 13, 2019

No. It was apparently an rpc command available in earlier version of bitcoin core. Would be nice to have it back as there is no easy way to get that info from rpc.

@jamescowens
Copy link
Member

I don't believe we have ever had it.

@RoboticMind
Copy link
Contributor

Looks like the function CWallet::GetUnconfirmedBalance() would make it relatively easy to implement since that's most of the work needed to set it up

@jamescowens
Copy link
Member

Yes. We can create an rpc wrapper pretty easily for that.

@jamescowens
Copy link
Member

jamescowens commented May 14, 2019

I don't think that command provides what you guys think given the if statement conditions...

int64_t CWallet::GetUnconfirmedBalance() const
{
    int64_t nTotal = 0;
    {
        LOCK2(cs_main, cs_wallet);
        for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
        {
            const CWalletTx* pcoin = &(*it).second;
            if (!IsFinalTx(*pcoin) || (!pcoin->IsConfirmed() && !pcoin->fFromMe && pcoin->IsInMainChain()))
                nTotal += pcoin->GetAvailableCredit();
        }
    }
    return nTotal;
}

@RoboticMind
Copy link
Contributor

Wait that's weird, why does it only do that if the balance is zero?

@jamescowens
Copy link
Member

the nTotal = 0 just initializes the accumulator outside of the for loop. The contents of the if statement is what worries me is the logic in the if statement...

hmm... in quasi English...

if the transaction is NOT final OR (NOT confirmed AND NOT FromME AND IsInMainChain)

Does that do the right thing if the transaction is not final?

@RoboticMind
Copy link
Contributor

RoboticMind commented May 14, 2019

oh sorry misread as if (nTotal == 0)

@jamescowens
Copy link
Member

Implemented the wrapper. Let's see if this gives you what you need.

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

No branches or pull requests

3 participants