5 suggestions
Earlier concerns neither republished nor resolved: 2 suggestions. See the Run archive for their assessments.
Optional improvements
[suggestion] · The GUI amount-field API still permits implicit numeric conversions
The GUI getter and setter still permit bool, floating-point, and raw-integer conversions that the new CAmount API intends to reject.
Location: src/qt/bitcoinamountfield.h:31 (head).
Details and suggested fix
QAmount publicly adds an implicit operator qint64(), so ordinary callers of value() can still compile value() * 0.5, value() * value(), value() == 0, and if (value()). The public setValue(qint64) also accepts true and truncates 1.5. Return CAmount from the ordinary getter and keep only setValue(const CAmount&). Preserve the existing qint64 property through separately named private adapters such as qint64Value() and setQint64Value(qint64); moc can call these as class members. The settings read and write in sendcoinsdialog.cpp then need explicit CAmount{...} and .Int() conversions. Current callers use typed comparisons and parsing checks the range, so no incorrect payment is established. The base integer alias already allowed these expressions; this is a type-safety gap left open by the migration, not a behavioral regression.
[suggestion] · Braced CAmount construction no longer rejects unsigned narrowing
Braced construction from uint64_t now bypasses narrowing diagnostics and can turn values above INT64_MAX into negative amounts, although no current caller producing such an input was found.
Location: src/consensus/amount.h:36 (head).
Details and suggested fix
For a non-constant uint64_t u, CAmount{u} deduces the constructor's T as uint64_t, then converts it through the parenthesized m_sats(sats) initializer without checking representability. Values above INT64_MAX therefore become negative amounts. With the base int64_t alias, the same braced construction was ill-formed narrowing. Constrain the constructor to integral source types whose entire range fits in int64_t, requiring deliberate int64_t casts at existing unsigned boundaries such as FeeFrac::EvaluateFee and coinstatsindex's GetLow64() conversion. This restores a compiler-enforced boundary without treating legitimate negative amounts as invalid.
[suggestion] · CAmount's compile-time restrictions lack regression coverage
The amount tests exercise valid numerical operations but do not assert rejection of forbidden construction, conversions, or arithmetic.
Location: src/consensus/amount.h:33 (head).
Details and suggested fix
The new safety contract is compile-time, but the numerical assertions would still accept unused additions such as default construction, bool construction, implicit integer conversion, or amount-by-amount multiplication. Add static_assert checks in amount_tests.cpp for non-default-constructibility, rejection of bool and double, and construction from int64_t without implicit conversion. For operators, use a file-scope dependent helper such as template <class A, class B> concept Multipliable = requires(A a, B b) { a * b; };. Assert that amount-by-amount and floating-point multiplication are unavailable while integral-scalar multiplication remains supported. Apply the same pattern to mixed integer comparisons. These expression checks must be dependent: an invalid expression in a non-dependent requires expression is a hard error rather than false. util_not_null_tests.cpp already demonstrates this testing style.
[suggestion] · Orphanage resource scores acquire a satoshi type
Making FeeFrac::fee a CAmount forces orphanage latency and memory scores into monetary types without changing eviction behavior.
Location: src/node/txorphanage.cpp:166 (head).
Details and suggested fix
GetDosScore() now constructs CAmount values from latency-score counts and weight-based memory usage, while LimitOrphans() labels the dimensionless threshold as 1*sats. Neither resource measures satoshis. The arithmetic and eviction ordering remain unchanged, but these conversions weaken the intended unit distinction and expose fee-evaluation APIs returning monetary amounts on resource ratios. Give the orphanage a dedicated integer-ratio type rather than wrapping its scores in CAmount. Preserve the overflow-safe cross-multiplication comparison, reversed-denominator tie-break, and subsequent peer-ID tie-break. This costs an additional ratio type but leaves monetary FeeFrac users unchanged.
[suggestion] · The fee-delta initializer repeats the map lookup
For a new txid, the replacement for mapDeltas[hash] searches the tree twice; try_emplace can insert the explicit zero in one lookup.
Location: src/txmempool.cpp:682 (head).
Details and suggested fix
The lambda calls find() and then emplace(hash, 0) when the entry is absent. Replace it with CAmount& delta{mapDeltas.try_emplace(hash, 0*sats).first->second};. try_emplace leaves an existing delta untouched and constructs the explicit zero only on a miss, without requiring a default constructor. It returns the same stable mapped-value reference needed by the following SaturatingAdd update and zero-delta erase. The existing LOCK(cs) still protects the operation, so the lambda and its nested lock annotation are unnecessary.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Fractional CoinGrinder test targets lose a satoshi on some platforms (earlier report)
- [suggestion]: The CAmount IPC writer skips the integer-width check (earlier report)