pub struct Preimage {
pub bytes: Option<[u8; 32]>,
pub sha256: Hash,
pub hash160: Hash,
}Expand description
Helper to work with Preimage & Hashes required for swap scripts.
Fields§
§bytes: Option<[u8; 32]>§sha256: Hash§hash160: HashImplementations§
Source§impl Preimage
impl Preimage
Sourcepub fn random() -> Preimage
pub fn random() -> Preimage
Creates a new random preimage RECOMMENDED NOT TO USE THIS FUNCTION USE FROM_SWAP_KEY INSTEAD
Sourcepub fn from_vec(preimage: Vec<u8>) -> Result<Preimage, Error>
pub fn from_vec(preimage: Vec<u8>) -> Result<Preimage, Error>
Creates a struct from a preimage vector.
Sourcepub fn from_sha256_str(preimage_sha256: &str) -> Result<Preimage, Error>
pub fn from_sha256_str(preimage_sha256: &str) -> Result<Preimage, Error>
Creates a Preimage struct without a value and only a hash Used only in submarine swaps where we do not know the preimage, only the hash
Sourcepub fn from_sha256_vec(preimage_sha256: Vec<u8>) -> Result<Preimage, Error>
pub fn from_sha256_vec(preimage_sha256: Vec<u8>) -> Result<Preimage, Error>
Creates a Preimage struct without a value and only a hash Used only in submarine swaps where we do not know the preimage, only the hash
Sourcepub fn from_invoice_str(invoice_str: &str) -> Result<Preimage, Error>
pub fn from_invoice_str(invoice_str: &str) -> Result<Preimage, Error>
Extracts the preimage sha256 hash from a lightning invoice Creates a Preimage struct without a value and only a hash
Sourcepub fn from_swap_key(keypair: &Keypair) -> Preimage
pub fn from_swap_key(keypair: &Keypair) -> Preimage
Creates a Preimage from a KeyPair’s private key hash sha256(privateKey(index)) RECOMMENDED TO ENSURE SWAPS CAN BE RESTORED MORE EASILY
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Preimage
impl<'de> Deserialize<'de> for Preimage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Preimage
impl StructuralPartialEq for Preimage
Auto Trait Implementations§
impl Freeze for Preimage
impl RefUnwindSafe for Preimage
impl Send for Preimage
impl Sync for Preimage
impl Unpin for Preimage
impl UnwindSafe for Preimage
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)