WIP: RFC: consensus: Make CAmount a class #35511

Draft
hodlinator wants to merge 12 commits from 2026/06/safer_camount.take2 into master AGit
hodlinator commented 2026-06-11 10:06:17 +00:00 (Migrated from github.com)

We should treat people's money with care across node and wallet.

Having our CAmount be a typedef for raw int64_t as on master has the following drawbacks:

  • Allows assigning to from bools, leading to the issues like the one previously fixed by 0026b330c4.
  • Allows direct comparison with integral types of differing size, leading to things like the issue previously fixed by 890a09b1e4 (reverting it on top of this PR leads to compile errors).
  • Allows forgetting to initialize amounts (CAmount fee;).
  • Allows direct operations with imprecise decimal types as in CAmount target = 49.5L * COIN in src/wallet/test/coinselector_tests.cpp.
  • Allows multiplying two CAmounts with each other, which does not make sense.

Beyond fixing the above, this PR also makes amounts stick out more in code - either by the CAmount type itself or by using the sats unit specifier.

This work is also a stepping stone for possible future work introducing an even safer amount type which only allows values in the range [0, MAX_MONEY].

Already merged PRs spawned out of this work: #35456, #35372

Prior attempts in similar directions: #5430, #4067

We should treat people's money with care across node and wallet. Having our `CAmount` be a `typedef` for raw `int64_t` as on master has the following drawbacks: * Allows assigning to from `bool`s, leading to the issues like the one previously fixed by 0026b330c4abbbbdb96e4f0c4d380d70d8e592ab. * Allows direct comparison with integral types of differing size, leading to things like the issue previously fixed by 890a09b1e49925315a5636f29cc5af36928fe092 (reverting it on top of this PR leads to compile errors). * Allows forgetting to initialize amounts (`CAmount fee;`). * Allows direct operations with imprecise decimal types as in `CAmount target = 49.5L * COIN` in src/wallet/test/coinselector_tests.cpp. * Allows *multiplying* two `CAmount`s with each other, which does not make sense. Beyond fixing the above, this PR also makes amounts stick out more in code - either by the `CAmount` type itself or by using the `sats` unit specifier. This work is also a stepping stone for possible future work introducing an even safer amount type which only allows values in the range `[0, MAX_MONEY]`. Already merged PRs spawned out of this work: #35456, #35372 Prior attempts in similar directions: #5430, #4067
DrahtBot commented 2026-06-11 10:06:42 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Concept ACK sedited, ryanofsky

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #bitcoin-core/gui/952 (Adds non-mempool wallet balance to overview by polespinasa)
  • #36743 ([RFC] build: build with -Wmissing-declarations/prototypes by fanquake)
  • #36741 (policy: Document rounding behavior of feerate fee getters by maflcko)
  • #36696 (CTransaction: Add constructor taking inputs and outputs by purpleKarrot)
  • #36694 (test: construct mempool_tests inputs/outputs declaratively by alexanderwiederin)
  • #36686 (test: cover cumulative input value range in CheckTxInput tests. by KY-U)
  • #36603 (Improve loadtxoutset performance by ajtowns)
  • #36601 (test: avoid reusing AssumeUTXO coin insertion method in test fixtures by l0rinc)
  • #36539 (gui: Use PSBT v0 by davidgumberg)
  • #36525 (mining: add getTotalFees(), protect m_block_template with mutex by Sjors)
  • #36451 (refactor: Use NotNull for CreateNewBlock and pimpls by maflcko)
  • #36386 (compressor: oversized script decoding can leave a spendable script by l0rinc)
  • #36384 (rpc: Use self.Arg<_>(name) helper over manual and duplicate parsing by maflcko)
  • #36367 (mempool: keep prioritisetransaction deltas within MAX_MONEY by Bruce039)
  • #36357 (mining: move BlockAssembler statics into BlockTemplateManager by w0xlt)
  • #36356 (mining: move getblocktemplate cache into BlockTemplateManager by w0xlt)
  • #36342 (wallet: reject recipient amounts above MAX_MONEY by Bruce039)
  • #36280 (validation: throw when a compressed script can't be decompressed by furszy)
  • #36255 (Refactor CoinGrinder tests by murchandamus)
  • #36188 (crypto: plug hardware optimized SHA256 into libsecp256k1's context by furszy)
  • #36167 ([RFC] Enable -Wunused by fanquake)
  • #36097 (mining: replace interrupt methods with cancellation arguments by xyzconstant)
  • #36074 (scripted-diff: [test] Add util/check.h includes for assertions by maflcko)
  • #36068 (fuzz: reuse one fuzzed wallet across inputs by brunoerg)
  • #36066 (validation: Separate check-only version of ConnectBlock by optout21)
  • #35997 (refactor: bench: make_hard_case to find a solution by yancyribbens)
  • #35751 (validation: use parallel input prevout fetching in TestBlockValidity by andrewtoth)
  • #35713 (Remove boost as a unit test runner by rustaceanrob)
  • #35641 (kernel: Add script evaluation tracer by sedited)
  • #35557 (kernel, validation: Add btck_chainstate_manager_set_clock_time by ryanofsky)
  • #34824 (net: encapsulate TxRelay state and replace recursive mutexes by w0xlt)
  • #34698 (wallet: handle MiniMiner bump fee calculation failures by shuv-amp)
  • #34405 (wallet: skip APS when no partial spend exists by 8144225309)
  • #34360 (bench: add WalletBalanceManySpent for high-history wallet scenario by w0xlt)
  • #33741 (rpc: Optionally print feerates in sat/vb by polespinasa)
  • #32387 (ipc: add windows support by ryanofsky)
  • #31260 (scripted-diff: Type-safe settings retrieval by ryanofsky)
  • #30343 (wallet, logging: Replace WalletLogPrintf() with LogInfo() by ryanofsky)
  • #29700 (kernel, refactor: return error status on all fatal errors by ryanofsky)
  • #29491 ([EXPERIMENTAL] Schnorr batch verification for blocks by fjahr)
  • #29409 (ipc: Expose Chain interface to IPC clients by ryanofsky)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

LLM Linter (✨ experimental)

Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

  • src/test/rbf_tests.cpp: PaysForRBF(high_fee, high_fee - 1*sats, 1, CFeeRate(0*sats), unused_txid)
  • src/test/rbf_tests.cpp: PaysForRBF(high_fee, high_fee + 1*sats, 11, incremental_relay_feerate, unused_txid)
  • src/test/rbf_tests.cpp: PaysForRBF(high_fee, high_fee + 1*sats, 10, incremental_relay_feerate, unused_txid)
  • src/test/rbf_tests.cpp: PaysForRBF(high_fee, high_fee + 2*sats, 11, higher_relay_feerate, unused_txid)
  • src/test/rbf_tests.cpp: PaysForRBF(high_fee, high_fee + 4*sats, 20, higher_relay_feerate, unused_txid)
  • src/test/rbf_tests.cpp: StageAddition(tx1_conflict, tx1_fee + 1*sats, 0, 1, 0, false, 4, LockPoints())
  • src/test/rbf_tests.cpp: StageAddition(tx3, tx2_fee, 0, 1, 0, false, 4, LockPoints())
  • src/test/rbf_tests.cpp: CreateValidMempoolTransaction(tx_parent, 0, 101, child_key, child_spk, coinbase_value - low_fee_amt - 300*sats, false)

2026-11-24 19:35:39

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/35511 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/35511.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/35511#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | Concept ACK | [sedited](https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4679584491), [ryanofsky](https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4712614640) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#bitcoin-core/gui/952](https://github.com/bitcoin-core/gui/pull/952) <sub><img src="https://drahtbot.space/ack_count/bitcoin-core/gui/952.svg"></sub> (Adds non-mempool wallet balance to overview by polespinasa) * [#36743](https://github.com/bitcoin/bitcoin/pull/36743) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36743.svg"></sub> ([RFC] build: build with -Wmissing-declarations/prototypes by fanquake) * [#36741](https://github.com/bitcoin/bitcoin/pull/36741) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36741.svg"></sub> (policy: Document rounding behavior of feerate fee getters by maflcko) * [#36696](https://github.com/bitcoin/bitcoin/pull/36696) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36696.svg"></sub> (CTransaction: Add constructor taking inputs and outputs by purpleKarrot) * [#36694](https://github.com/bitcoin/bitcoin/pull/36694) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36694.svg"></sub> (test: construct `mempool_tests` inputs/outputs declaratively by alexanderwiederin) * [#36686](https://github.com/bitcoin/bitcoin/pull/36686) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36686.svg"></sub> (test: cover cumulative input value range in CheckTxInput tests. by KY-U) * [#36603](https://github.com/bitcoin/bitcoin/pull/36603) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36603.svg"></sub> (Improve loadtxoutset performance by ajtowns) * [#36601](https://github.com/bitcoin/bitcoin/pull/36601) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36601.svg"></sub> (test: avoid reusing AssumeUTXO coin insertion method in test fixtures by l0rinc) * [#36539](https://github.com/bitcoin/bitcoin/pull/36539) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36539.svg"></sub> (gui: Use PSBT v0 by davidgumberg) * [#36525](https://github.com/bitcoin/bitcoin/pull/36525) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36525.svg"></sub> (mining: add getTotalFees(), protect m_block_template with mutex by Sjors) * [#36451](https://github.com/bitcoin/bitcoin/pull/36451) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36451.svg"></sub> (refactor: Use NotNull for CreateNewBlock and pimpls by maflcko) * [#36386](https://github.com/bitcoin/bitcoin/pull/36386) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36386.svg"></sub> (compressor: oversized script decoding can leave a spendable script by l0rinc) * [#36384](https://github.com/bitcoin/bitcoin/pull/36384) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36384.svg"></sub> (rpc: Use self.Arg<_>(name) helper over manual and duplicate parsing by maflcko) * [#36367](https://github.com/bitcoin/bitcoin/pull/36367) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36367.svg"></sub> (mempool: keep prioritisetransaction deltas within MAX_MONEY by Bruce039) * [#36357](https://github.com/bitcoin/bitcoin/pull/36357) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36357.svg"></sub> (mining: move BlockAssembler statics into BlockTemplateManager by w0xlt) * [#36356](https://github.com/bitcoin/bitcoin/pull/36356) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36356.svg"></sub> (mining: move getblocktemplate cache into BlockTemplateManager by w0xlt) * [#36342](https://github.com/bitcoin/bitcoin/pull/36342) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36342.svg"></sub> (wallet: reject recipient amounts above MAX_MONEY by Bruce039) * [#36280](https://github.com/bitcoin/bitcoin/pull/36280) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36280.svg"></sub> (validation: throw when a compressed script can't be decompressed by furszy) * [#36255](https://github.com/bitcoin/bitcoin/pull/36255) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36255.svg"></sub> (Refactor CoinGrinder tests by murchandamus) * [#36188](https://github.com/bitcoin/bitcoin/pull/36188) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36188.svg"></sub> (crypto: plug hardware optimized SHA256 into libsecp256k1's context by furszy) * [#36167](https://github.com/bitcoin/bitcoin/pull/36167) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36167.svg"></sub> ([RFC] Enable `-Wunused` by fanquake) * [#36097](https://github.com/bitcoin/bitcoin/pull/36097) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36097.svg"></sub> (mining: replace interrupt methods with cancellation arguments by xyzconstant) * [#36074](https://github.com/bitcoin/bitcoin/pull/36074) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36074.svg"></sub> (scripted-diff: [test] Add util/check.h includes for assertions by maflcko) * [#36068](https://github.com/bitcoin/bitcoin/pull/36068) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36068.svg"></sub> (fuzz: reuse one fuzzed wallet across inputs by brunoerg) * [#36066](https://github.com/bitcoin/bitcoin/pull/36066) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36066.svg"></sub> (validation: Separate check-only version of ConnectBlock by optout21) * [#35997](https://github.com/bitcoin/bitcoin/pull/35997) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35997.svg"></sub> (refactor: bench: make_hard_case to find a solution by yancyribbens) * [#35751](https://github.com/bitcoin/bitcoin/pull/35751) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35751.svg"></sub> (validation: use parallel input prevout fetching in TestBlockValidity by andrewtoth) * [#35713](https://github.com/bitcoin/bitcoin/pull/35713) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35713.svg"></sub> (Remove boost as a unit test runner by rustaceanrob) * [#35641](https://github.com/bitcoin/bitcoin/pull/35641) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35641.svg"></sub> (kernel: Add script evaluation tracer by sedited) * [#35557](https://github.com/bitcoin/bitcoin/pull/35557) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35557.svg"></sub> (kernel, validation: Add btck_chainstate_manager_set_clock_time by ryanofsky) * [#34824](https://github.com/bitcoin/bitcoin/pull/34824) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34824.svg"></sub> (net: encapsulate TxRelay state and replace recursive mutexes by w0xlt) * [#34698](https://github.com/bitcoin/bitcoin/pull/34698) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34698.svg"></sub> (wallet: handle MiniMiner bump fee calculation failures by shuv-amp) * [#34405](https://github.com/bitcoin/bitcoin/pull/34405) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34405.svg"></sub> (wallet: skip APS when no partial spend exists by 8144225309) * [#34360](https://github.com/bitcoin/bitcoin/pull/34360) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34360.svg"></sub> (bench: add WalletBalanceManySpent for high-history wallet scenario by w0xlt) * [#33741](https://github.com/bitcoin/bitcoin/pull/33741) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/33741.svg"></sub> (rpc: Optionally print feerates in sat/vb by polespinasa) * [#32387](https://github.com/bitcoin/bitcoin/pull/32387) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/32387.svg"></sub> (ipc: add windows support by ryanofsky) * [#31260](https://github.com/bitcoin/bitcoin/pull/31260) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/31260.svg"></sub> (scripted-diff: Type-safe settings retrieval by ryanofsky) * [#30343](https://github.com/bitcoin/bitcoin/pull/30343) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/30343.svg"></sub> (wallet, logging: Replace WalletLogPrintf() with LogInfo() by ryanofsky) * [#29700](https://github.com/bitcoin/bitcoin/pull/29700) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/29700.svg"></sub> (kernel, refactor: return error status on all fatal errors by ryanofsky) * [#29491](https://github.com/bitcoin/bitcoin/pull/29491) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/29491.svg"></sub> ([EXPERIMENTAL] Schnorr batch verification for blocks by fjahr) * [#29409](https://github.com/bitcoin/bitcoin/pull/29409) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/29409.svg"></sub> (ipc: Expose Chain interface to IPC clients by ryanofsky) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3--> ### LLM Linter (✨ experimental) Possible places where named args for integral literals may be used (e.g. `func(x, /*named_arg=*/0)` in C++, and `func(x, named_arg=0)` in Python): - `src/test/rbf_tests.cpp`: `PaysForRBF(high_fee, high_fee - 1*sats, 1, CFeeRate(0*sats), unused_txid)` - `src/test/rbf_tests.cpp`: `PaysForRBF(high_fee, high_fee + 1*sats, 11, incremental_relay_feerate, unused_txid)` - `src/test/rbf_tests.cpp`: `PaysForRBF(high_fee, high_fee + 1*sats, 10, incremental_relay_feerate, unused_txid)` - `src/test/rbf_tests.cpp`: `PaysForRBF(high_fee, high_fee + 2*sats, 11, higher_relay_feerate, unused_txid)` - `src/test/rbf_tests.cpp`: `PaysForRBF(high_fee, high_fee + 4*sats, 20, higher_relay_feerate, unused_txid)` - `src/test/rbf_tests.cpp`: `StageAddition(tx1_conflict, tx1_fee + 1*sats, 0, 1, 0, false, 4, LockPoints())` - `src/test/rbf_tests.cpp`: `StageAddition(tx3, tx2_fee, 0, 1, 0, false, 4, LockPoints())` - `src/test/rbf_tests.cpp`: `CreateValidMempoolTransaction(tx_parent, 0, 101, child_key, child_spk, coinbase_value - low_fee_amt - 300*sats, false)` <sup>2026-11-24 19:35:39</sup>
sedited commented 2026-06-11 10:26:58 +00:00 (Migrated from github.com)

Concept ACK

Concept ACK
DrahtBot commented 2026-06-11 11:40:17 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task test ancestor commits: https://github.com/bitcoin/bitcoin/actions/runs/27339510417/job/80774458061
LLM reason (✨ experimental): CI failed because the fuzz target wouldn’t compile: clang++ reported -Wc++11-narrowing errors in coinselection.cpp when initializing CAmount from group_pos.size().

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `test ancestor commits`: https://github.com/bitcoin/bitcoin/actions/runs/27339510417/job/80774458061</sub> <sub>LLM reason (✨ experimental): CI failed because the fuzz target wouldn’t compile: clang++ reported `-Wc++11-narrowing` errors in `coinselection.cpp` when initializing `CAmount` from `group_pos.size()`.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
janb84 (Migrated from github.com) reviewed 2026-06-11 13:17:38 +00:00
janb84 (Migrated from github.com) commented 2026-06-11 13:17:39 +00:00
    output.set(value.Int());
    // OR output.set(static_cast<CAmount::inner_type>(value.Int()));

Current code gets a local copy, overrides the local copy and local copy gets destroyed at the end of the function. Nothing is written back to the Cap'n Proto message.

Regression test:

diff --git a/src/ipc/test/ipc_test.capnp b/src/ipc/test/ipc_test.capnp
@@ -15,6 +15,7 @@ using Mining = import "../capnp/mining.capnp";
 
 interface FooInterface $Proxy.wrap("FooImplementation") {
     add @0 (a :Int32, b :Int32) -> (result :Int32);
+    passAmounts @6 (arg :List(Int64)) -> (result :List(Int64));
     passOutPoint @1 (arg :Data) -> (result :Data);
     passUniValue @2 (arg :Text) -> (result :Text);
     passTransaction @3 (arg :Data) -> (result :Data);

diff --git a/src/ipc/test/ipc_test.h b/src/ipc/test/ipc_test.h
@@ -15,6 +15,7 @@ class FooImplementation
 {
 public:
     int add(int a, int b) { return a + b; }
+    std::vector<CAmount> passAmounts(std::vector<CAmount> v) { return v; }
     COutPoint passOutPoint(COutPoint o) { return o; }
     UniValue passUniValue(UniValue v) { return v; }
     CTransactionRef passTransaction(CTransactionRef t) { return t; }

diff --git a/src/ipc/test/ipc_test.cpp b/src/ipc/test/ipc_test.cpp
@@ -84,6 +84,15 @@ void IpcPipeTest()
     // Test: make sure arguments were sent and return value is received
     BOOST_CHECK_EQUAL(foo->add(1, 2), 3);
 
+    // Test for CustomBuildField / CustomReadField overloads for 
+    //  CAmount in ipc/capnp/common-types.h. Each value is serialized
+    //  once as the argument and once as the return value, so
+    // a build field that fails to write its value shows up as a zeroed result.
+    const std::vector<CAmount> amounts1{0_sats, 1_sats, COIN, MAX_MONEY, CAmount{-1}};
+    const std::vector<CAmount> amounts2{foo->passAmounts(amounts1)};
+    BOOST_CHECK_EQUAL_COLLECTIONS(amounts1.begin(), amounts1.end(), amounts2.begin(), amounts2.end());
+
     COutPoint txout1{Txid::FromUint256(uint256{100}), 200};
     COutPoint txout2{foo->passOutPoint(txout1)};
     BOOST_CHECK(txout1 == txout2);
```suggestion output.set(value.Int()); // OR output.set(static_cast<CAmount::inner_type>(value.Int())); ``` Current code gets a local copy, overrides the local copy and local copy gets destroyed at the end of the function. Nothing is written back to the Cap'n Proto message. <details> Regression test: ```diff diff --git a/src/ipc/test/ipc_test.capnp b/src/ipc/test/ipc_test.capnp @@ -15,6 +15,7 @@ using Mining = import "../capnp/mining.capnp"; interface FooInterface $Proxy.wrap("FooImplementation") { add @0 (a :Int32, b :Int32) -> (result :Int32); + passAmounts @6 (arg :List(Int64)) -> (result :List(Int64)); passOutPoint @1 (arg :Data) -> (result :Data); passUniValue @2 (arg :Text) -> (result :Text); passTransaction @3 (arg :Data) -> (result :Data); diff --git a/src/ipc/test/ipc_test.h b/src/ipc/test/ipc_test.h @@ -15,6 +15,7 @@ class FooImplementation { public: int add(int a, int b) { return a + b; } + std::vector<CAmount> passAmounts(std::vector<CAmount> v) { return v; } COutPoint passOutPoint(COutPoint o) { return o; } UniValue passUniValue(UniValue v) { return v; } CTransactionRef passTransaction(CTransactionRef t) { return t; } diff --git a/src/ipc/test/ipc_test.cpp b/src/ipc/test/ipc_test.cpp @@ -84,6 +84,15 @@ void IpcPipeTest() // Test: make sure arguments were sent and return value is received BOOST_CHECK_EQUAL(foo->add(1, 2), 3); + // Test for CustomBuildField / CustomReadField overloads for + // CAmount in ipc/capnp/common-types.h. Each value is serialized + // once as the argument and once as the return value, so + // a build field that fails to write its value shows up as a zeroed result. + const std::vector<CAmount> amounts1{0_sats, 1_sats, COIN, MAX_MONEY, CAmount{-1}}; + const std::vector<CAmount> amounts2{foo->passAmounts(amounts1)}; + BOOST_CHECK_EQUAL_COLLECTIONS(amounts1.begin(), amounts1.end(), amounts2.begin(), amounts2.end()); + COutPoint txout1{Txid::FromUint256(uint256{100}), 200}; COutPoint txout2{foo->passOutPoint(txout1)}; BOOST_CHECK(txout1 == txout2); ``` </details>
janb84 (Migrated from github.com) reviewed 2026-06-11 15:57:51 +00:00
janb84 (Migrated from github.com) commented 2026-06-11 15:57:51 +00:00

NIT: Change suggestion isn't helpful but now that we have new Serialization/deserialization, deserializes straight into a CAmount amountdelta. Dropping the need for the int64_t nFeeDelta temporary and the separate CAmount amountdelta{nFeeDelta} wrap.


CAmount amountdelta{0};
file >> TX_WITH_WITNESS(tx);
file >> nTime;
file >> amountdelta;

if (opts.use_current_time) {
nTime = TicksSinceEpoch<std::chrono::seconds>(now);
}

```suggestion ``` NIT: Change suggestion isn't helpful but now that we have new Serialization/deserialization, deserializes straight into a `CAmount amountdelta`. Dropping the need for the int64_t nFeeDelta temporary and the separate `CAmount amountdelta{nFeeDelta}` wrap. ```cpp CAmount amountdelta{0}; file >> TX_WITH_WITNESS(tx); file >> nTime; file >> amountdelta; if (opts.use_current_time) { nTime = TicksSinceEpoch<std::chrono::seconds>(now); } ```
hodlinator (Migrated from github.com) reviewed 2026-06-11 18:16:49 +00:00
hodlinator (Migrated from github.com) commented 2026-06-11 18:16:49 +00:00

Thanks for catching this! I'm surprised it was not covered by tests earlier. I guess transaction serialization has the CAmounts outputs serialized as part of a byte-stream before reaching our Cap'n Proto integration layer. Added your test in a separate commit (44e5ba33d8ded7c1d72ce29321bcf839aacfb7e4) in the latest push (6b8a616b60541c77120525f74ebb11e422373a44), omitting the comment (let me know if you disagree, I think it was good context for your comment here in the PR but a bit verbose in the context of the test).

Thanks for catching this! I'm surprised it was not covered by tests earlier. I guess transaction serialization has the `CAmount`s outputs serialized as part of a byte-stream before reaching our Cap'n Proto integration layer. Added your test in a separate commit (44e5ba33d8ded7c1d72ce29321bcf839aacfb7e4) in the latest push (6b8a616b60541c77120525f74ebb11e422373a44), omitting the comment (let me know if you disagree, I think it was good context for your comment here in the PR but a bit verbose in the context of the test).
hodlinator (Migrated from github.com) commented 2026-06-11 18:19:10 +00:00

Agreed - switched in latest push (6b8a616b60541c77120525f74ebb11e422373a44) to serializing and checking CAmount fee_delta{0};. I think nFeeDelta was a more descriptive name, but altered it to match current naming style.

Agreed - switched in latest push (6b8a616b60541c77120525f74ebb11e422373a44) to serializing and checking `CAmount fee_delta{0};`. I think `nFeeDelta` was a more descriptive name, but altered it to match current naming style.
janb84 (Migrated from github.com) reviewed 2026-06-12 08:31:28 +00:00
janb84 (Migrated from github.com) commented 2026-06-12 08:31:28 +00:00

yeah test was for proving the bug not the intention to add it so i'm glad you altered it somewhat !

yeah test was for proving the bug not the intention to add it so i'm glad you altered it somewhat !
ryanofsky commented 2026-06-15 21:30:44 +00:00 (Migrated from github.com)

Concept ACK. New CAmount implementation seems simple and clean and adds safety benefits.

I haven't looked through the commits yet, but the PR seems very big. Could it make sense to split up somehow, maybe by introducing a new amount class and beginning to use that in places where it's most important, and gradually replacing CAmount, instead of replacing it everywhere? Or maybe there are other ways to split it up? Or maybe it is trivial to review and splitting it up would not be helpful? Curious what you think. This is just larger than I might have expected.

Concept ACK. New [CAmount](https://github.com/hodlinator/bitcoin/blob/6b8a616b60541c77120525f74ebb11e422373a44/src/consensus/amount.h#L23-L109) implementation seems simple and clean and adds safety benefits. I haven't looked through the commits yet, but the PR seems very big. Could it make sense to split up somehow, maybe by introducing a new amount class and beginning to use that in places where it's most important, and gradually replacing CAmount, instead of replacing it everywhere? Or maybe there are other ways to split it up? Or maybe it is trivial to review and splitting it up would not be helpful? Curious what you think. This is just larger than I might have expected.
maflcko commented 2026-06-16 06:33:52 +00:00 (Migrated from github.com)

I haven't looked through the commits yet, but the PR seems very big. Could it make sense to split up somehow, maybe by introducing a new amount class and beginning to use that in places where it's most important, and gradually replacing CAmount, instead of replacing it everywhere? Or maybe there are other ways to split it up? Or maybe it is trivial to review and splitting it up would not be helpful? Curious what you think. This is just larger than I might have expected.

I think the main reason why this looks large is commit c8fa9d5fbef02ccb2150448cb84ed6e9bba383ef and the two following ones. It should be trivial to split the them up and then reduce the size of this pull by two thirds. After this, it seems small enough and easy enough to do in one go.

> I haven't looked through the commits yet, but the PR seems very big. Could it make sense to split up somehow, maybe by introducing a new amount class and beginning to use that in places where it's most important, and gradually replacing CAmount, instead of replacing it everywhere? Or maybe there are other ways to split it up? Or maybe it is trivial to review and splitting it up would not be helpful? Curious what you think. This is just larger than I might have expected. I think the main reason why this looks large is commit c8fa9d5fbef02ccb2150448cb84ed6e9bba383ef and the two following ones. It should be trivial to split the them up and then reduce the size of this pull by two thirds. After this, it seems small enough and easy enough to do in one go.
maflcko (Migrated from github.com) reviewed 2026-06-16 06:34:01 +00:00
maflcko (Migrated from github.com) commented 2026-06-16 06:27:35 +00:00

Either mark with LIFETIMEBOUND, or just return a copy, which is usually not slower anyway?

Either mark with LIFETIMEBOUND, or just return a copy, which is usually not slower anyway?
maflcko (Migrated from github.com) commented 2026-06-16 06:27:00 +00:00

q: Shouldn't this check against MAX_MONEY?

q: Shouldn't this check against MAX_MONEY?
Sjors commented 2026-06-17 08:21:27 +00:00 (Migrated from github.com)

I think the main reason why this looks large is commit github.com/bitcoin/bitcoin@c8fa9d5fbe and the two following ones.

In addition to making b7af8d94d6708e50ebede9a513d006ac0031606c a followup or earlier PR (to introduce the _sats literal), it could be a scripted diff? The script is already in the commit description, but then CI can check it too.

> I think the main reason why this looks large is commit https://github.com/bitcoin/bitcoin/commit/c8fa9d5fbef02ccb2150448cb84ed6e9bba383ef and the two following ones. In addition to making b7af8d94d6708e50ebede9a513d006ac0031606c a followup or earlier PR (to introduce the _sats literal), it could be a scripted diff? The script is already in the commit description, but then CI can check it too.
ryanofsky commented 2026-06-17 12:30:20 +00:00 (Migrated from github.com)

I think the main reason why this looks large is commit c8fa9d5 and the two following ones. It should be trivial to split the them up and then reduce the size of this pull by two thirds. After this, it seems small enough and easy enough to do in one go.

Nice. I'd be ok with reviewing this all together, but IMO it would be good to introduce the _sats suffix as a standalone readability improvement so this PR is smaller and just focused on safety issues, which seem more subtle.

> I think the main reason why this looks large is commit [c8fa9d5](https://github.com/bitcoin/bitcoin/commit/c8fa9d5fbef02ccb2150448cb84ed6e9bba383ef) and the two following ones. It should be trivial to split the them up and then reduce the size of this pull by two thirds. After this, it seems small enough and easy enough to do in one go. Nice. I'd be ok with reviewing this all together, but IMO it would be good to introduce the `_sats` suffix as a standalone readability improvement so this PR is smaller and just focused on safety issues, which seem more subtle.
hodlinator commented 2026-06-17 13:42:25 +00:00 (Migrated from github.com)

Thanks for the encouraging feedback & ideas to facilitate review!
Migrating to a new class gradually is worth at least keeping in the back-pocket (https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4712614640).
Agree with https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4715661184 that peeling off the beginning half of this PR up until before CAmount starts becoming an actual class could make sense (everything before "ipc: Add coverage for passing CAmount"?).

Regarding https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4727632236, making a scripted diff commit out of the largest one ("refactor: Apply _sats literals (trivial)"):
In that commit I'm preemptively manually inserting _sats in places which will otherwise no longer compile due to later commits. Outside of some kind of heavily C++ AST-aware Clang-integrated tooling, I don't see a way of doing that in a scripted fashion. Maybe there is some creative way of running the sed-script I have in reverse... I just cannot come up with it now, but I'm open to suggestions.

Thanks for the encouraging feedback & ideas to facilitate review! Migrating to a new class gradually is worth at least keeping in the back-pocket (https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4712614640). Agree with https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4715661184 that peeling off the beginning half of this PR up until before `CAmount` starts becoming an actual class could make sense (everything before "ipc: Add coverage for passing CAmount"?). Regarding https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4727632236, making a scripted diff commit out of the largest one ("refactor: Apply _sats literals (trivial)"): In that commit I'm preemptively manually inserting `_sats` in places which will otherwise no longer compile due to later commits. Outside of some kind of heavily C++ AST-aware Clang-integrated tooling, I don't see a way of doing that in a scripted fashion. Maybe there is some creative way of running the sed-script I have in reverse... I just cannot come up with it now, but I'm open to suggestions.
maflcko commented 2026-06-17 13:48:01 +00:00 (Migrated from github.com)

Ah, it is an inverse scripted diff. In theory (after https://github.com/bitcoin/bitcoin/pull/35547) you could do an empty scripted diff in the next commit with:

  • Your sed command on ./src
  • git --no-pager diff --exit-code --quiet HEAD~
  • git checkout -- ./src

Not sure if that is too spicy.

Ah, it is an inverse scripted diff. In theory (after https://github.com/bitcoin/bitcoin/pull/35547) you could do an empty scripted diff in the next commit with: * Your sed command on ./src * git --no-pager diff --exit-code --quiet HEAD~ * git checkout -- ./src Not sure if that is too spicy.
DrahtBot commented 2026-06-17 15:26:25 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task iwyu: https://github.com/bitcoin/bitcoin/actions/runs/27693235629/job/81909522457
LLM reason (✨ experimental): CI failed because IWYU reported include issues (“Failure generated from IWYU”), causing the test script to exit with status 1.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `iwyu`: https://github.com/bitcoin/bitcoin/actions/runs/27693235629/job/81909522457</sub> <sub>LLM reason (✨ experimental): CI failed because IWYU reported include issues (“Failure generated from IWYU”), causing the test script to exit with status 1.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
optout21 commented 2026-06-18 09:16:47 +00:00 (Migrated from github.com)

A strong like for the concept of CAmount as a class rather than a simple typedef.

These properties make a lot of sense:

  • constructible from a numerical value
  • convertible to to a numerical value, but only explicitly
  • automatic extra sanity checks (e.g. max)

However, to be constructible only from _sats literals, and to be comparable only against other CAmount seems a bit of an overkill to me, and it hinders introduction (large change). An amount is a special kind of number, but it is a number, and I don't see the benefit of abstracting away that fact that it is a number.

I would be happier to see a more gradual introduction:

  • constructible from a number (with internal max check)
  • using conversion to number for comparisons, computations (i.e., amount.Int() < 1000 instead of amount < 1000_sat
  • for an even more gradual introduction, as an intermediary step, the conversion to number can be automatic
  • forcing to exclusive comparison and arithmetics (as proposed currently) could be done as a later step.

Also, I'm a bit uneasy with the allowed negative values. Maybe such a change would be a good time to separate absolute amounts and amount differences, with the former being strictly non-negative (e.g. CAmount andd CAmountDelta; an analogue would be time points and time differences). I suspect for most of the usages, non-negative absolute amount would fit.

A strong like for the concept of `CAmount` as a class rather than a simple typedef. These properties make a lot of sense: - constructible from a numerical value - convertible to to a numerical value, but only explicitly - automatic extra sanity checks (e.g. max) However, to be constructible only from `_sats` literals, and to be comparable only against other `CAmount` seems a bit of an overkill to me, and it hinders introduction (large change). An amount is a special kind of number, but it is a number, and I don't see the benefit of abstracting away that fact that it is a number. I would be happier to see a more gradual introduction: - constructible from a number (with internal max check) - using conversion to number for comparisons, computations (i.e., `amount.Int() < 1000` instead of `amount < 1000_sat` - for an even more gradual introduction, as an intermediary step, the conversion to number can be automatic - forcing to exclusive comparison and arithmetics (as proposed currently) could be done as a later step. Also, I'm a bit uneasy with the allowed negative values. Maybe such a change would be a good time to separate absolute amounts and amount differences, with the former being strictly non-negative (e.g. `CAmount` andd `CAmountDelta`; an analogue would be time points and time differences). I suspect for most of the usages, non-negative absolute amount would fit.
hodlinator commented 2026-06-18 11:45:46 +00:00 (Migrated from github.com)

Thanks for your feedback @optout21!

constructible from a number (with internal max check)
[...]
I'm a bit uneasy with the allowed negative values. Maybe such a change would be a good time to separate absolute amounts and amount differences, with the former being strictly non-negative (e.g. CAmount andd CAmountDelta; an analogue would be time points and time differences). I suspect for most of the usages, non-negative absolute amount would fit.

One of my first experiments in this area was having distinct Amount (signed) and UAmount (unsigned) types (older branch: https://github.com/hodlinator/bitcoin/tree/2026/03/safer_camount).

After presenting this experiment at https://btctranscripts.com/bitcoin-core-dev-tech/2026-05/camount I got feedback about the pitfalls of unsigned integers (mixing signed with unsigned in the same expression makes the result unsigned, which might result in unintentional conversion from negative values to positive).

This made me change my approach to only keep signed amounts, but to experiment with having an amount type which only allows [0,21M BTC] in addition to a type which allows any int64_t value. A first attempt in this direction is made here: https://github.com/hodlinator/bitcoin/tree/2026/06/safer_camount.take2.unchecked. But will probably go with a more careful approach as described in the final commit message.

using conversion to number for comparisons, computations (i.e., amount.Int() < 1000 instead of amount < 1000_sat

If we were going to introduce the requirement to use .Int() everywhere we might as well instead introduce the literal directly?

  • for an even more gradual introduction, as an intermediary step, the conversion to number can be automatic
  • forcing to exclusive comparison and arithmetics (as proposed currently) could be done as a later step.

I briefly experimented with having an operator int64_t() method and allowing comparisons against integers. What I ran into a lot was that the compiler couldn't resolve the resulting ambiguities. Maybe there's a way to resolve those ambiguities, but my impression from earlier feedback is that the current approach without that intermediate step may be acceptable.

Thanks for your feedback @optout21! > constructible from a number (with internal max check) > [...] > I'm a bit uneasy with the allowed negative values. Maybe such a change would be a good time to separate absolute amounts and amount differences, with the former being strictly non-negative (e.g. `CAmount` andd `CAmountDelta`; an analogue would be time points and time differences). I suspect for most of the usages, non-negative absolute amount would fit. One of my first experiments in this area was having distinct `Amount` (signed) and `UAmount` (unsigned) types (older branch: https://github.com/hodlinator/bitcoin/tree/2026/03/safer_camount). After presenting this experiment at https://btctranscripts.com/bitcoin-core-dev-tech/2026-05/camount I got feedback about the pitfalls of unsigned integers (mixing signed with unsigned in the same expression makes the result unsigned, which might result in unintentional conversion from negative values to positive). This made me change my approach to only keep signed amounts, but to experiment with having an amount type which only allows [0,21M BTC] in addition to a type which allows any `int64_t` value. A first attempt in this direction is made here: https://github.com/hodlinator/bitcoin/tree/2026/06/safer_camount.take2.unchecked. But will probably go with a more careful approach as described in the final commit message. > using conversion to number for comparisons, computations (i.e., `amount.Int() < 1000` instead of `amount < 1000_sat` If we were going to introduce the requirement to use `.Int()` everywhere we might as well instead introduce the literal directly? > * for an even more gradual introduction, as an intermediary step, the conversion to number can be automatic > * forcing to exclusive comparison and arithmetics (as proposed currently) could be done as a later step. I briefly experimented with having an `operator int64_t()` method and allowing comparisons against integers. What I ran into a lot was that the compiler couldn't resolve the resulting ambiguities. Maybe there's a way to resolve those ambiguities, but my impression from earlier feedback is that the current approach without that intermediate step may be acceptable.
purpleKarrot commented 2026-06-22 06:30:40 +00:00 (Migrated from github.com)

It might be worth having a look into the crystal ball. If P3045 gets accepted into the C++ standard in one form or another, then our preferred way of defining amount might become something like this:

using Amount = std::quantity<units::satoshi, std::int64_t>;

I don't want to suggest using a polyfill for std::quantity, but I strongly recommend having a look into the proposal linked above and see whether some of its design decisions could influence the design of a custom Amount class.
For example, there is a design decision against user defined literals that contains:

UDLs work only with literals (compile-time known values). Our observation is that besides the unit tests, only a few compile-time known quantity values are used in the production code.

Which is absolutely true and convinces me to vote against a _sat UDL.

I also strongly believe that whether an amount is inside a particular value range should be a predicate rather than an invarant.

It might be worth having a look into the crystal ball. If [P3045](http://wg21.link/p3045) gets accepted into the C++ standard in one form or another, then our preferred way of defining amount might become something like this: ```cpp using Amount = std::quantity<units::satoshi, std::int64_t>; ``` I don't want to suggest using a polyfill for `std::quantity`, but I strongly recommend having a look into the proposal linked above and see whether some of its design decisions could influence the design of a custom `Amount` class. For example, there is a design decision [against user defined literals](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2026/p3045r8.html#why-dont-we-use-udls-to-create-quantities) that contains: > UDLs work only with literals (compile-time known values). Our observation is that besides the unit tests, only a few compile-time known quantity values are used in the production code. Which is absolutely true and convinces me to vote **against** a `_sat` UDL. I also strongly believe that whether an amount is inside a particular value range should be a **predicate** rather than an **invarant**.
ryanofsky commented 2026-06-22 20:35:27 +00:00 (Migrated from github.com)

re: https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4765530904

I also strongly believe that whether an amount is inside a particular value range should be a predicate rather than an invarant.

This seems to already be the case if you look at ed38d9ffa1da4cfafb17fc7977edc579e5147207. The CAmount class doesn't enforce any range requirements. It could be useful to have other types that enforce runtime invariants like not_null or boost's safe_signed_range type do, but this would be a separate concern. There is also a MoneyRange predicate already.

convinces me to vote against a _sat UDL.

The std::quantity proposal is interesting and seems to write units with multiplication syntax (quantity dist1 = 80 * km;) instead of literal suffixes. This does seem more general and could be a good idea to apply here.

re: https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4765530904 > I also strongly believe that whether an amount is inside a particular value range should be a **predicate** rather than an **invarant**. This seems to already be the case if you look at ed38d9ffa1da4cfafb17fc7977edc579e5147207. The `CAmount` class doesn't enforce any range requirements. It could be useful to have other types that enforce runtime invariants like `not_null` or boost's `safe_signed_range` type do, but this would be a separate concern. There is also a `MoneyRange` predicate already. > convinces me to vote against a _sat UDL. The std::quantity proposal is interesting and seems to write units with multiplication syntax (`quantity dist1 = 80 * km;`) instead of literal suffixes. This does seem more general and could be a good idea to apply here.
purpleKarrot commented 2026-06-23 06:26:43 +00:00 (Migrated from github.com)

The CAmount class doesn't enforce any range requirements. It could be useful to have other types that enforce runtime invariants like not_null or boost's safe_signed_range type do,

True. Such a utility may be handy in some areas of the codebase, but we should keep in mind (and probably document somewhere) that there are areas where such a utility must not be used. A function like validate(Block) -> bool has three different outcomes:

  1. true when the block was found valid
  2. false when the block was found invalid
  3. An exception being thrown in case of a runtime failure, in which case the function is unable to determine whether the block is valid or invalid.

It is especially crucial that we are always able to distinguish between 2 and 3. That means:

  • A block must be allowed to represent invalid data. None of its parts should have an invariant that disallows checking it for validity.
  • Checking an invalid block must not result in runtime failure. There is no throw in case of consensus violations.
  • Runtime errors must not be interpreted as the block being invalid. There should be no catch in validation code.

But outside of consensus, yes, such a utility may be useful.

> The `CAmount` class doesn't enforce any range requirements. It could be useful to have other types that enforce runtime invariants like `not_null` or boost's `safe_signed_range` type do, True. Such a utility may be handy in *some* areas of the codebase, but we should keep in mind (and probably document somewhere) that there are areas where such a utility **must not be used**. A function like `validate(Block) -> bool` has **three** different outcomes: 1. `true` when the block was found **valid** 2. `false` when the block was found **invalid** 3. An exception being thrown in case of a runtime failure, in which case the function is **unable** to determine whether the block is valid or invalid. It is especially crucial that we are always able to distinguish between 2 and 3. That means: * A block must be allowed to represent invalid data. None of its parts should have an invariant that disallows checking it for validity. * Checking an invalid block must not result in runtime failure. There is no `throw` in case of consensus violations. * Runtime errors must not be interpreted as the block being invalid. There should be no `catch` in validation code. But outside of consensus, yes, such a utility may be useful.
hodlinator commented 2026-06-26 13:00:57 +00:00 (Migrated from github.com)

Thanks for your comments @purpleKarrot & @ryanofsky! (https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4765530904, https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4772817451, https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4776362626).

User-defined literals

The future quantities & units library makes sense for use-cases mixing different quantities (radius vs distance), units (metre vs foot) and kinds (energy vs length). In our domain we are typically interested in sats, sat/vbyte and similar cost/weight unit ratios. At least one test had me define a _BTC literal (fe04bd335bc407c2754f332c697c1f7475f1dd17).

Writing 0_sats rather than CAmount{0} was nice for readability and is okay for code that is not exposed by the kernel IMO. However, my next plan is to experiment with a version of this PR which does not introduce any UDLs and instead tries to survive on explicit CAmount-ctors and possibly increased usage of .Int().

Constraining valid ranges - [0,21M] BTC

My experimentation so far confirms that it would be safer to introduce constraints on amount types outside of the consensus code.

Thanks for your comments @purpleKarrot & @ryanofsky! (https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4765530904, https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4772817451, https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4776362626). ### User-defined literals The future quantities & units library makes sense for use-cases mixing different quantities (radius vs distance), units (metre vs foot) and kinds (energy vs length). In our domain we are typically interested in sats, sat/vbyte and similar cost/weight unit ratios. At least one test had me define a `_BTC` literal (fe04bd335bc407c2754f332c697c1f7475f1dd17). Writing `0_sats` rather than `CAmount{0}` was nice for readability and is okay for code that is not exposed by the kernel IMO. However, my next plan is to experiment with a version of this PR which does not introduce any UDLs and instead tries to survive on explicit `CAmount`-ctors and possibly increased usage of `.Int()`. ### Constraining valid ranges - `[0,21M] BTC` My experimentation so far confirms that it would be safer to introduce constraints on amount types outside of the consensus code.
ryanofsky commented 2026-06-29 18:28:48 +00:00 (Migrated from github.com)

re: https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4809818861

Writing 0_sats rather than CAmount{0} was nice for readability and is okay for code that is not exposed by the kernel IMO. However, my next plan is to experiment with a version of this PR which does not introduce any UDLs and instead tries to survive on explicit CAmount-ctors

I think you should consider using the * sats multiplication syntax like std::quantity. It seems pretty nice, and better than literal suffixes because it can work with all integer expressions, not just integer literals. It should also be more readable and self-documenting than passing numbers without units to the CAmount constructor.

re: https://github.com/bitcoin/bitcoin/pull/35511#issuecomment-4809818861 > Writing `0_sats` rather than `CAmount{0}` was nice for readability and is okay for code that is not exposed by the kernel IMO. However, my next plan is to experiment with a version of this PR which does not introduce any UDLs and instead tries to survive on explicit `CAmount`-ctors I think you should consider using the `* sats` multiplication syntax like `std::quantity`. It seems pretty nice, and better than literal suffixes because it can work with all integer expressions, not just integer literals. It should also be more readable and self-documenting than passing numbers without units to the CAmount constructor.
l0rinc (Migrated from github.com) requested changes 2026-06-29 19:29:17 +00:00
l0rinc (Migrated from github.com) left a comment

As mentioned by others, I am also not comfortable with taking such a large change in one step. I would prefer introducing a new amount type first, with a few focused examples, and then converting call sites gradually. I also think _sats, * sats, and explicit CAmount{} construction should be debated independently.

I share the concern around value-range semantics. If the goal is that an amount object is always valid once constructed, then the boundary needs to be explicit: parsing should probably produce an unchecked/raw amount first, and validation should then finalize it into a bounded monetary amount, for example through a factory returning std::optional<MoneyAmount> or util::Result<MoneyAmount>. If negative values are needed, they may deserve a separate MoneyDelta type instead of being folded into the same bounded money type.

One area I would like clarified is amount compression and serialization. After this change, AmountCompression still appears to deserialize compressed amounts into CAmount without enforcing MoneyRange. Is that intentional and byte-for-byte compatible with the current behavior? Several fuzz targets in src/test/fuzz/deserialize.cpp can already construct invalid monetary values, and coins/undo data previously seemed to treat a successful parse as sufficient, as far as I can tell.

As mentioned by others, I am also not comfortable with taking such a large change in one step. I would prefer introducing a new amount type first, with a few focused examples, and then converting call sites gradually. I also think `_sats`, `* sats`, and explicit `CAmount{}` construction should be debated independently. I share the concern around value-range semantics. If the goal is that an amount object is always valid once constructed, then the boundary needs to be explicit: parsing should probably produce an unchecked/raw amount first, and validation should then finalize it into a bounded monetary amount, for example through a factory returning `std::optional<MoneyAmount>` or `util::Result<MoneyAmount>`. If negative values are needed, they may deserve a separate `MoneyDelta` type instead of being folded into the same bounded money type. One area I would like clarified is amount compression and serialization. After this change, `AmountCompression` still appears to deserialize compressed amounts into `CAmount` without enforcing `MoneyRange`. Is that intentional and byte-for-byte compatible with the current behavior? Several fuzz targets in `src/test/fuzz/deserialize.cpp` can already construct invalid monetary values, and coins/undo data previously seemed to treat a successful parse as sufficient, as far as I can tell.
l0rinc (Migrated from github.com) commented 2026-06-11 10:32:16 +00:00

c8fa9d5 _consensus: Add sats user defined literal:

... guess this will finally put an end to the sats-vs-bits debate ...

> [c8fa9d5](https://github.com/bitcoin/bitcoin/pull/35511/changes/c8fa9d5fbef02ccb2150448cb84ed6e9bba383ef) _consensus: Add _sats user defined literal_: ... guess this will finally put an end to the sats-vs-bits debate ...
l0rinc (Migrated from github.com) commented 2026-06-11 10:35:17 +00:00

Do we need to keep the Hungarian notation C prefix?

Do we need to keep the Hungarian notation `C` prefix?
l0rinc (Migrated from github.com) commented 2026-06-11 10:35:35 +00:00

What are the expected use cases for dividing one CAmount by another? What is the expected outcome of 10_sats / 3_sats? Since this returns a scalar ratio rather than another amount, would it be clearer to avoid exposing this as a generic operator and keep the few ratio-style uses explicit?

What are the expected use cases for dividing one `CAmount` by another? What is the expected outcome of 10_sats / 3_sats? Since this returns a scalar ratio rather than another amount, would it be clearer to avoid exposing this as a generic operator and keep the few ratio-style uses explicit?
l0rinc (Migrated from github.com) commented 2026-06-29 19:06:59 +00:00

Could we rather encapsulate the serialization inside the new type?

Could we rather encapsulate the serialization inside the new type?
l0rinc (Migrated from github.com) commented 2026-06-29 19:05:45 +00:00

alternatively we could add a bool operator to it (we have many other cases when we're checking for value > 0)

alternatively we could add a `bool` operator to it (we have many other cases when we're checking for `value > 0`)
l0rinc (Migrated from github.com) commented 2026-06-29 19:15:34 +00:00

seems contrived to do math with the new types, wouldn't it make a lot more sense to extract the value, do the math and reparse at the end?

seems contrived to do math with the new types, wouldn't it make a lot more sense to extract the value, do the math and reparse at the end?
l0rinc (Migrated from github.com) commented 2026-06-29 19:13:34 +00:00

note that 0.5 * COIN may not be the same as COIN / 2

note that `0.5 * COIN` may not be the same as `COIN / 2`
l0rinc (Migrated from github.com) commented 2026-06-29 19:11:14 +00:00

Won't this introduce unnecessary headaches around floating-point money, even if this is only test code? This was already doing something similar before, but adding a _BTC literal seems to make that pattern more attractive rather than less. See 5aadd4b and fa2ac58.

Won't this introduce unnecessary headaches around floating-point money, even if this is only test code? This was already doing something similar before, but adding a `_BTC` literal seems to make that pattern more attractive rather than less. See [5aadd4b](https://github.com/bitcoin/bitcoin/commit/5aadd4be1883386a04bef6a04e9a1142601ef7a7) and [fa2ac58](https://github.com/bitcoin/bitcoin/commit/fa2ac5881edf8d0d3f15c43f089f1831348dfae2).
l0rinc (Migrated from github.com) commented 2026-06-29 19:14:41 +00:00

why do we have CAmount{1} here instead of 1_sats

why do we have `CAmount{1}` here instead of `1_sats`
l0rinc (Migrated from github.com) commented 2026-06-29 19:07:40 +00:00

Wouldn't it make more sense to make this optional instead of using a magic value?

Wouldn't it make more sense to make this optional instead of using a magic value?
hodlinator (Migrated from github.com) reviewed 2026-07-01 12:10:38 +00:00
hodlinator (Migrated from github.com) left a comment

Thanks for checking this out @l0rinc!

As mentioned by others, I am also not comfortable with taking such a large change in one step. I would prefer introducing a new amount type first, with a few focused examples, and then converting call sites gradually. I also think _sats, * sats, and explicit CAmount{} construction should be debated independently.

Yes, explicit construction could be split off as a later PR.

I share the concern around value-range semantics. If the goal is that an amount object is always valid once constructed, then the boundary needs to be explicit: parsing should probably produce an unchecked/raw amount first, and validation should then finalize it into a bounded monetary amount, for example through a factory returning std::optional<MoneyAmount> or util::Result<MoneyAmount>. If negative values are needed, they may deserve a separate MoneyDelta type instead of being folded into the same bounded money type.

Yup, introducing an additional bounded type should come after this work. Something like MoneyDelta/AmountDelta sounds good.

One area I would like clarified is amount compression and serialization. After this change, AmountCompression still appears to deserialize compressed amounts into CAmount without enforcing MoneyRange. Is that intentional and byte-for-byte compatible with the current behavior? Several fuzz targets in src/test/fuzz/deserialize.cpp can already construct invalid monetary values, and coins/undo data previously seemed to treat a successful parse as sufficient, as far as I can tell.

As far as I can see there is no change to the on the wire format. This comment makes me uneasy but the number of out of bounds values serialized should be the same as on master.

github.com/bitcoin/bitcoin@341360964a/src/compressor.h (L30-L39)

Thanks for checking this out @l0rinc! > As mentioned by others, I am also not comfortable with taking such a large change in one step. I would prefer introducing a new amount type first, with a few focused examples, and then converting call sites gradually. I also think `_sats`, `* sats`, and explicit `CAmount{}` construction should be debated independently. Yes, explicit construction could be split off as a later PR. > I share the concern around value-range semantics. If the goal is that an amount object is always valid once constructed, then the boundary needs to be explicit: parsing should probably produce an unchecked/raw amount first, and validation should then finalize it into a bounded monetary amount, for example through a factory returning `std::optional<MoneyAmount>` or `util::Result<MoneyAmount>`. If negative values are needed, they may deserve a separate `MoneyDelta` type instead of being folded into the same bounded money type. Yup, introducing an additional bounded type should come after this work. Something like `MoneyDelta`/`AmountDelta` sounds good. > One area I would like clarified is amount compression and serialization. After this change, `AmountCompression` still appears to deserialize compressed amounts into `CAmount` without enforcing `MoneyRange`. Is that intentional and byte-for-byte compatible with the current behavior? Several fuzz targets in `src/test/fuzz/deserialize.cpp` can already construct invalid monetary values, and coins/undo data previously seemed to treat a successful parse as sufficient, as far as I can tell. As far as I can see there is no change to the on the wire format. This comment makes me uneasy but the number of out of bounds values serialized should be the same as on master. https://github.com/bitcoin/bitcoin/blob/341360964a6fef725825639edc507c275f8ad0b2/src/compressor.h#L30-L39
hodlinator (Migrated from github.com) commented 2026-07-01 08:02:40 +00:00

Agree it would be nice to rename to Amount as a before/after marker that the codebase is more typesafe, just want to keep the file count down a bit for now.

Agree it would be nice to rename to `Amount` as a before/after marker that the codebase is more typesafe, just want to keep the file count down a bit for now.
hodlinator (Migrated from github.com) commented 2026-07-01 11:36:04 +00:00

When would it be harmful to allow calculating the scalar ratio? Exploring this helped me find a CeilDiv.

Diff from disabling `amount / amount` and `amount % amount` while still being able to divide & mod by scalars.
diff --git a/src/consensus/amount.h b/src/consensus/amount.h
index 143d76b7b7..e42d55dedf 100644
--- a/src/consensus/amount.h
+++ b/src/consensus/amount.h
@@ -52,7 +52,7 @@ public:
     {
         return CAmount{m_sats - other.m_sats};
     }
-
+/*
     constexpr inner_type operator/(const CAmount other) const noexcept
     {
         return m_sats / other.m_sats;
@@ -62,7 +62,7 @@ public:
     {
         return m_sats % other.m_sats;
     }
-
+*/
     constexpr CAmount& operator+=(const CAmount other) noexcept
     {
         *this = CAmount{m_sats + other.m_sats};
diff --git a/src/core_io.cpp b/src/core_io.cpp
index a5ad9f618f..38988f980c 100644
--- a/src/core_io.cpp
+++ b/src/core_io.cpp
@@ -283,8 +283,8 @@ util::Result<int> SighashFromStr(const std::string& sighash)
 UniValue ValueFromAmount(const CAmount amount)
 {
     static_assert(COIN > 1_sats);
-    int64_t quotient = amount / COIN;
-    int64_t remainder = amount % COIN;
+    int64_t quotient = amount.Int() / COIN.Int();
+    int64_t remainder = amount.Int() % COIN.Int();
     if (amount < 0_sats) {
         quotient = -quotient;
         remainder = -remainder;
diff --git a/src/policy/feerate.cpp b/src/policy/feerate.cpp
index 5cacd5c4f2..ad926dde14 100644
--- a/src/policy/feerate.cpp
+++ b/src/policy/feerate.cpp
@@ -30,7 +30,7 @@ std::string CFeeRate::ToString(FeeRateFormat fee_rate_format) const
 {
     const CAmount feerate_per_kvb{GetFeePerK()};
     switch (fee_rate_format) {
-    case FeeRateFormat::BTC_KVB: return strprintf("%d.%08d %s/kvB", feerate_per_kvb / COIN, feerate_per_kvb % COIN, CURRENCY_UNIT);
+    case FeeRateFormat::BTC_KVB: return strprintf("%d.%08d %s/kvB", feerate_per_kvb / COIN.Int(), feerate_per_kvb % COIN.Int(), CURRENCY_UNIT);
     case FeeRateFormat::SAT_VB: return strprintf("%d.%03d %s/vB", feerate_per_kvb / 1000, feerate_per_kvb % 1000, CURRENCY_ATOM);
     } // no default case, so the compiler can warn about missing cases
     assert(false);
diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp
index 286150a834..1241e0c664 100644
--- a/src/primitives/transaction.cpp
+++ b/src/primitives/transaction.cpp
@@ -59,7 +59,7 @@ CTxOut::CTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn)
 
 std::string CTxOut::ToString() const
 {
-    return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", nValue / COIN, nValue % COIN, HexStr(scriptPubKey).substr(0, 30));
+    return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", nValue.Int() / COIN.Int(), nValue.Int() % COIN.Int(), HexStr(scriptPubKey).substr(0, 30));
 }
 
 CMutableTransaction::CMutableTransaction() : version{CTransaction::CURRENT_VERSION}, nLockTime{0} {}
diff --git a/src/util/moneystr.cpp b/src/util/moneystr.cpp
index fe488bca92..a4b9aa603e 100644
--- a/src/util/moneystr.cpp
+++ b/src/util/moneystr.cpp
@@ -22,8 +22,8 @@ std::string FormatMoney(const CAmount n)
     // Note: not using straight sprintf here because we do NOT want
     // localized number formatting.
     static_assert(COIN > 1_sats);
-    int64_t quotient = n / COIN;
-    int64_t remainder = n % COIN;
+    int64_t quotient = n.Int() / COIN.Int();
+    int64_t remainder = n.Int() % COIN.Int();
     if (n < 0_sats) {
         quotient = -quotient;
         remainder = -remainder;
diff --git a/src/wallet/coinselection.cpp b/src/wallet/coinselection.cpp
index 457f6ae290..750ae51647 100644
--- a/src/wallet/coinselection.cpp
+++ b/src/wallet/coinselection.cpp
@@ -12,6 +12,7 @@
 #include <util/check.h>
 #include <util/log.h>
 #include <util/moneystr.h>
+#include <util/overflow.h>
 
 #include <numeric>
 #include <optional>
@@ -528,7 +529,7 @@ util::Result<SelectionResult> CoinGrinder(std::vector<OutputGroup>& utxo_pool, c
                 best_selection_weight = curr_weight;
                 best_selection_amount = curr_amount;
             }
-        } else if (!best_selection.empty() && curr_weight + int64_t{min_tail_weight[curr_tail]} * ((total_target - curr_amount + utxo_pool[curr_tail].GetSelectionAmount() - 1_sats) / utxo_pool[curr_tail].GetSelectionAmount()) > best_selection_weight) {
+        } else if (!best_selection.empty() && curr_weight + int64_t{min_tail_weight[curr_tail]} * int64_t(CeilDiv(uint64_t((total_target - curr_amount).Int()), uint64_t(utxo_pool[curr_tail].GetSelectionAmount().Int()))) > best_selection_weight) {
             // Compare minimal tail weight and last selected amount with the amount missing to gauge whether a better weight is still possible.
             if (utxo_pool[curr_tail].m_weight <= min_tail_weight[curr_tail]) {
                 should_cut = true;
When would it be harmful to allow calculating the scalar ratio? Exploring this helped me find a `CeilDiv`. <details><summary>Diff from disabling `amount / amount` and `amount % amount` while still being able to divide & mod by scalars.</summary> ```diff diff --git a/src/consensus/amount.h b/src/consensus/amount.h index 143d76b7b7..e42d55dedf 100644 --- a/src/consensus/amount.h +++ b/src/consensus/amount.h @@ -52,7 +52,7 @@ public: { return CAmount{m_sats - other.m_sats}; } - +/* constexpr inner_type operator/(const CAmount other) const noexcept { return m_sats / other.m_sats; @@ -62,7 +62,7 @@ public: { return m_sats % other.m_sats; } - +*/ constexpr CAmount& operator+=(const CAmount other) noexcept { *this = CAmount{m_sats + other.m_sats}; diff --git a/src/core_io.cpp b/src/core_io.cpp index a5ad9f618f..38988f980c 100644 --- a/src/core_io.cpp +++ b/src/core_io.cpp @@ -283,8 +283,8 @@ util::Result<int> SighashFromStr(const std::string& sighash) UniValue ValueFromAmount(const CAmount amount) { static_assert(COIN > 1_sats); - int64_t quotient = amount / COIN; - int64_t remainder = amount % COIN; + int64_t quotient = amount.Int() / COIN.Int(); + int64_t remainder = amount.Int() % COIN.Int(); if (amount < 0_sats) { quotient = -quotient; remainder = -remainder; diff --git a/src/policy/feerate.cpp b/src/policy/feerate.cpp index 5cacd5c4f2..ad926dde14 100644 --- a/src/policy/feerate.cpp +++ b/src/policy/feerate.cpp @@ -30,7 +30,7 @@ std::string CFeeRate::ToString(FeeRateFormat fee_rate_format) const { const CAmount feerate_per_kvb{GetFeePerK()}; switch (fee_rate_format) { - case FeeRateFormat::BTC_KVB: return strprintf("%d.%08d %s/kvB", feerate_per_kvb / COIN, feerate_per_kvb % COIN, CURRENCY_UNIT); + case FeeRateFormat::BTC_KVB: return strprintf("%d.%08d %s/kvB", feerate_per_kvb / COIN.Int(), feerate_per_kvb % COIN.Int(), CURRENCY_UNIT); case FeeRateFormat::SAT_VB: return strprintf("%d.%03d %s/vB", feerate_per_kvb / 1000, feerate_per_kvb % 1000, CURRENCY_ATOM); } // no default case, so the compiler can warn about missing cases assert(false); diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index 286150a834..1241e0c664 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -59,7 +59,7 @@ CTxOut::CTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn) std::string CTxOut::ToString() const { - return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", nValue / COIN, nValue % COIN, HexStr(scriptPubKey).substr(0, 30)); + return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", nValue.Int() / COIN.Int(), nValue.Int() % COIN.Int(), HexStr(scriptPubKey).substr(0, 30)); } CMutableTransaction::CMutableTransaction() : version{CTransaction::CURRENT_VERSION}, nLockTime{0} {} diff --git a/src/util/moneystr.cpp b/src/util/moneystr.cpp index fe488bca92..a4b9aa603e 100644 --- a/src/util/moneystr.cpp +++ b/src/util/moneystr.cpp @@ -22,8 +22,8 @@ std::string FormatMoney(const CAmount n) // Note: not using straight sprintf here because we do NOT want // localized number formatting. static_assert(COIN > 1_sats); - int64_t quotient = n / COIN; - int64_t remainder = n % COIN; + int64_t quotient = n.Int() / COIN.Int(); + int64_t remainder = n.Int() % COIN.Int(); if (n < 0_sats) { quotient = -quotient; remainder = -remainder; diff --git a/src/wallet/coinselection.cpp b/src/wallet/coinselection.cpp index 457f6ae290..750ae51647 100644 --- a/src/wallet/coinselection.cpp +++ b/src/wallet/coinselection.cpp @@ -12,6 +12,7 @@ #include <util/check.h> #include <util/log.h> #include <util/moneystr.h> +#include <util/overflow.h> #include <numeric> #include <optional> @@ -528,7 +529,7 @@ util::Result<SelectionResult> CoinGrinder(std::vector<OutputGroup>& utxo_pool, c best_selection_weight = curr_weight; best_selection_amount = curr_amount; } - } else if (!best_selection.empty() && curr_weight + int64_t{min_tail_weight[curr_tail]} * ((total_target - curr_amount + utxo_pool[curr_tail].GetSelectionAmount() - 1_sats) / utxo_pool[curr_tail].GetSelectionAmount()) > best_selection_weight) { + } else if (!best_selection.empty() && curr_weight + int64_t{min_tail_weight[curr_tail]} * int64_t(CeilDiv(uint64_t((total_target - curr_amount).Int()), uint64_t(utxo_pool[curr_tail].GetSelectionAmount().Int()))) > best_selection_weight) { // Compare minimal tail weight and last selected amount with the amount missing to gauge whether a better weight is still possible. if (utxo_pool[curr_tail].m_weight <= min_tail_weight[curr_tail]) { should_cut = true; ```
hodlinator (Migrated from github.com) commented 2026-07-01 11:43:18 +00:00

Agreed, thanks for pushing back on this.

(Edit: Fixed in later push).

Agreed, thanks for pushing back on this. (Edit: Fixed in later push).
hodlinator (Migrated from github.com) commented 2026-07-01 07:59:22 +00:00

What I'm going for is to make amounts stand out more in code and have less implicit conversions with raw types.

What I'm going for is to make amounts stand out more in code and have less implicit conversions with raw types.
hodlinator (Migrated from github.com) commented 2026-07-01 07:48:19 +00:00

The idea is for CAmount to not implicitly convert back & forth with raw integers. Not sure I follow, are you objecting to there being two calls to COIN.Int()?

The idea is for `CAmount` to not implicitly convert back & forth with raw integers. Not sure I follow, are you objecting to there being two calls to `COIN.Int()`?
hodlinator (Migrated from github.com) commented 2026-06-30 14:27:25 +00:00

0.5 * COIN on master is double * int64_t which somehow ends up being sent into a int64_t parameter. Making COIN a typed amount and disallowing implicit double operations is a step in the right direction I think.
(We also know that 100'000'000 is divisible by 2 without any remainder).

`0.5 * COIN` on master is `double * int64_t` which somehow ends up being sent into a `int64_t` parameter. Making `COIN` a typed amount and disallowing implicit `double` operations is a step in the right direction I think. (We also know that 100'000'000 is divisible by 2 without any remainder).
hodlinator (Migrated from github.com) commented 2026-07-01 07:57:35 +00:00

The literal is only declared in this one .CPP file and has a comment that it should only be used for tests due to imprecision.

github.com/bitcoin/bitcoin@cc90782e0c/src/wallet/test/coinselector_tests.cpp (L34-L39)

(The standard non-long double type has more than enough bits1 to represent satoshi-amounts, which is part of why we have 21M BTC as I got confirmed when I presented this).

The literal is only declared in this one .CPP file and has a comment that it should only be used for tests due to imprecision. https://github.com/bitcoin/bitcoin/blob/cc90782e0cfa602d2b312f0d669d47a7d3d4dd37/src/wallet/test/coinselector_tests.cpp#L34-L39 (The standard non-long `double` type has more than enough bits[^1] to represent satoshi-amounts, which is part of why we have 21M BTC as I got confirmed when I presented this). [^1]: https://cppreference.com/cpp/language/types#Standard_floating-point_types
hodlinator (Migrated from github.com) commented 2026-07-01 07:43:52 +00:00

Good point, it's inconsistent with the similar case around L177.

Good point, it's inconsistent with the similar case around L177.
hodlinator (Migrated from github.com) commented 2026-07-01 07:58:10 +00:00

Agreed, that would be cleaner. However we do have:
github.com/bitcoin/bitcoin@341360964a/src/wallet/spend.cpp (L1485)
So I'd prefer if that change happened in another PR.

Agreed, that would be cleaner. However we do have: https://github.com/bitcoin/bitcoin/blob/341360964a6fef725825639edc507c275f8ad0b2/src/wallet/spend.cpp#L1485 So I'd prefer if that change happened in another PR.
DrahtBot commented 2026-07-07 21:37:40 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-07-14 18:49:12 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-08-07 13:28:19 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task lint: https://github.com/bitcoin/bitcoin/actions/runs/31179697887/job/92869756766
LLM reason (✨ experimental): CI failed because the lint check rpc_assert flagged a fatal assert used in RPC code (src/rpc/rawtransaction.cpp) instead of a non-fatal check.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `lint`: https://github.com/bitcoin/bitcoin/actions/runs/31179697887/job/92869756766</sub> <sub>LLM reason (✨ experimental): CI failed because the lint check `rpc_assert` flagged a fatal `assert` used in RPC code (`src/rpc/rawtransaction.cpp`) instead of a non-fatal check.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
DrahtBot commented 2026-08-11 16:21:37 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
hodlinator commented 2026-08-25 07:40:18 +00:00 (Migrated from github.com)

Latest push removes the _sats UDL. Instead the commits get by on CAmount{<literal>} until the end, when a sats unit is defined and applied as <literal>*sats. (It can also be applied to non-literal expressions). The push also uses scripted diffs to a larger extent than before.

Latest push removes the `_sats` UDL. Instead the commits get by on `CAmount{<literal>}` until the end, when a `sats` unit is defined and applied as `<literal>*sats`. (It can also be applied to non-literal expressions). The push also uses scripted diffs to a larger extent than before.
DrahtBot commented 2026-09-22 23:09:15 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
First-time contributor

1 additional verified finding in the Review report.

Earlier concerns neither republished nor resolved: 2 suggestions. See the Run archive linked from the Review report for their assessments.

🔵 Suggestion · CAmount restrictions lack compile-time regression tests

The amount tests exercise supported expressions, so they would not detect removal of the constructor restrictions that provide the PR's main guarantees.

Location: src/consensus/amount.h:38 (head).

🔵 Suggestion · The Qt property bridge bypasses CAmount restrictions for C++ callers

No current caller misusing these conversions was found, but QAmount and the public setValue(qint64) overload expose integer, boolean and floating-point conversions outside the Qt property bridge.

Location: src/qt/bitcoinamountfield.h:35 (head).

🔵 Suggestion · The new BTC helper changes two coin-selection targets by one satoshi

The two 1.9 * BTC targets evaluate to 189999999 sats with 80-bit long double, versus 190000000 with binary64 long double; no assertion failure was established.

Location: src/wallet/test/coinselector_tests.cpp:39 (head).

🔵 Suggestion · CAmount{...} no longer rejects narrowing integer inputs

Unlike the base typedef's brace initialization, CAmount{u64} can now wrap values above INT64_MAX; no current caller supplying such a value was found.

Location: src/consensus/amount.h:39 (head).

🔵 Suggestion · CAmount IPC building bypasses existing integer-range checks

All current amount fields are Int64, but the new IPC build hook bypasses BuildPrimitive's compile-time checks that the wire type covers the full int64_t range.

Location: src/ipc/capnp/common-types.h:150 (head).

🔵 Suggestion · Orphanage resource ratios acquire monetary types

Eviction ordering is unchanged, but GetDosScore() now represents latency counts and memory usage as CAmount, making non-monetary resource ratios look like satoshi values.

Location: src/node/txorphanage.cpp:166 (head).

Review coverage was incomplete.


Reviewed: b889efb6232c · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:301f8fac66b8cbe87114981d6600f15187695a2edf245458a232c3958e920add:3329223fb40bbbe44124b0523f0fa08f23650d06836368f60e45a38d2db02971 --> <!-- ralph-base:74f3ed9021e853aa14a402ed0ceef78544c5b4a7 --> <!-- ralph-head:b889efb6232cc722e2d056526b5220b1105157c7 --> <!-- ralph-case:6b0852b2accd3b5868c72503f21b5f84132a289d14b977a59f0a91a73cc47861 --> [1 additional verified finding in the Review report](<https://review.fish.foo/report/35511-b889efb6232cc722e2d056526b5220b1105157c7-3062-11.html>). Earlier concerns neither republished nor resolved: 2 suggestions. See the Run archive linked from the Review report for their assessments. **🔵 Suggestion · `CAmount` restrictions lack compile-time regression tests** The amount tests exercise supported expressions, so they would not detect removal of the constructor restrictions that provide the PR's main guarantees. Location: [`src/consensus/amount.h:38`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/b889efb6232cc722e2d056526b5220b1105157c7/src/consensus/amount.h#L38>) (head). **🔵 Suggestion · The Qt property bridge bypasses `CAmount` restrictions for C++ callers** No current caller misusing these conversions was found, but `QAmount` and the public `setValue(qint64)` overload expose integer, boolean and floating-point conversions outside the Qt property bridge. Location: [`src/qt/bitcoinamountfield.h:35`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/b889efb6232cc722e2d056526b5220b1105157c7/src/qt/bitcoinamountfield.h#L35>) (head). **🔵 Suggestion · The new `BTC` helper changes two coin-selection targets by one satoshi** The two `1.9 * BTC` targets evaluate to 189999999 sats with 80-bit `long double`, versus 190000000 with binary64 `long double`; no assertion failure was established. Location: [`src/wallet/test/coinselector_tests.cpp:39`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/b889efb6232cc722e2d056526b5220b1105157c7/src/wallet/test/coinselector_tests.cpp#L39>) (head). **🔵 Suggestion · `CAmount{...}` no longer rejects narrowing integer inputs** Unlike the base typedef's brace initialization, `CAmount{u64}` can now wrap values above `INT64_MAX`; no current caller supplying such a value was found. Location: [`src/consensus/amount.h:39`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/b889efb6232cc722e2d056526b5220b1105157c7/src/consensus/amount.h#L39>) (head). **🔵 Suggestion · `CAmount` IPC building bypasses existing integer-range checks** All current amount fields are `Int64`, but the new IPC build hook bypasses `BuildPrimitive`'s compile-time checks that the wire type covers the full `int64_t` range. Location: [`src/ipc/capnp/common-types.h:150`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/b889efb6232cc722e2d056526b5220b1105157c7/src/ipc/capnp/common-types.h#L150>) (head). **🔵 Suggestion · Orphanage resource ratios acquire monetary types** Eviction ordering is unchanged, but `GetDosScore()` now represents latency counts and memory usage as `CAmount`, making non-monetary resource ratios look like satoshi values. Location: [`src/node/txorphanage.cpp:166`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/b889efb6232cc722e2d056526b5220b1105157c7/src/node/txorphanage.cpp#L166>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`b889efb6232c`](<https://git.fish.foo/bitcoin/bitcoin/commit/b889efb6232cc722e2d056526b5220b1105157c7>) · [Review report](<https://review.fish.foo/report/35511-b889efb6232cc722e2d056526b5220b1105157c7-3062-11.html>) · [Previous reports](<https://review.fish.foo/traces/35511/>) [permalink](<https://review.fish.foo/report/35511-b889efb6232cc722e2d056526b5220b1105157c7-3062-11.html>)
DrahtBot commented 2026-10-12 20:42:15 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task test ancestor commits: https://github.com/bitcoin/bitcoin/actions/runs/38296359020/job/114968285143
LLM reason (✨ experimental): CI failed during compilation: bip352_tests.cpp passes {} for CTxOut amounts, but CAmount’s default constructor is deleted.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `test ancestor commits`: https://github.com/bitcoin/bitcoin/actions/runs/38296359020/job/114968285143</sub> <sub>LLM reason (✨ experimental): CI failed during compilation: `bip352_tests.cpp` passes `{}` for `CTxOut` amounts, but `CAmount`’s default constructor is deleted.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
DrahtBot commented 2026-10-29 16:52:31 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-11-02 23:01:47 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-11-03 09:18:44 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task FreeBSD Cross: https://github.com/bitcoin/bitcoin/actions/runs/41603274148/job/125806849923
LLM reason (✨ experimental): CI fails during compilation because amount_tests.cpp calls CFeeRate with two integer arguments that don’t match its constructor’s CAmount parameter.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `FreeBSD Cross`: https://github.com/bitcoin/bitcoin/actions/runs/41603274148/job/125806849923</sub> <sub>LLM reason (✨ experimental): CI fails during compilation because `amount_tests.cpp` calls `CFeeRate` with two integer arguments that don’t match its constructor’s `CAmount` parameter.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
DrahtBot commented 2026-11-04 18:15:21 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-11-24 14:07:06 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task test ancestor commits: https://github.com/bitcoin/bitcoin/actions/runs/45399558461/job/138464256043
LLM reason (✨ experimental): The build fails because miner_tests.cpp:269 subtracts CAmount feeToUse from a long long, causing an invalid-operand type error.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `test ancestor commits`: https://github.com/bitcoin/bitcoin/actions/runs/45399558461/job/138464256043</sub> <sub>LLM reason (✨ experimental): The build fails because `miner_tests.cpp:269` subtracts `CAmount feeToUse` from a `long long`, causing an invalid-operand type error.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
DrahtBot commented 2026-11-25 10:04:11 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!35511
No description provided.