Handle zero transaction expirations (#2782)

* handle zero transaction expirations

* add consensus rule doc

Co-authored-by: teor <teor@riseup.net>

Co-authored-by: teor <teor@riseup.net>
This commit is contained in:
Alfredo Garcia 2021-09-22 00:44:52 -03:00 committed by GitHub
parent b714b2b3b6
commit 825da448c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -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)),
},
}
}

View File

@ -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();