refactor: semi-revert validation error
@@ -45,8 +45,7 @@ use tari_crypto::{
};
use tari_script::ScriptContext;
-use crate::{
- transactions::{
+use crate::transactions::{
crypto_factories::CryptoFactories,
tari_amount::MicroTari,
transaction_components::{
@@ -61,8 +60,6 @@ use crate::{
TransactionOutput,
},
weight::TransactionWeight,
- },
- validation::helpers,
};
pub const LOG_TARGET: &str = "c::tx::aggregated_body";
@@ -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(())
