File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -1516,6 +1516,9 @@ impl From<BdkEncodeError> for TransactionError {
15161516pub enum HashParseError {
15171517 #[ error( "invalid hash: expected length 32 bytes, got {len} bytes" ) ]
15181518 InvalidHash { len : u32 } ,
1519+
1520+ #[ error( "invalid hex string: {hex}" ) ]
1521+ InvalidHexString { hex : String } ,
15191522}
15201523
15211524impl From < bdk_kyoto:: builder:: SqlInitializationError > for CbfBuilderError {
Original file line number Diff line number Diff line change @@ -35,6 +35,14 @@ macro_rules! impl_hash_like {
3535 Ok ( Self ( hash_like) )
3636 }
3737
38+ /// Construct a hash-like type from a hex string.
39+ #[ uniffi:: constructor]
40+ pub fn from_string( hex: String ) -> Result <Self , HashParseError > {
41+ hex. parse:: <$core_type>( )
42+ . map( Self )
43+ . map_err( |_| HashParseError :: InvalidHexString { hex } )
44+ }
45+
3846 /// Serialize this type into a 32 byte array.
3947 pub fn serialize( & self ) -> Vec <u8 > {
4048 serialize( & self . 0 )
You can’t perform that action at this time.
0 commit comments