Skip to content

Commit

Permalink
Handle zero transaction expirations (#2782)
Browse files Browse the repository at this point in the history
* handle zero transaction expirations

* add consensus rule doc

Co-authored-by: teor <[email protected]>

Co-authored-by: teor <[email protected]>
  • Loading branch information
oxarbitrage and teor2345 authored Sep 22, 2021
1 parent b714b2b commit 825da44
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions zebra-chain/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,15 @@ impl Transaction {
match self {
Transaction::V1 { .. } => None,
Transaction::V2 { .. } => None,
Transaction::V3 { expiry_height, .. } => Some(*expiry_height),
Transaction::V4 { expiry_height, .. } => Some(*expiry_height),
Transaction::V5 { expiry_height, .. } => Some(*expiry_height),
Transaction::V3 { expiry_height, .. }
| Transaction::V4 { expiry_height, .. }
| Transaction::V5 { expiry_height, .. } => match expiry_height {
// Consensus rule:
// > No limit: To set no limit on transactions (so that they do not expire), nExpiryHeight should be set to 0.
// https://zips.z.cash/zip-0203#specification
block::Height(0) => None,
block::Height(expiry_height) => Some(block::Height(*expiry_height)),
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion zebra-consensus/src/block/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ fn founders_reward_validation_failure() -> Result<(), Report> {
inputs: transaction.inputs().to_vec(),
outputs: vec![transaction.outputs()[0].clone()],
lock_time: transaction.lock_time(),
expiry_height: transaction.expiry_height().unwrap(),
expiry_height: Height(0),
joinsplit_data: None,
})
.unwrap();
Expand Down

0 comments on commit 825da44

Please sign in to comment.