projects
/
rust-lightning
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
28e16ae
)
Add a bindings constructor for `lightning-invoice`'s `Sha256` wrapper
2023-04-115-bindings-upstream-2
author
Matt Corallo
<git@bluematt.me>
Tue, 25 Apr 2023 17:35:24 +0000
(17:35 +0000)
committer
Matt Corallo
<git@bluematt.me>
Tue, 25 Apr 2023 22:51:18 +0000
(22:51 +0000)
lightning-invoice/src/lib.rs
patch
|
blob
|
history
diff --git
a/lightning-invoice/src/lib.rs
b/lightning-invoice/src/lib.rs
index 0923fcc1756d4fd05305ab53b2653d08539949f9..101051b5e7f23509325d42301a424d3045fc7589 100644
(file)
--- a/
lightning-invoice/src/lib.rs
+++ b/
lightning-invoice/src/lib.rs
@@
-455,6
+455,15
@@
pub enum TaggedField {
pub struct Sha256(/// This is not exported to bindings users as the native hash types are not currently mapped
pub sha256::Hash);
pub struct Sha256(/// This is not exported to bindings users as the native hash types are not currently mapped
pub sha256::Hash);
+impl Sha256 {
+ /// Constructs a new [`Sha256`] from the given bytes, which are assumed to be the output of a
+ /// single sha256 hash.
+ #[cfg(c_bindings)]
+ pub fn from_bytes(bytes: &[u8; 32]) -> Self {
+ Self(sha256::Hash::from_slice(bytes).expect("from_slice only fails if len is not 32"))
+ }
+}
+
/// Description string
///
/// # Invariants
/// Description string
///
/// # Invariants