pub struct EnforcementState {Show 13 fields
pub next_holder_commit_num: u64,
pub next_counterparty_commit_num: u64,
pub next_counterparty_revoke_num: u64,
pub current_counterparty_point: Option<PublicKey>,
pub previous_counterparty_point: Option<PublicKey>,
pub current_holder_commit_info: Option<CommitmentInfo2>,
pub current_counterparty_signatures: Option<CommitmentSignatures>,
pub next_holder_commit_info: Option<(CommitmentInfo2, CommitmentSignatures)>,
pub current_counterparty_commit_info: Option<CommitmentInfo2>,
pub previous_counterparty_commit_info: Option<CommitmentInfo2>,
pub channel_closed: bool,
pub initial_holder_value: u64,
pub counterparty_secrets: Option<CounterpartyCommitmentSecrets>,
}
Expand description
Enforcement state for a channel
This keeps track of commitments on both sides and whether the channel was closed.
Fields§
§next_holder_commit_num: u64
§next_counterparty_commit_num: u64
§next_counterparty_revoke_num: u64
§current_counterparty_point: Option<PublicKey>
§previous_counterparty_point: Option<PublicKey>
§current_holder_commit_info: Option<CommitmentInfo2>
§current_counterparty_signatures: Option<CommitmentSignatures>
Counterparty signatures on holder’s commitment
next_holder_commit_info: Option<(CommitmentInfo2, CommitmentSignatures)>
Next holder commitment
current_counterparty_commit_info: Option<CommitmentInfo2>
§previous_counterparty_commit_info: Option<CommitmentInfo2>
§channel_closed: bool
§initial_holder_value: u64
§counterparty_secrets: Option<CounterpartyCommitmentSecrets>
Counterparty revocation secrets. This is an Option for backwards compatibility with old databases.
Implementations§
Source§impl EnforcementState
impl EnforcementState
Sourcepub fn new(initial_holder_value: u64) -> EnforcementState
pub fn new(initial_holder_value: u64) -> EnforcementState
Create state for a new channel.
initial_holder_value
is in satoshi and represents the lowest value
that we expect the initial commitment to send to us.
Sourcepub fn minimum_to_holder_value(&self, epsilon_sat: u64) -> Option<u64>
pub fn minimum_to_holder_value(&self, epsilon_sat: u64) -> Option<u64>
Returns the minimum amount to_holder from both commitments or None if the amounts are not within epsilon_sat.
Sourcepub fn minimum_to_counterparty_value(&self, epsilon_sat: u64) -> Option<u64>
pub fn minimum_to_counterparty_value(&self, epsilon_sat: u64) -> Option<u64>
Returns the minimum amount to_counterparty from both commitments or None if the amounts are not within epsilon_sat.
Sourcepub fn set_next_holder_commit_num(
&mut self,
num: u64,
current_commitment_info: CommitmentInfo2,
counterparty_signatures: CommitmentSignatures,
)
pub fn set_next_holder_commit_num( &mut self, num: u64, current_commitment_info: CommitmentInfo2, counterparty_signatures: CommitmentSignatures, )
Set next holder commitment number Policy enforcement must be performed by the caller
Sourcepub fn set_next_counterparty_commit_num(
&mut self,
num: u64,
current_point: PublicKey,
current_commitment_info: CommitmentInfo2,
)
pub fn set_next_counterparty_commit_num( &mut self, num: u64, current_point: PublicKey, current_commitment_info: CommitmentInfo2, )
Set next counterparty commitment number
Sourcepub fn get_previous_counterparty_point(&self, num: u64) -> Option<PublicKey>
pub fn get_previous_counterparty_point(&self, num: u64) -> Option<PublicKey>
Previous counterparty commitment point, or None if unknown
Sourcepub fn get_previous_counterparty_commit_info(
&self,
num: u64,
) -> Option<CommitmentInfo2>
pub fn get_previous_counterparty_commit_info( &self, num: u64, ) -> Option<CommitmentInfo2>
Previous counterparty commitment info
Sourcepub fn set_next_counterparty_revoke_num(&mut self, num: u64)
pub fn set_next_counterparty_revoke_num(&mut self, num: u64)
Set next counterparty revoked commitment number
Sourcepub fn payments_summary(
&self,
new_holder_tx: Option<&CommitmentInfo2>,
new_counterparty_tx: Option<&CommitmentInfo2>,
) -> Map<PaymentHash, u64>
pub fn payments_summary( &self, new_holder_tx: Option<&CommitmentInfo2>, new_counterparty_tx: Option<&CommitmentInfo2>, ) -> Map<PaymentHash, u64>
Summarize in-flight outgoing payments, possibly with new holder offered or counterparty received commitment tx. The amounts are in satoshi. HTLCs belonging to a payment are summed for each of the holder and counterparty txs. The greater value is taken as the actual in-flight value.
Sourcepub fn incoming_payments_summary(
&self,
new_holder_tx: Option<&CommitmentInfo2>,
new_counterparty_tx: Option<&CommitmentInfo2>,
) -> Map<PaymentHash, u64>
pub fn incoming_payments_summary( &self, new_holder_tx: Option<&CommitmentInfo2>, new_counterparty_tx: Option<&CommitmentInfo2>, ) -> Map<PaymentHash, u64>
Summarize in-flight incoming payments, possibly with new holder offered or counterparty received commitment tx. The amounts are in satoshi. HTLCs belonging to a payment are summed for each of the holder and counterparty txs. The smaller value is taken as the actual in-flight value.
Sourcepub fn claimable_balances<T: PreimageMap>(
&self,
preimage_map: &T,
new_holder_tx: Option<&CommitmentInfo2>,
new_counterparty_tx: Option<&CommitmentInfo2>,
channel_setup: &ChannelSetup,
) -> BalanceDelta
pub fn claimable_balances<T: PreimageMap>( &self, preimage_map: &T, new_holder_tx: Option<&CommitmentInfo2>, new_counterparty_tx: Option<&CommitmentInfo2>, channel_setup: &ChannelSetup, ) -> BalanceDelta
The claimable balance before and after a new commitment tx
Sourcepub fn balance<T: PreimageMap + Debug>(
&self,
preimage_map: &T,
channel_setup: &ChannelSetup,
is_ready: bool,
) -> ChannelBalance
pub fn balance<T: PreimageMap + Debug>( &self, preimage_map: &T, channel_setup: &ChannelSetup, is_ready: bool, ) -> ChannelBalance
Return channel balances
Trait Implementations§
Source§impl Clone for EnforcementState
impl Clone for EnforcementState
Source§fn clone(&self) -> EnforcementState
fn clone(&self) -> EnforcementState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for EnforcementState
impl Debug for EnforcementState
Source§impl<'de> Deserialize<'de> for EnforcementState
impl<'de> Deserialize<'de> for EnforcementState
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>,
Auto Trait Implementations§
impl Freeze for EnforcementState
impl RefUnwindSafe for EnforcementState
impl Send for EnforcementState
impl Sync for EnforcementState
impl Unpin for EnforcementState
impl UnwindSafe for EnforcementState
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more