-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(applying): check non-empty set of inputs and outputs (#312)
- Loading branch information
1 parent
93c978b
commit eb4f39d
Showing
4 changed files
with
111 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
//! Utilities required for Byron-era transaction validation. | ||
use crate::types::{ByronProtParams, UTxOs, ValidationResult}; | ||
use crate::types::{ByronProtParams, UTxOs, ValidationError, ValidationResult}; | ||
|
||
use pallas_primitives::byron::MintedTxPayload; | ||
use pallas_primitives::byron::{MintedTxPayload, Tx}; | ||
|
||
// TODO: implement each of the validation rules. | ||
// TODO: implement missing validation rules. | ||
pub fn validate_byron_tx( | ||
_mtxp: &MintedTxPayload, | ||
mtxp: &MintedTxPayload, | ||
_utxos: &UTxOs, | ||
_prot_pps: &ByronProtParams, | ||
) -> ValidationResult { | ||
let tx: &Tx = &mtxp.transaction; | ||
check_ins_not_empty(tx)?; | ||
check_outs_not_empty(tx) | ||
} | ||
|
||
fn check_ins_not_empty(tx: &Tx) -> ValidationResult { | ||
if tx.inputs.clone().to_vec().is_empty() { | ||
return Err(ValidationError::TxInsEmpty); | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn check_outs_not_empty(tx: &Tx) -> ValidationResult { | ||
if tx.outputs.clone().to_vec().is_empty() { | ||
return Err(ValidationError::TxOutsEmpty); | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters