@@ -109,24 +109,34 @@ impl Commitment {
109
109
use Commitment :: * ;
110
110
use CommitmentError :: * ;
111
111
112
- match NetworkUpgrade :: current ( network, height) {
113
- Genesis | BeforeOverwinter | Overwinter => Ok ( PreSaplingReserved ( bytes) ) ,
114
- Sapling | Blossom => match sapling:: tree:: Root :: try_from ( bytes) {
112
+ match NetworkUpgrade :: current_with_activation_height ( network, height) {
113
+ ( Genesis | BeforeOverwinter | Overwinter , _ ) => Ok ( PreSaplingReserved ( bytes) ) ,
114
+ ( Sapling | Blossom , _ ) => match sapling:: tree:: Root :: try_from ( bytes) {
115
115
Ok ( root) => Ok ( FinalSaplingRoot ( root) ) ,
116
116
_ => Err ( InvalidSapingRootBytes ) ,
117
117
} ,
118
+ ( Heartwood , activation_height) if height == activation_height => {
119
+ if bytes == CHAIN_HISTORY_ACTIVATION_RESERVED {
120
+ Ok ( ChainHistoryActivationReserved )
121
+ } else {
122
+ Err ( InvalidChainHistoryActivationReserved { actual : bytes } )
123
+ }
124
+ }
118
125
// NetworkUpgrade::current() returns the latest network upgrade that's activated at the provided height, so
119
126
// on Regtest for heights above height 0, it returns NU5, and it's possible for the current network upgrade
120
127
// to be NU5 (or Canopy, or any network upgrade above Heartwood) at the Heartwood activation height.
121
- Heartwood | Canopy | Nu5 if Some ( height) == Heartwood . activation_height ( network) => {
128
+ ( Canopy | Nu5 , activation_height)
129
+ if height == activation_height
130
+ && Some ( height) == Heartwood . activation_height ( network) =>
131
+ {
122
132
if bytes == CHAIN_HISTORY_ACTIVATION_RESERVED {
123
133
Ok ( ChainHistoryActivationReserved )
124
134
} else {
125
135
Err ( InvalidChainHistoryActivationReserved { actual : bytes } )
126
136
}
127
137
}
128
- Heartwood | Canopy => Ok ( ChainHistoryRoot ( ChainHistoryMmrRootHash ( bytes) ) ) ,
129
- Nu5 => Ok ( ChainHistoryBlockTxAuthCommitment (
138
+ ( Heartwood | Canopy , _ ) => Ok ( ChainHistoryRoot ( ChainHistoryMmrRootHash ( bytes) ) ) ,
139
+ ( Nu5 , _ ) => Ok ( ChainHistoryBlockTxAuthCommitment (
130
140
ChainHistoryBlockTxAuthCommitmentHash ( bytes) ,
131
141
) ) ,
132
142
}
0 commit comments