Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions dash/src/blockdata/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,13 @@ impl Decodable for Transaction {
) -> Result<Self, encode::Error> {
let version = u16::consensus_decode_from_finite_reader(r)?;
let special_transaction_type_u16 = u16::consensus_decode(r)?;
let special_transaction_type = TransactionType::try_from(special_transaction_type_u16)
.map_err(|_| {
let special_transaction_type = if version != 0 {
TransactionType::try_from(special_transaction_type_u16).map_err(|_| {
encode::Error::UnknownSpecialTransactionType(special_transaction_type_u16)
})?;
})?
} else {
TransactionType::Classic
};
Comment on lines +600 to +606

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Preserve the raw type bits for version-0 transactions.

Line 600 fixes deserialization, but it also drops the original on-wire special_transaction_type_u16 when version == 0. After that, consensus_encode() and txid() re-emit/hash self.tx_type() as 0, so this malformed mainnet transaction no longer round-trips and its IDs can change after decode. If we need to treat pre-DIP-0002 transactions as Classic, we still need to retain the raw u16 (or full raw version word) somewhere so serialization and hashing stay faithful to the chain data.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dash/src/blockdata/transaction/mod.rs` around lines 600 - 606, The fix must
preserve the original on-wire special_transaction_type_u16 for version == 0
while still treating it as TransactionType::Classic for logic; update the
struct/backing fields used by TransactionType::try_from so that the raw u16 (or
the full raw version word) is stored (e.g., add/keep a raw_special_tx_type
field) and use TransactionType::Classic only for behavior, but have
consensus_encode(), txid(), and tx_type() re-emit the preserved raw u16 when
serializing/hashing; change the deserialization branch around
TransactionType::try_from(special_transaction_type_u16) so version == 0 assigns
TransactionType::Classic but also saves special_transaction_type_u16 into the
raw field, and update consensus_encode()/txid()/tx_type() to prefer the raw
field for output.

let input = Vec::<TxIn>::consensus_decode_from_finite_reader(r)?;
// segwit
let mut segwit = input.is_empty();
Expand Down
Loading