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§
§impl CounterpartyCommitmentSecrets
impl CounterpartyCommitmentSecrets
pub fn new() -> CounterpartyCommitmentSecrets
pub fn new() -> CounterpartyCommitmentSecrets
Creates a new empty CounterpartyCommitmentSecrets
structure.
pub 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.
pub 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.
pub 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§
§impl Clone for CounterpartyCommitmentSecrets
impl Clone for CounterpartyCommitmentSecrets
§fn clone(&self) -> CounterpartyCommitmentSecrets
fn clone(&self) -> CounterpartyCommitmentSecrets
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl PartialEq for CounterpartyCommitmentSecrets
impl PartialEq for CounterpartyCommitmentSecrets
§impl Readable for CounterpartyCommitmentSecrets
impl Readable for CounterpartyCommitmentSecrets
§fn read<R>(reader: &mut R) -> Result<CounterpartyCommitmentSecrets, DecodeError>where
R: Read,
fn read<R>(reader: &mut R) -> Result<CounterpartyCommitmentSecrets, DecodeError>where
R: Read,
Reads a
Self
in from the given Read
.§impl Writeable for CounterpartyCommitmentSecrets
impl Writeable for CounterpartyCommitmentSecrets
impl Eq for CounterpartyCommitmentSecrets
Auto Trait Implementations§
impl Freeze for CounterpartyCommitmentSecrets
impl RefUnwindSafe for CounterpartyCommitmentSecrets
impl Send for CounterpartyCommitmentSecrets
impl Sync for CounterpartyCommitmentSecrets
impl Unpin for CounterpartyCommitmentSecrets
impl UnwindSafe for CounterpartyCommitmentSecrets
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request