Struct lightning::ln::chan_utils::CounterpartyCommitmentSecrets
source · [−]pub struct CounterpartyCommitmentSecrets { /* private fields */ }
Expand description
Implements the per-commitment secret storage scheme from BOLT 3.
Allows us to keep track of all of the revocation secrets of our counterparty in just 50*32 bytes or so.
Implementations
sourceimpl CounterpartyCommitmentSecrets
impl CounterpartyCommitmentSecrets
sourcepub fn get_min_seen_secret(&self) -> u64
pub fn get_min_seen_secret(&self) -> u64
Returns the minimum index of all stored secrets. Note that indexes start at 1 << 48 and get decremented by one for each new secret.
sourcepub fn provide_secret(&mut self, idx: u64, secret: [u8; 32]) -> Result<(), ()>
pub fn provide_secret(&mut self, idx: u64, secret: [u8; 32]) -> Result<(), ()>
Inserts the secret
at idx
. Returns Ok(())
if the secret
was generated in accordance with BOLT 3 and is consistent with previous secrets.
sourcepub fn get_secret(&self, idx: u64) -> Option<[u8; 32]>
pub fn get_secret(&self, idx: u64) -> Option<[u8; 32]>
Returns the secret at idx
.
Returns None
if idx
is < CounterpartyCommitmentSecrets::get_min_seen_secret
.
Trait Implementations
sourceimpl Clone for CounterpartyCommitmentSecrets
impl Clone for CounterpartyCommitmentSecrets
sourcefn clone(&self) -> CounterpartyCommitmentSecrets
fn clone(&self) -> CounterpartyCommitmentSecrets
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Writeable for CounterpartyCommitmentSecrets
impl Writeable for CounterpartyCommitmentSecrets
sourcefn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error>
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error>
Writes self out to the given Writer
sourcefn encode(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn encode(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Writes self out to a Vec
sourcefn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
Gets the length of this object after it has been serialized. This can be overridden to optimize cases where we prepend an object with its length. Read more
Auto Trait Implementations
impl RefUnwindSafe for CounterpartyCommitmentSecrets
impl Send for CounterpartyCommitmentSecrets
impl Sync for CounterpartyCommitmentSecrets
impl Unpin for CounterpartyCommitmentSecrets
impl UnwindSafe for CounterpartyCommitmentSecrets
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more