@@ -5,11 +5,12 @@ use bitcoin::FeeRate;
55use log:: warn;
66
77use crate :: output_substitution:: OutputSubstitution ;
8+ use crate :: Version ;
89
910#[ derive( Debug , Clone ) ]
1011pub ( crate ) struct Params {
1112 // version
12- pub v : usize ,
13+ pub v : Version ,
1314 // disableoutputsubstitution
1415 pub output_substitution : OutputSubstitution ,
1516 // maxadditionalfeecontribution, additionalfeeoutputindex
@@ -24,7 +25,7 @@ pub(crate) struct Params {
2425impl Default for Params {
2526 fn default ( ) -> Self {
2627 Params {
27- v : 1 ,
28+ v : Version :: One ,
2829 output_substitution : OutputSubstitution :: Enabled ,
2930 additional_fee_contribution : None ,
3031 min_fee_rate : FeeRate :: BROADCAST_MIN ,
@@ -37,7 +38,7 @@ impl Default for Params {
3738impl Params {
3839 pub fn from_query_pairs < K , V , I > (
3940 pairs : I ,
40- supported_versions : & ' static [ usize ] ,
41+ supported_versions : & ' static [ Version ] ,
4142 ) -> Result < Self , Error >
4243 where
4344 I : Iterator < Item = ( K , V ) > ,
@@ -52,8 +53,9 @@ impl Params {
5253 for ( key, v) in pairs {
5354 match ( key. borrow ( ) , v. borrow ( ) ) {
5455 ( "v" , version) =>
55- params. v = match version. parse :: < usize > ( ) {
56- Ok ( version) if supported_versions. contains ( & version) => version,
56+ params. v = match version {
57+ "1" => Version :: One ,
58+ "2" => Version :: Two ,
5759 _ => return Err ( Error :: UnknownVersion { supported_versions } ) ,
5860 } ,
5961 ( "additionalfeeoutputindex" , index) =>
@@ -117,7 +119,7 @@ impl Params {
117119
118120#[ derive( Debug ) ]
119121pub ( crate ) enum Error {
120- UnknownVersion { supported_versions : & ' static [ usize ] } ,
122+ UnknownVersion { supported_versions : & ' static [ Version ] } ,
121123 FeeRate ,
122124}
123125
0 commit comments