@@ -43,6 +43,7 @@ use bitcoin::secp256k1::PublicKey;
43
43
use bitcoin:: secp256k1:: { Message , Secp256k1 } ;
44
44
use bitcoin:: secp256k1:: ecdsa:: RecoverableSignature ;
45
45
46
+ use alloc:: boxed:: Box ;
46
47
use core:: cmp:: Ordering ;
47
48
use core:: fmt:: { Display , Formatter , self } ;
48
49
use core:: iter:: FilterMap ;
@@ -999,6 +1000,12 @@ macro_rules! find_all_extract {
999
1000
1000
1001
#[ allow( missing_docs) ]
1001
1002
impl 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
+
1002
1009
/// Hash the HRP as bytes and signatureless data part.
1003
1010
fn hash_from_parts ( hrp_bytes : & [ u8 ] , data_without_signature : & [ Fe32 ] ) -> [ u8 ; 32 ] {
1004
1011
use crate :: de:: FromBase32 ;
@@ -1029,9 +1036,9 @@ impl RawBolt11Invoice {
1029
1036
pub fn signable_hash ( & self ) -> [ u8 ; 32 ] {
1030
1037
use crate :: ser:: Base32Iterable ;
1031
1038
1032
- RawBolt11Invoice :: hash_from_parts (
1039
+ RawBolt11Invoice :: hash_from_parts_iter (
1033
1040
self . hrp . to_string ( ) . as_bytes ( ) ,
1034
- & self . data . fe_iter ( ) . collect :: < Vec < Fe32 > > ( ) ,
1041
+ self . data . fe_iter ( ) ,
1035
1042
)
1036
1043
}
1037
1044
0 commit comments