-
Notifications
You must be signed in to change notification settings - Fork 35.7k
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
Conversation
How should this be tested? |
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. |
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. |
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/ed1afd67c1d3f485a9ba3850ba2751e50d897f53 for binaries and test log. |
@Diapolo Those builds from @BitcoinPullTester should help you out |
@luke-jr How does this help? You mean using the Qt version from jenkins and using it on testnet? |
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 I could for sure add |
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. |
@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. |
ACK on the changes to core; I didn't test the UI changes. |
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/dfdd4dac8291b55fd96feea3b4545a0a5389e86b for binaries and test log. |
Rebased! |
const CWalletTx& pcoin = (*it).second; | ||
if (pcoin.IsCoinBase() && pcoin.GetBlocksToMaturity() > 0 && pcoin.IsInMainChain()) | ||
nTotal += GetCredit(pcoin); | ||
const CWalletTx* pcoin = &(*it).second; |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
add CWalletTx::GetImmatureCredit() and use it in CWallet::GetImmatureBalance()
…edit add CWalletTx::GetImmatureCredit() and use it in CWallet::GetImmatureBalance()
* 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)
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
This harmonizes
CWallet::GetImmatureBalance()
withCWallet::GetBalance()
andCWallet::GetUnconfirmedBalance()
.