Remove implicit uint256 conversion and comparison
What changed, and why it matters
This commit removes shortcuts that let a new transaction ID type be silently treated as the older uint256 type. It is a code-cleanup change that makes type mismatches produce compile-time errors rather than compile silently. There is no direct evidence this fixes an exploitable vulnerability; it is a hardening/refactoring step.
Treat as a normal code-quality/type-safety improvement. Review downstream call sites that may now fail to compile and must be updated to use explicit `ToUint256()` or `FromUint256()`. No urgent security response is indicated by the commit itself.
Security signals we found
Type-safety hardening: removal of implicit conversion between distinct identifier types
Prevention of silent comparison/conversion between txid, wtxid, and uint256
No runtime behavior change; compile-time enforcement only
TODO comments indicate this was planned refactoring, not an emergency security fix
Evidence from the diff
The commit deletes the implicit operator const uint256&() conversion and the Compare(const uint256&) overload from transaction_identifier<has_witness>. The TODO comments explicitly state these were transitional helpers intended to be removed once most code adopted the new Txid/Wtxid types. Removing them prevents accidental mixing of uint256 and transaction_identifier values, which could previously compile and silently compare or convert between semantically distinct identifiers (e.g., txid vs. wtxid vs. raw uint256).
Changed components
src/util/transaction_identifier.htransaction_identifier<Txid>/transaction_identifier<Wtxid> template classInspect captured patch +0 / −12
diff --git a/src/util/transaction_identifier.h b/src/util/transaction_identifier.h
index 30302f06..b59f2e77 100644
--- a/src/util/transaction_identifier.h
+++ b/src/util/transaction_identifier.h
@@ -24,9 +24,6 @@ class transaction_identifier
// Note: Use FromUint256 externally instead.
transaction_identifier(const uint256& wrapped) : m_wrapped{wrapped} {}
- // TODO: Comparisons with uint256 should be disallowed once we have
- // converted most of the code to using the new txid types.
- constexpr int Compare(const uint256& other) const { return m_wrapped.Compare(other); }
constexpr int Compare(const transaction_identifier<has_witness>& other) const { return m_wrapped.Compare(other.m_wrapped); }
template <typename Other>
constexpr int Compare(const Other& other) const
@@ -65,15 +62,6 @@ public:
constexpr const std::byte* end() const { return reinterpret_cast<const std::byte*>(m_wrapped.end()); }
template <typename Stream> void Serialize(Stream& s) const { m_wrapped.Serialize(s); }
template <typename Stream> void Unserialize(Stream& s) { m_wrapped.Unserialize(s); }
-
- /** Conversion function to `uint256`.
- *
- * Note: new code should use `ToUint256`.
- *
- * TODO: This should be removed once the majority of the code has switched
- * to using the Txid and Wtxid types. Until then it makes for a smoother
- * transition to allow this conversion. */
- operator const uint256&() const LIFETIMEBOUND { return m_wrapped; }
};
/** Txid commits to all transaction fields except the witness. */
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.