Struct DecryptedOurPeerStorage

Source
pub struct DecryptedOurPeerStorage { /* private fields */ }
Expand description

DecryptedOurPeerStorage is used to store serialised channel information that allows for the creation of a peer_storage backup.

This structure is designed to serialize channel data for backup and supports encryption using ChaCha20Poly1305RFC for transmission.

§Key Methods

§Example

use lightning::ln::our_peer_storage::DecryptedOurPeerStorage;
use lightning::sign::{KeysManager, NodeSigner};
let seed = [1u8; 32];
let keys_mgr = KeysManager::new(&seed, 42, 42, true);
let key = keys_mgr.get_peer_storage_key();
let decrypted_ops = DecryptedOurPeerStorage::new(vec![1, 2, 3]);
let our_peer_storage = decrypted_ops.encrypt(&key, &[0u8; 32]);
let decrypted_data = our_peer_storage.decrypt(&key).unwrap();
assert_eq!(decrypted_data.into_vec(), vec![1, 2, 3]);

Implementations§

Source§

impl DecryptedOurPeerStorage

Source

pub fn new(data: Vec<u8>) -> Self

Returns DecryptedOurPeerStorage with the given data.

Source

pub fn into_vec(self) -> Vec<u8>

Returns data stored in Vec<u8> format.

Source

pub fn encrypt( self, key: &PeerStorageKey, random_bytes: &[u8; 32], ) -> EncryptedOurPeerStorage

Encrypts the data inside DecryptedOurPeerStorage using PeerStorageKey and random_bytes and returns EncryptedOurPeerStorage.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V