Struct lightning_signer::policy::validator::EnforcementState
source · pub struct EnforcementState {
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 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
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 get_current_holder_commitment_info(&self) -> CommitmentInfo2
pub fn get_current_holder_commitment_info(&self) -> CommitmentInfo2
Get the current commitment info
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
) -> ChannelBalance
pub fn balance<T: PreimageMap + Debug>( &self, preimage_map: &T, channel_setup: &ChannelSetup ) -> 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 more