diff options
author | Andrew Chow <github@achow101.com> | 2023-10-26 14:09:33 -0400 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-10-26 14:18:55 -0400 |
commit | 5572f98f058543eb87922b4a1bd6fccf91364aa9 (patch) | |
tree | f712d60f6006226be9d551744717e1b64bc07de0 /src/wallet/transaction.h | |
parent | cb8844e2b9d3ae3cae613c82683660f0fc5222d6 (diff) | |
parent | 940a49978c70453e1aaf2c4a0bcb382872b844a5 (diff) | |
download | bitcoin-5572f98f058543eb87922b4a1bd6fccf91364aa9.tar.xz |
Merge bitcoin/bitcoin#28107: util: Type-safe transaction identifiers
940a49978c70453e1aaf2c4a0bcb382872b844a5 Use type-safe txid types in orphanage (dergoegge)
ed70e6501648466b9ca91a39b83775363e9a726d Introduce types for txids & wtxids (dergoegge)
cdb14d79e809bf7d1612b21b554a9fcfb2ab1c91 [net processing] Use HasWitness over comparing (w)txids (dergoegge)
Pull request description:
We currently have two different identifiers for transactions: `txid` (refering to the hash of a transaction without witness data) and `wtxid` (referring to the hash of a transaction including witness data). Both are typed as `uint256` which could lead to type-safety bugs in which one transaction identifier type is passed where the other would be expected.
This PR introduces explicit `Txid` and `Wtxid` types that (if used) would cause compilation errors for such type confusion bugs.
(Only the orphanage is converted to use these types in this PR)
ACKs for top commit:
achow101:
ACK 940a49978c70453e1aaf2c4a0bcb382872b844a5
stickies-v:
ACK 940a49978c70453e1aaf2c4a0bcb382872b844a5
hebasto:
ACK 940a49978c70453e1aaf2c4a0bcb382872b844a5, I have reviewed the code and it looks OK.
instagibbs:
re-ACK 940a49978c70453e1aaf2c4a0bcb382872b844a5
BrandonOdiwuor:
re-ACK 940a49978c70453e1aaf2c4a0bcb382872b844a5
glozow:
reACK 940a49978c
Tree-SHA512: 55298d1c2bb82b7a6995e96e554571c22eaf4a89fb2a4d7a236d70e0f625e8cca62ff2490e1c179c47bd93153fe6527b56870198f026f5ee7753d64d7a424c92
Diffstat (limited to 'src/wallet/transaction.h')
-rw-r--r-- | src/wallet/transaction.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/wallet/transaction.h b/src/wallet/transaction.h index 0d0821e857..2969ba7fdb 100644 --- a/src/wallet/transaction.h +++ b/src/wallet/transaction.h @@ -330,8 +330,8 @@ public: bool isInactive() const { return state<TxStateInactive>(); } bool isUnconfirmed() const { return !isAbandoned() && !isConflicted() && !isConfirmed(); } bool isConfirmed() const { return state<TxStateConfirmed>(); } - const uint256& GetHash() const { return tx->GetHash(); } - const uint256& GetWitnessHash() const { return tx->GetWitnessHash(); } + const Txid& GetHash() const { return tx->GetHash(); } + const Wtxid& GetWitnessHash() const { return tx->GetWitnessHash(); } bool IsCoinBase() const { return tx->IsCoinBase(); } private: |