Page MenuHomePhabricator

Merge #10999: Fix amounts formatting in `decoderawtransaction`
ClosedPublic

Authored by nakihito on Jun 14 2019, 22:05.

Details

Summary

ce07638 doc: Add comment to use ValueFromAmount/AmountFromValue for JSON, not utilmoneystr (Wladimir J. van der Laan)
ec05c50 rpc: Use ValueFromAmount instead of FormatMoney in TxToUniv (Wladimir J. van der Laan)
46347ad rpc: Move ValueFromAmount to core_write (Wladimir J. van der Laan)
dac3782 doc: Correct AmountFromValue/ValueFromAmount names (Wladimir J. van der Laan)

Pull request description:

With this, the amounts returned in `decoderawtransaction` will be padded to 8 digits like anywhere else in the API.

This is accomplished by using `ValueFromAmount` in `TxToUniv`, instead of `FormatMoney` which it currently (mistakingly) uses. The `FormatMoney` function is only for debugging/logging use!

To avoid dependency issues, `ValueFromAmount` is moved to `core_write.cpp`, where it also fits better. I don't move `AmountFromValue` to `core_read.cpp` at the same time, as this would have more impact due to the RPCError dependency there.

(n.b.: large number of changed files is solely due to the util_tests JSONs needing update)

Tree-SHA512: 10fc2d27d33a77dbcb57aa7eccd4f53110c05d38eb7df6d40f10f14c08fad4274472e93af75aa59fe68ad0720fdf0930f0108124abef518e0dd162b3d2b2b292

Backport of Core PR10999
https://github.com/bitcoin/bitcoin/pull/10999

Test Plan
make check
test_runner.py

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Owners added a reviewer: Restricted Owners Package.Jun 14 2019, 22:05
jasonbcox requested changes to this revision.Jun 14 2019, 23:58
jasonbcox added inline comments.
src/core_io.h
8 ↗(On Diff #9462)

Needs to be a bracketed include.

src/core_write.cpp
7 ↗(On Diff #9462)

Why add this here?

This revision now requires changes to proceed.Jun 14 2019, 23:58

Removed extra include in core_write.cpp and bracketed include in core_io.h.

deadalnix requested changes to this revision.Jun 15 2019, 00:39

developer notes are missing.

src/core_io.h
8 ↗(On Diff #9469)

This is not neede if you take the amount by ref (which is a signature change from the original, BTW).

This revision now requires changes to proceed.Jun 15 2019, 00:39

developer notes are missing.

Looks like developer notes were added in this patch: https://reviews.bitcoinabc.org/D2941

Removed #include <amount.h> from core_io.h and changed ValueFromAmount() to pass amount by value rather than pass by reference.

jasonbcox requested changes to this revision.Jun 17 2019, 17:32
jasonbcox added inline comments.
src/core_io.h
8 ↗(On Diff #9469)

Correct, this isn't needed if passed by ref. But the original PR *does* pass by reference: https://github.com/bitcoin/bitcoin/pull/10999/files#diff-b624a5b31a81f5bbdcb9f452719067e8R30

11 ↗(On Diff #9471)

This is correct.

30 ↗(On Diff #9471)

Keep the original pass by reference.

src/core_write.cpp
20 ↗(On Diff #9471)

ditto

This revision now requires changes to proceed.Jun 17 2019, 17:32

Changed amount to pass by reference again.

This revision is now accepted and ready to land.Jun 18 2019, 18:13