Skip to content

Commit 44063dc

Browse files
committed
Assign value to local balance field
1 parent 3eba0e2 commit 44063dc

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

lightning/src/ln/channel.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,8 +1490,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
14901490
/// If we can't release a [`ChannelMonitorUpdate`] until some external action completes, we
14911491
/// store it here and only release it to the `ChannelManager` once it asks for it.
14921492
blocked_monitor_updates: Vec<PendingChannelMonitorUpdate>,
1493-
1494-
last_local_balance_msats: u64,
14951493
}
14961494

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

18321830
is_manual_broadcast: false,
1833-
1834-
last_local_balance_msats: 0,
18351831
};
18361832

18371833
Ok(channel_context)
@@ -2060,12 +2056,10 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
20602056
blocked_monitor_updates: Vec::new(),
20612057
local_initiated_shutdown: None,
20622058
is_manual_broadcast: false,
2063-
2064-
last_local_balance_msats: 0,
20652059
})
20662060
}
20672061

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

20702064
/// Allowed in any state (including after shutdown)
20712065
pub fn get_update_time_counter(&self) -> u32 {
@@ -3537,7 +3531,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
35373531
counterparty_node_id: self.counterparty_node_id,
35383532
unbroadcasted_funding_tx,
35393533
channel_funding_txo: self.get_funding_txo(),
3540-
last_local_balance_msats: self.last_local_balance_msats,
3534+
last_local_balance_msats: self.value_to_self_msat,
35413535
}
35423536
}
35433537

@@ -6228,7 +6222,7 @@ impl<SP: Deref> Channel<SP> where
62286222
counterparty_node_id: self.context.counterparty_node_id,
62296223
unbroadcasted_funding_tx: self.context.unbroadcasted_funding(),
62306224
channel_funding_txo: self.context.get_funding_txo(),
6231-
last_local_balance_msats: self.context.last_local_balance_msats,
6225+
last_local_balance_msats: self.context.value_to_self_msat,
62326226
};
62336227
let tx = self.build_signed_closing_transaction(&mut closing_tx, &msg.signature, &sig);
62346228
self.context.channel_state = ChannelState::ShutdownComplete;
@@ -6264,7 +6258,7 @@ impl<SP: Deref> Channel<SP> where
62646258
counterparty_node_id: self.context.counterparty_node_id,
62656259
unbroadcasted_funding_tx: self.context.unbroadcasted_funding(),
62666260
channel_funding_txo: self.context.get_funding_txo(),
6267-
last_local_balance_msats: self.context.last_local_balance_msats,
6261+
last_local_balance_msats: self.context.value_to_self_msat,
62686262
};
62696263
self.context.channel_state = ChannelState::ShutdownComplete;
62706264
self.context.update_time_counter += 1;
@@ -9587,8 +9581,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
95879581

95889582
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
95899583
is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
9590-
9591-
last_local_balance_msats: 0,
95929584
},
95939585
#[cfg(any(dual_funding, splicing))]
95949586
dual_funding_channel_context: None,

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11880,7 +11880,7 @@ where
1188011880
counterparty_node_id: Some(channel.context.get_counterparty_node_id()),
1188111881
channel_capacity_sats: Some(channel.context.get_value_satoshis()),
1188211882
channel_funding_txo: channel.context.get_funding_txo(),
11883-
last_local_balance_msats: Some(channel.context.get_last_local_balance_msats()),
11883+
last_local_balance_msats: Some(channel.context.get_value_to_self_msat()),
1188411884
}, None));
1188511885
for (channel_htlc_source, payment_hash) in channel.inflight_htlc_sources() {
1188611886
let mut found_htlc = false;
@@ -11937,7 +11937,7 @@ where
1193711937
counterparty_node_id: Some(channel.context.get_counterparty_node_id()),
1193811938
channel_capacity_sats: Some(channel.context.get_value_satoshis()),
1193911939
channel_funding_txo: channel.context.get_funding_txo(),
11940-
last_local_balance_msats: Some(channel.context.get_last_local_balance_msats()),
11940+
last_local_balance_msats: Some(channel.context.get_value_to_self_msat()),
1194111941
}, None));
1194211942
} else {
1194311943
log_error!(logger, "Missing ChannelMonitor for channel {} needed by ChannelManager.", &channel.context.channel_id());

0 commit comments

Comments
 (0)