Replaces int64_t with a typedef in all monetary contexts.
See #4067 for a more thorough description of this patch and associated context.
ACK.
To review, git show --word-diff-regex='[[:alnum:]]+|[^[:space:]]'
may be useful.
I get quite a few compile errors in the Qt GUI. I think you’re missing some casts here and there:
http://www.hastebin.com/mamaxumafo.vbs
Mind that qint64 and int64_t are defined differently (long long versus long on AMD64), so converting between then needs casts.
I tend to focus on pulls that fix bugs, add tests or change functionality in a useful way, so ‘all over the place’ changes like this tend to end up in the back burner.
Last time it introduced a build problem for me. As that’s fixed, and when this is rebased, I’m fine with merging it.
I’m reviewing as well, comparing with my own rebase.
I don’t mind changing the name, but only if we get consensus. Amount is way too generic IMHO. Amount of what? Fees? We have a separate class (CFeeRate) for that. CMoney/Money isn’t ideal, but I don’t see a better, succinct option…
Well it’s better than Value. We should stop bike-shedding here and simply decide. Otherwise we’ll still have this open in a month. @jtimon likes Amount, @sipa likes Amount, I like Amount. So that’s our consensus.
To be entirely clear, just add a comment what it is about in amount.h where you define the type.
38@@ -39,7 +39,7 @@ class COrphan
39 CFeeRate feeRate;
40 double dPriority;
41
42- COrphan(const CTransaction* ptxIn) : ptx(ptxIn), feeRate(0), dPriority(0)
43+ COrphan(const CTransaction* ptxIn) : ptx(ptxIn), dPriority(0), feeRate(0)
That… is a fine question. I swear at one point during the rebase I was getting out-of-order initialization warnings, so I switched it. But looking at the diff, the prior ordering is obviously correct. Thank you for catching it.
I’ve pushed a new squashed commit that reverses that one hunk.
35@@ -34,8 +36,8 @@ class OverviewPage : public QWidget
36 void showOutOfSyncWarning(bool fShow);
37
38 public slots:
39- void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance,
40- qint64 watchOnlyBalance, qint64 watchUnconfBalance, qint64 watchImmatureBalance);
41+ void setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance,
42+ const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance);
BTW we have many signal/slot definitions like this:
0connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64, qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64, qint64, qint64, qint64)));
I’m fairly sure that these need to be updated to use CAmount as well. No need to add & or const in these SIGNAL() and SLOT() definitions (they are ignored), but the type needs to match.
Also the CAmount type likely has to be registered to Qt at some point to be able to pass it in this way (see http://qt-project.org/doc/qt-4.8/custom-types.html).
As long as CAmount is the same type as qint64 I imagine it will keep working, but it seems brittle.
It cannot be merged like this. One thing needs to be done here, either:
Connecting the signals/slots with amounts as qint64 but having them as CAmount in the .h file is difficult to read, and may break randomly.
Lots of conflicts already…
0UU src/coins.cpp
1UU src/coins.h
2UU src/core.cpp
3UU src/main.h
4UU src/miner.cpp
5UU src/qt/transactionfilterproxy.h
6UU src/qt/walletmodel.cpp
7UU src/qt/walletmodel.h
8UU src/rpcrawtransaction.cpp
9UU src/rpcserver.cpp
10UU src/rpcwallet.cpp
11UU src/txmempool.cpp
12UU src/util.cpp
13UU src/util.h
Automatic sanity-testing: FAILED BUILD/TEST, see http://jenkins.bluematt.me/pull-tester/p4234_57c858d8c179a14487a6a85f5dbbc2b087d21e30/ for binaries and test log.
This could happen for one of several reasons:
If you believe this to be in error, please ping BlueMatt on freenode or TheBlueMatt here.
This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.
Automatic sanity-testing: FAILED BUILD/TEST, see http://jenkins.bluematt.me/pull-tester/p4234_a8df9965b68498292a1cc588b4ebdc6622b79499/ for binaries and test log.
This could happen for one of several reasons:
If you believe this to be in error, please ping BlueMatt on freenode or TheBlueMatt here.
This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.
Automatic sanity-testing: FAILED BUILD/TEST, see http://jenkins.bluematt.me/pull-tester/p4234_a372168e77a8a195613a02983f2589252698bf0f/ for binaries and test log.
This could happen for one of several reasons:
If you believe this to be in error, please ping BlueMatt on freenode or TheBlueMatt here.
This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.
8+
9+#include <stdint.h>
10+
11+typedef int64_t CAmount;
12+
13+#endif
#endif // BITCOIN_AMOUNT_H
!
Wladimir made an in-line comment about that already. The right and proper thing to do is to abstract the interface between the two, and to register / provide the necessary hooks for Qt to handle CAmount natively in slot definitions.
I’ll be honest though, I’m not going to have time to write that in the next 1-2 weeks. Given how quickly this PR atrophies, it’s probably better to do that as a separate PR.
@sipa The point is that I am not sure how Qt handles types, ie, CAmount that are not directly registered to the system but used nevertheless in slot/signal descriptions. It does some magic especially when serializing for cross-thread messages, and it may be that this only works by accident.
Has anyone actually tested the wallet GUI with this? That amounts still work correctly when receiving and sending? That update signals still come through properly?
Thanks for testing @jtimon .
I don’t like merging this in good faith. What if it breaks only on some platforms? Having wrong amounts would be the greatest screw-up possible in a GUI. So I’m going to do some testing myself and research the qt documentation on what to do here first.
OK - I’ve verified all three signals involving CAmount:
WalletModel::balanceChanged(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)
WalletView::incomingTransaction(QString,int,CAmount,QString,QString)
OptionsModel::transactionFeeChanged(CAmount)
I’ve also added code to make it possible to send CAmount over queued connections (just two lines).
Fixes are here https://github.com/laanwj/bitcoin/commit/c122f5528c882efc8aebe31fd4d84612175f66aa
Note: after merging this, be sure to start building from scratch - I had some strange issues with setting the fee in the options that went away with a clean build.
13@@ -14,6 +14,7 @@
14 #include "config/bitcoin-config.h"
15 #endif
16
17+#include "amount.h"