File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,8 @@ mod offers_tests;
8585
8686pub use self :: peer_channel_encryptor:: LN_MAX_MSG_LEN ;
8787
88+ use bitcoin:: hashes:: { sha256:: Hash as Sha256 , Hash } ;
89+
8890/// payment_hash type, use to cross-lock hop
8991///
9092/// This is not exported to bindings users as we just use [u8; 32] directly
@@ -109,6 +111,13 @@ impl core::fmt::Display for PaymentPreimage {
109111 }
110112}
111113
114+ /// Converts a `PaymentPreimage` into a `PaymentHash` by hashing the preimage with SHA256.
115+ impl Into < PaymentHash > for PaymentPreimage {
116+ fn into ( self ) -> PaymentHash {
117+ PaymentHash ( Sha256 :: hash ( & self . 0 ) . to_byte_array ( ) )
118+ }
119+ }
120+
112121/// payment_secret type, use to authenticate sender to the receiver and tie MPP HTLCs together
113122///
114123/// This is not exported to bindings users as we just use [u8; 32] directly
You can’t perform that action at this time.
0 commit comments