File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,8 @@ mod offers_tests;
85
85
86
86
pub use self :: peer_channel_encryptor:: LN_MAX_MSG_LEN ;
87
87
88
+ use bitcoin:: hashes:: { sha256:: Hash as Sha256 , Hash } ;
89
+
88
90
/// payment_hash type, use to cross-lock hop
89
91
///
90
92
/// This is not exported to bindings users as we just use [u8; 32] directly
@@ -109,6 +111,13 @@ impl core::fmt::Display for PaymentPreimage {
109
111
}
110
112
}
111
113
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
+
112
121
/// payment_secret type, use to authenticate sender to the receiver and tie MPP HTLCs together
113
122
///
114
123
/// 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