@@ -570,41 +570,52 @@ impl StacksBlock {
570
570
epoch_id : StacksEpochId ,
571
571
) -> bool {
572
572
for tx in txs. iter ( ) {
573
- if let TransactionPayload :: Coinbase ( _, ref recipient_opt, ref proof_opt) = & tx. payload {
574
- if proof_opt. is_some ( ) && epoch_id < StacksEpochId :: Epoch30 {
575
- // not supported
576
- error ! ( "Coinbase with VRF proof not supported before Stacks 3.0" ; "txid" => %tx. txid( ) ) ;
577
- return false ;
578
- }
579
- if proof_opt. is_none ( ) && epoch_id >= StacksEpochId :: Epoch30 {
580
- // not supported
581
- error ! ( "Coinbase with VRF proof is required in Stacks 3.0 and later" ; "txid" => %tx. txid( ) ) ;
582
- return false ;
583
- }
584
- if recipient_opt. is_some ( ) && epoch_id < StacksEpochId :: Epoch21 {
585
- // not supported
586
- error ! ( "Coinbase pay-to-alt-recipient not supported before Stacks 2.1" ; "txid" => %tx. txid( ) ) ;
587
- return false ;
588
- }
573
+ if !StacksBlock :: validate_transaction_static_epoch ( tx, epoch_id) {
574
+ return false ;
589
575
}
590
- if let TransactionPayload :: SmartContract ( _, ref version_opt) = & tx. payload {
591
- if version_opt. is_some ( ) && epoch_id < StacksEpochId :: Epoch21 {
592
- // not supported
593
- error ! ( "Versioned smart contracts not supported before Stacks 2.1" ) ;
594
- return false ;
595
- }
576
+ }
577
+ return true ;
578
+ }
579
+
580
+ /// Verify that one transaction is supported in the given epoch, as indicated by `epoch_id`
581
+ pub fn validate_transaction_static_epoch (
582
+ tx : & StacksTransaction ,
583
+ epoch_id : StacksEpochId ,
584
+ ) -> bool {
585
+ if let TransactionPayload :: Coinbase ( _, ref recipient_opt, ref proof_opt) = & tx. payload {
586
+ if proof_opt. is_some ( ) && epoch_id < StacksEpochId :: Epoch30 {
587
+ // not supported
588
+ error ! ( "Coinbase with VRF proof not supported before Stacks 3.0" ; "txid" => %tx. txid( ) ) ;
589
+ return false ;
596
590
}
597
- if let TransactionPayload :: TenureChange ( ..) = & tx. payload {
598
- if epoch_id < StacksEpochId :: Epoch30 {
599
- error ! ( "TenureChange transaction not supported before Stacks 3.0" ; "txid" => %tx. txid( ) ) ;
600
- return false ;
601
- }
591
+ if proof_opt. is_none ( ) && epoch_id >= StacksEpochId :: Epoch30 {
592
+ // not supported
593
+ error ! ( "Coinbase with VRF proof is required in Stacks 3.0 and later" ; "txid" => %tx. txid( ) ) ;
594
+ return false ;
602
595
}
603
- if !tx. auth . is_supported_in_epoch ( epoch_id) {
604
- error ! ( "Authentication mode not supported in Epoch {epoch_id}" ) ;
596
+ if recipient_opt. is_some ( ) && epoch_id < StacksEpochId :: Epoch21 {
597
+ // not supported
598
+ error ! ( "Coinbase pay-to-alt-recipient not supported before Stacks 2.1" ; "txid" => %tx. txid( ) ) ;
605
599
return false ;
606
600
}
607
601
}
602
+ if let TransactionPayload :: SmartContract ( _, ref version_opt) = & tx. payload {
603
+ if version_opt. is_some ( ) && epoch_id < StacksEpochId :: Epoch21 {
604
+ // not supported
605
+ error ! ( "Versioned smart contracts not supported before Stacks 2.1" ) ;
606
+ return false ;
607
+ }
608
+ }
609
+ if let TransactionPayload :: TenureChange ( ..) = & tx. payload {
610
+ if epoch_id < StacksEpochId :: Epoch30 {
611
+ error ! ( "TenureChange transaction not supported before Stacks 3.0" ; "txid" => %tx. txid( ) ) ;
612
+ return false ;
613
+ }
614
+ }
615
+ if !tx. auth . is_supported_in_epoch ( epoch_id) {
616
+ error ! ( "Authentication mode not supported in Epoch {epoch_id}" ) ;
617
+ return false ;
618
+ }
608
619
return true ;
609
620
}
610
621
0 commit comments