We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
lightning-invoice
Sha256
1 parent 63ea8ea commit 4c26091Copy full SHA for 4c26091
lightning-invoice/src/lib.rs
@@ -455,6 +455,15 @@ pub enum TaggedField {
455
pub struct Sha256(/// This is not exported to bindings users as the native hash types are not currently mapped
456
pub sha256::Hash);
457
458
+impl Sha256 {
459
+ /// Constructs a new [`Sha256`] from the given bytes, which are assumed to be the output of a
460
+ /// single sha256 hash.
461
+ #[cfg(c_bindings)]
462
+ pub fn from_bytes(bytes: &[u8; 32]) -> Self {
463
+ Self(sha256::Hash::from_slice(bytes).expect("from_slice only fails if len is not 32"))
464
+ }
465
+}
466
+
467
/// Description string
468
///
469
/// # Invariants
0 commit comments