Skip to content

Commit

Permalink
refactor: semi-revert validation error
Browse files Browse the repository at this point in the history
  • Loading branch information
stringhandler committed Dec 13, 2022
1 parent 774ab7a commit 47fdf93
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions base_layer/core/src/transactions/aggregated_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,21 @@ use tari_crypto::{
};
use tari_script::ScriptContext;

use crate::{
transactions::{
crypto_factories::CryptoFactories,
tari_amount::MicroTari,
transaction_components::{
transaction_output::batch_verify_range_proofs,
KernelFeatures,
KernelSum,
OutputType,
Transaction,
TransactionError,
TransactionInput,
TransactionKernel,
TransactionOutput,
},
weight::TransactionWeight,
use crate::transactions::{
crypto_factories::CryptoFactories,
tari_amount::MicroTari,
transaction_components::{
transaction_output::batch_verify_range_proofs,
KernelFeatures,
KernelSum,
OutputType,
Transaction,
TransactionError,
TransactionInput,
TransactionKernel,
TransactionOutput,
},
validation::helpers,
weight::TransactionWeight,
};

pub const LOG_TARGET: &str = "c::tx::aggregated_body";
Expand Down Expand Up @@ -330,7 +327,16 @@ impl AggregateBody {

pub fn check_output_features(&self, max_coinbase_metadata_size: u32) -> Result<(), TransactionError> {
for output in self.outputs() {
helpers::check_output_feature(output, max_coinbase_metadata_size)?;
if !output.is_coinbase() && !output.features.coinbase_extra.is_empty() {
return Err(TransactionError::NonCoinbaseHasOutputFeaturesCoinbaseExtra);
}

if output.is_coinbase() && output.features.coinbase_extra.len() as u32 > max_coinbase_metadata_size {
return Err(TransactionError::InvalidOutputFeaturesCoinbaseExtraSize {
len: output.features.coinbase_extra.len(),
max: max_coinbase_metadata_size,
});
}
}

Ok(())
Expand Down

0 comments on commit 47fdf93

Please sign in to comment.