@@ -43,6 +43,7 @@ use bitcoin::secp256k1::PublicKey;
4343use bitcoin:: secp256k1:: { Message , Secp256k1 } ;
4444use bitcoin:: secp256k1:: ecdsa:: RecoverableSignature ;
4545
46+ use alloc:: boxed:: Box ;
4647use core:: cmp:: Ordering ;
4748use core:: fmt:: { Display , Formatter , self } ;
4849use core:: iter:: FilterMap ;
@@ -999,6 +1000,12 @@ macro_rules! find_all_extract {
9991000
10001001#[ allow( missing_docs) ]
10011002impl RawBolt11Invoice {
1003+ /// Hash the HRP (as bytes) and signatureless data part (as Fe32 iterator)
1004+ fn hash_from_parts_iter < ' s > ( hrp_bytes : & [ u8 ] , data_without_signature_iter : Box < dyn Iterator < Item = Fe32 > + ' s > ) -> [ u8 ; 32 ] {
1005+ let data_part_signature = data_without_signature_iter. collect :: < Vec < Fe32 > > ( ) ;
1006+ Self :: hash_from_parts ( hrp_bytes, & data_part_signature[ ..] )
1007+ }
1008+
10021009 /// Hash the HRP as bytes and signatureless data part.
10031010 fn hash_from_parts ( hrp_bytes : & [ u8 ] , data_without_signature : & [ Fe32 ] ) -> [ u8 ; 32 ] {
10041011 use crate :: de:: FromBase32 ;
@@ -1029,9 +1036,9 @@ impl RawBolt11Invoice {
10291036 pub fn signable_hash ( & self ) -> [ u8 ; 32 ] {
10301037 use crate :: ser:: Base32Iterable ;
10311038
1032- RawBolt11Invoice :: hash_from_parts (
1039+ RawBolt11Invoice :: hash_from_parts_iter (
10331040 self . hrp . to_string ( ) . as_bytes ( ) ,
1034- & self . data . fe_iter ( ) . collect :: < Vec < Fe32 > > ( ) ,
1041+ self . data . fe_iter ( ) ,
10351042 )
10361043 }
10371044
0 commit comments