Skip to content

Commit

Permalink
Assign value to local balance field
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirebella committed Aug 13, 2024
1 parent 3eba0e2 commit 44063dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
16 changes: 4 additions & 12 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1490,8 +1490,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
/// If we can't release a [`ChannelMonitorUpdate`] until some external action completes, we
/// store it here and only release it to the `ChannelManager` once it asks for it.
blocked_monitor_updates: Vec<PendingChannelMonitorUpdate>,

last_local_balance_msats: u64,
}

impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
Expand Down Expand Up @@ -1830,8 +1828,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
blocked_monitor_updates: Vec::new(),

is_manual_broadcast: false,

last_local_balance_msats: 0,
};

Ok(channel_context)
Expand Down Expand Up @@ -2060,12 +2056,10 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
blocked_monitor_updates: Vec::new(),
local_initiated_shutdown: None,
is_manual_broadcast: false,

last_local_balance_msats: 0,
})
}

pub(crate) fn get_last_local_balance_msats(&self) -> u64 {self.last_local_balance_msats}
pub(crate) fn get_value_to_self_msat(&self) -> u64 {self.value_to_self_msat}

/// Allowed in any state (including after shutdown)
pub fn get_update_time_counter(&self) -> u32 {
Expand Down Expand Up @@ -3537,7 +3531,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
counterparty_node_id: self.counterparty_node_id,
unbroadcasted_funding_tx,
channel_funding_txo: self.get_funding_txo(),
last_local_balance_msats: self.last_local_balance_msats,
last_local_balance_msats: self.value_to_self_msat,
}
}

Expand Down Expand Up @@ -6228,7 +6222,7 @@ impl<SP: Deref> Channel<SP> where
counterparty_node_id: self.context.counterparty_node_id,
unbroadcasted_funding_tx: self.context.unbroadcasted_funding(),
channel_funding_txo: self.context.get_funding_txo(),
last_local_balance_msats: self.context.last_local_balance_msats,
last_local_balance_msats: self.context.value_to_self_msat,
};
let tx = self.build_signed_closing_transaction(&mut closing_tx, &msg.signature, &sig);
self.context.channel_state = ChannelState::ShutdownComplete;
Expand Down Expand Up @@ -6264,7 +6258,7 @@ impl<SP: Deref> Channel<SP> where
counterparty_node_id: self.context.counterparty_node_id,
unbroadcasted_funding_tx: self.context.unbroadcasted_funding(),
channel_funding_txo: self.context.get_funding_txo(),
last_local_balance_msats: self.context.last_local_balance_msats,
last_local_balance_msats: self.context.value_to_self_msat,
};
self.context.channel_state = ChannelState::ShutdownComplete;
self.context.update_time_counter += 1;
Expand Down Expand Up @@ -9587,8 +9581,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch

blocked_monitor_updates: blocked_monitor_updates.unwrap(),
is_manual_broadcast: is_manual_broadcast.unwrap_or(false),

last_local_balance_msats: 0,
},
#[cfg(any(dual_funding, splicing))]
dual_funding_channel_context: None,
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11880,7 +11880,7 @@ where
counterparty_node_id: Some(channel.context.get_counterparty_node_id()),
channel_capacity_sats: Some(channel.context.get_value_satoshis()),
channel_funding_txo: channel.context.get_funding_txo(),
last_local_balance_msats: Some(channel.context.get_last_local_balance_msats()),
last_local_balance_msats: Some(channel.context.get_value_to_self_msat()),
}, None));
for (channel_htlc_source, payment_hash) in channel.inflight_htlc_sources() {
let mut found_htlc = false;
Expand Down Expand Up @@ -11937,7 +11937,7 @@ where
counterparty_node_id: Some(channel.context.get_counterparty_node_id()),
channel_capacity_sats: Some(channel.context.get_value_satoshis()),
channel_funding_txo: channel.context.get_funding_txo(),
last_local_balance_msats: Some(channel.context.get_last_local_balance_msats()),
last_local_balance_msats: Some(channel.context.get_value_to_self_msat()),
}, None));
} else {
log_error!(logger, "Missing ChannelMonitor for channel {} needed by ChannelManager.", &channel.context.channel_id());
Expand Down

0 comments on commit 44063dc

Please sign in to comment.