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

add CWalletTx::GetImmatureCredit() and use it in CWallet::GetImmatureBalance() #1479

Merged
merged 1 commit into from
Nov 13, 2012
Merged

add CWalletTx::GetImmatureCredit() and use it in CWallet::GetImmatureBalance() #1479

merged 1 commit into from
Nov 13, 2012

Conversation

Diapolo
Copy link

@Diapolo Diapolo commented Jun 18, 2012

This harmonizes CWallet::GetImmatureBalance() with CWallet::GetBalance() and CWallet::GetUnconfirmedBalance().

@gavinandresen
Copy link
Contributor

How should this be tested?

@sipa
Copy link
Member

sipa commented Jun 18, 2012

I suppose you could temporarily add an immature_amount to the gettransaction() RPC, and immature_balance to getinfo(), and mine a few blocks on testnet.

@Diapolo
Copy link
Author

Diapolo commented Jun 20, 2012

I "only" verified this patch with Bitcoin-Qt on testnet, I'm not sure how to test this with bitcoind, as I can't compile it. Help would be appreciated, as this testing is blocking a merge.

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/ed1afd67c1d3f485a9ba3850ba2751e50d897f53 for binaries and test log.

@luke-jr
Copy link
Member

luke-jr commented Aug 12, 2012

@Diapolo Those builds from @BitcoinPullTester should help you out

@Diapolo
Copy link
Author

Diapolo commented Aug 13, 2012

@luke-jr How does this help? You mean using the Qt version from jenkins and using it on testnet?

@luke-jr
Copy link
Member

luke-jr commented Aug 13, 2012

@Diapolo
Copy link
Author

Diapolo commented Aug 25, 2012

Guys, I setup bitcoind and can use it to pass RPC commands, but I simply don't know how you want me to test the function there, as GetImmatureBalance() seems to be only used by Qt?

I could for sure add obj.push_back(Pair("walletversion", pwalletMain->GetImmatureBalance())); to RPC getinfo, but as I can't compile bitcoind I would rely on @BitcoinPullTester to create a bitcoind.exe for me and need to revert that change before this would be considered mergeable.

@sipa
Copy link
Member

sipa commented Aug 25, 2012

GetImmatureBalance looks correct from reading it, and it's only used within the Qt code. I'm sure we can use it in RPC code as well, but let's do that later.

@Diapolo
Copy link
Author

Diapolo commented Aug 26, 2012

@sipa I didn't want to push or create a usage scenario for RPC, I just wanted to say I dunno how to further test this code :). As I said in Qt it does the job and asked if it will get accepted that way or what I can do now.

@sipa
Copy link
Member

sipa commented Aug 26, 2012

ACK on the changes to core; I didn't test the UI changes.

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/dfdd4dac8291b55fd96feea3b4545a0a5389e86b for binaries and test log.

@Diapolo
Copy link
Author

Diapolo commented Nov 13, 2012

Rebased!

const CWalletTx& pcoin = (*it).second;
if (pcoin.IsCoinBase() && pcoin.GetBlocksToMaturity() > 0 && pcoin.IsInMainChain())
nTotal += GetCredit(pcoin);
const CWalletTx* pcoin = &(*it).second;
Copy link
Member

Choose a reason for hiding this comment

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

Why change this to a pointer instead of a reference (&)? IMO &(*it).second; is slightly more ugly code, and in C++ it's generally advised to use references instead of pointers where possible (for type safety etc).

Copy link
Author

Choose a reason for hiding this comment

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

Same as below, I wanted this to be similar to the other functions, perhaps it would be a good idea to update all these to be more C++ style then? But I'm not sure if core devs would ACK such a change on that code-part?

Copy link
Member

Choose a reason for hiding this comment

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

Satoshi is a very bad person to learn C++ style from 🐩 If you want an example of well-structured, readable C++ I can recommend reading source from LLVM.
And I'm not sure either, it doesn't warrant changing all the functions I guess... maybe just leave it like this then.

laanwj added a commit that referenced this pull request Nov 13, 2012
add CWalletTx::GetImmatureCredit() and use it in CWallet::GetImmatureBalance()
@laanwj laanwj merged commit f2b1280 into bitcoin:master Nov 13, 2012
laudney pushed a commit to reddcoin-project/reddcoin-3.10 that referenced this pull request Mar 19, 2014
…edit

add CWalletTx::GetImmatureCredit() and use it in CWallet::GetImmatureBalance()
suprnurd pushed a commit to chaincoin-legacy/chaincoin that referenced this pull request Dec 5, 2017
lateminer pushed a commit to lateminer/bitcoin that referenced this pull request Jan 22, 2019
* ensure LTOR ordering of txs before creating and processing a block

* fix issue with minsize tx on regtest and other LTOR issue

* catch exception and return false, rather than letting the exception up the call stack (@gandrewstone)
lateminer pushed a commit to lateminer/bitcoin that referenced this pull request May 6, 2020
1117928 [GUI] Make WorkerTask work with contextual lock/unlock. (furszy)
bfc90e0 [GUI][Refactor] Remove global unlock context (random-zebra)
c737235 [GUI] masternodewidget: async unlock context for startAll (random-zebra)
a6977eb [GUI] Unlock: topbar, delete old context if any, before creating new (random-zebra)

Pull request description:

  **Problem**: startAll fails when the wallet is locked.

  **Cause**: startAll is executed as async background task, thus the lock context is lost (and the wallet is re-locked) when the execution gets to `startMN()`

  **Fix**: use a global unlock context pointer (as we did with the upgrade to HD flow).

ACKs for top commit:
  furszy:
    ACK 1117928
  Fuzzbawls:
    utACK 1117928

Tree-SHA512: fc8428f05196fd532d07049d45a192ee6888e271c2e67c2db69cc92a7938c73ba10ee826b9a8e3d902b3d020c9e7a9faf3ecb2eb1bd2b2d0ceb3a36d74618d08
@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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants