@@ -48,6 +48,7 @@ use core::iter::FilterMap;
4848use core:: num:: ParseIntError ;
4949use core:: ops:: Deref ;
5050use core:: slice:: Iter ;
51+ use core:: str:: FromStr ;
5152use core:: time:: Duration ;
5253
5354#[ cfg( feature = "serde" ) ]
@@ -78,8 +79,12 @@ use crate::prelude::*;
7879/// Re-export serialization traits
7980#[ cfg( fuzzing) ]
8081pub use crate :: de:: FromBase32 ;
82+ #[ cfg( not( fuzzing) ) ]
83+ use crate :: de:: FromBase32 ;
8184#[ cfg( fuzzing) ]
8285pub use crate :: ser:: Base32Iterable ;
86+ #[ cfg( not( fuzzing) ) ]
87+ use crate :: ser:: Base32Iterable ;
8388
8489/// Errors that indicate what is wrong with the invoice. They have some granularity for debug
8590/// reasons, but should generally result in an "invalid BOLT11 invoice" message for the user.
@@ -1189,6 +1194,21 @@ impl RawBolt11Invoice {
11891194 pub fn currency ( & self ) -> Currency {
11901195 self . hrp . currency . clone ( )
11911196 }
1197+
1198+ /// Convert to HRP prefix and Fe32 encoded data part.
1199+ /// Can be used to transmit unsigned invoices for remote signing.
1200+ pub fn to_raw ( & self ) -> ( String , Vec < Fe32 > ) {
1201+ ( self . hrp . to_string ( ) , self . data . fe_iter ( ) . collect ( ) )
1202+ }
1203+
1204+ /// Convert from HRP prefix and Fe32 encoded data part.
1205+ /// Can be used to receive unsigned invoices for remote signing.
1206+ pub fn from_raw ( hrp : & str , data : & [ Fe32 ] ) -> Result < Self , Bolt11ParseError > {
1207+ let raw_hrp: RawHrp = RawHrp :: from_str ( hrp) ?;
1208+ let data_part = RawDataPart :: from_base32 ( data) ?;
1209+
1210+ Ok ( Self { hrp : raw_hrp, data : data_part } )
1211+ }
11921212}
11931213
11941214impl PositiveTimestamp {
0 commit comments