Struct lightning_signer::node::NodeState
source · pub struct NodeState {
pub invoices: Map<PaymentHash, PaymentState>,
pub issued_invoices: Map<PaymentHash, PaymentState>,
pub payments: Map<PaymentHash, RoutedPayment>,
pub excess_amount: u64,
pub log_prefix: String,
pub velocity_control: VelocityControl,
pub fee_velocity_control: VelocityControl,
pub last_summary: String,
}
Expand description
Enforcement state for a node
Fields§
§invoices: Map<PaymentHash, PaymentState>
Added invoices for outgoing payments indexed by their payment hash
issued_invoices: Map<PaymentHash, PaymentState>
Issued invoices for incoming payments indexed by their payment hash
payments: Map<PaymentHash, RoutedPayment>
Payment states. There is one entry for each invoice. Entries also exist for HTLCs we route.
excess_amount: u64
Accumulator of excess payment amount in satoshi, for tracking certain payment corner cases. If this falls below zero, the attempted commit is failed.
log_prefix: String
Prefix for emitted logs lines
velocity_control: VelocityControl
Per node velocity control
fee_velocity_control: VelocityControl
Per node fee velocity control
last_summary: String
Last summary string
Implementations§
source§impl NodeState
impl NodeState
sourcepub fn new(
velocity_control: VelocityControl,
fee_velocity_control: VelocityControl
) -> Self
pub fn new( velocity_control: VelocityControl, fee_velocity_control: VelocityControl ) -> Self
Create a state
sourcepub fn restore(
invoices_v: Vec<(Vec<u8>, PaymentState)>,
issued_invoices_v: Vec<(Vec<u8>, PaymentState)>,
preimages: Vec<[u8; 32]>,
excess_amount: u64,
velocity_control: VelocityControl,
fee_velocity_control: VelocityControl
) -> Self
pub fn restore( invoices_v: Vec<(Vec<u8>, PaymentState)>, issued_invoices_v: Vec<(Vec<u8>, PaymentState)>, preimages: Vec<[u8; 32]>, excess_amount: u64, velocity_control: VelocityControl, fee_velocity_control: VelocityControl ) -> Self
Restore a state from persistence
sourcepub fn summary(&mut self) -> (String, bool)
pub fn summary(&mut self) -> (String, bool)
Return a summary for debugging and whether it changed since last call
sourcepub fn validate_payments(
&self,
channel_id: &ChannelId,
incoming_payment_summary: &Map<PaymentHash, u64>,
outgoing_payment_summary: &Map<PaymentHash, u64>,
balance_delta: &BalanceDelta,
validator: Arc<dyn Validator>
) -> Result<(), ValidationError>
pub fn validate_payments( &self, channel_id: &ChannelId, incoming_payment_summary: &Map<PaymentHash, u64>, outgoing_payment_summary: &Map<PaymentHash, u64>, balance_delta: &BalanceDelta, validator: Arc<dyn Validator> ) -> Result<(), ValidationError>
Validate outgoing in-flight payment amounts as a result of a new commitment tx.
The following policies are checked:
- no overpayment for any invoice.
- Sends without invoices (e.g. keysend) are only allowed if
policy.require_invoices
is false.
The amounts are in satoshi.
sourcepub fn apply_payments(
&mut self,
channel_id: &ChannelId,
incoming_payment_summary: &Map<PaymentHash, u64>,
outgoing_payment_summary: &Map<PaymentHash, u64>,
balance_delta: &BalanceDelta,
validator: Arc<dyn Validator>
)
pub fn apply_payments( &mut self, channel_id: &ChannelId, incoming_payment_summary: &Map<PaymentHash, u64>, outgoing_payment_summary: &Map<PaymentHash, u64>, balance_delta: &BalanceDelta, validator: Arc<dyn Validator> )
Apply outgoing in-flight payment amounts as a result of a new commitment tx. Must call NodeState::validate_payments first.
sourcepub fn htlc_fulfilled(
&mut self,
channel_id: &ChannelId,
preimage: PaymentPreimage,
validator: Arc<dyn Validator>
) -> bool
pub fn htlc_fulfilled( &mut self, channel_id: &ChannelId, preimage: PaymentPreimage, validator: Arc<dyn Validator> ) -> bool
Fulfills an HTLC. Performs bookkeeping on any invoice or routed payment with this payment hash.