-
Notifications
You must be signed in to change notification settings - Fork 411
Funding signed event #3024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Funding signed event #3024
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1331,7 +1331,12 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider { | |
counterparty_forwarding_info: Option<CounterpartyForwardingInfo>, | ||
|
||
pub(crate) channel_transaction_parameters: ChannelTransactionParameters, | ||
/// The transaction which funds this channel. Note that for manually-funded channels (i.e., | ||
/// is_manual_broadcast is true) this will be a dummy empty transaction. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, one more issue here, the |
||
funding_transaction: Option<Transaction>, | ||
/// This flag indicates that it is the user's responsibility to validated and broadcast the | ||
/// funding transaction. | ||
is_manual_broadcast: bool, | ||
is_batch_funding: Option<()>, | ||
|
||
counterparty_cur_commitment_point: Option<PublicKey>, | ||
|
@@ -1419,6 +1424,9 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider { | |
// We track whether we already emitted a `ChannelPending` event. | ||
channel_pending_event_emitted: bool, | ||
|
||
// We track whether we already emitted a `FundingTxBroadcastSafe` event. | ||
funding_tx_broadcast_safe_event_emitted: bool, | ||
|
||
// We track whether we already emitted a `ChannelReady` event. | ||
channel_ready_event_emitted: bool, | ||
|
||
|
@@ -1758,6 +1766,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider { | |
outbound_scid_alias: 0, | ||
|
||
channel_pending_event_emitted: false, | ||
funding_tx_broadcast_safe_event_emitted: false, | ||
channel_ready_event_emitted: false, | ||
|
||
#[cfg(any(test, fuzzing))] | ||
|
@@ -1769,6 +1778,8 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider { | |
local_initiated_shutdown: None, | ||
|
||
blocked_monitor_updates: Vec::new(), | ||
|
||
is_manual_broadcast: false, | ||
}; | ||
|
||
Ok(channel_context) | ||
|
@@ -1982,6 +1993,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider { | |
outbound_scid_alias, | ||
|
||
channel_pending_event_emitted: false, | ||
funding_tx_broadcast_safe_event_emitted: false, | ||
channel_ready_event_emitted: false, | ||
|
||
#[cfg(any(test, fuzzing))] | ||
|
@@ -1992,6 +2004,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider { | |
|
||
blocked_monitor_updates: Vec::new(), | ||
local_initiated_shutdown: None, | ||
is_manual_broadcast: false, | ||
}) | ||
} | ||
|
||
|
@@ -2370,6 +2383,10 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider { | |
self.config.options.forwarding_fee_proportional_millionths | ||
} | ||
|
||
pub fn is_manual_broadcast(&self) -> bool { | ||
self.is_manual_broadcast | ||
} | ||
|
||
pub fn get_cltv_expiry_delta(&self) -> u16 { | ||
cmp::max(self.config.options.cltv_expiry_delta, MIN_CLTV_EXPIRY_DELTA) | ||
} | ||
|
@@ -2404,6 +2421,11 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider { | |
self.channel_pending_event_emitted | ||
} | ||
|
||
// Returns whether we already emitted a `FundingTxBroadcastSafe` event. | ||
pub(crate) fn funding_tx_broadcast_safe_event_emitted(&self) -> bool { | ||
self.funding_tx_broadcast_safe_event_emitted | ||
} | ||
|
||
// Remembers that we already emitted a `ChannelPending` event. | ||
pub(crate) fn set_channel_pending_event_emitted(&mut self) { | ||
self.channel_pending_event_emitted = true; | ||
|
@@ -2419,6 +2441,11 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider { | |
self.channel_ready_event_emitted = true; | ||
} | ||
|
||
// Remembers that we already emitted a `FundingTxBroadcastSafe` event. | ||
pub(crate) fn set_funding_tx_broadcast_safe_event_emitted(&mut self) { | ||
self.funding_tx_broadcast_safe_event_emitted = true; | ||
} | ||
|
||
/// Tracks the number of ticks elapsed since the previous [`ChannelConfig`] was updated. Once | ||
/// [`EXPIRE_PREV_CONFIG_TICKS`] is reached, the previous config is considered expired and will | ||
/// no longer be considered when forwarding HTLCs. | ||
|
@@ -2455,6 +2482,17 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider { | |
did_channel_update | ||
} | ||
|
||
/// Marking the channel as manual broadcast is used in order to prevent LDK from automatically | ||
/// broadcasting the funding transaction. | ||
/// | ||
/// This is useful if you wish to get hold of the funding transaction before it is broadcasted | ||
/// via [`Event::FundingTxBroadcastSafe`] event. | ||
/// | ||
/// [`Event::FundingTxBroadcastSafe`]: crate::events::Event::FundingTxBroadcastSafe | ||
pub fn set_manual_broadcast(&mut self) { | ||
self.is_manual_broadcast = true; | ||
} | ||
|
||
/// Returns true if funding_signed was sent/received and the | ||
/// funding transaction has been broadcast if necessary. | ||
pub fn is_funding_broadcast(&self) -> bool { | ||
|
@@ -8706,6 +8744,7 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider { | |
|
||
let channel_pending_event_emitted = Some(self.context.channel_pending_event_emitted); | ||
let channel_ready_event_emitted = Some(self.context.channel_ready_event_emitted); | ||
let funding_tx_broadcast_safe_event_emitted = Some(self.context.funding_tx_broadcast_safe_event_emitted); | ||
|
||
// `user_id` used to be a single u64 value. In order to remain backwards compatible with | ||
// versions prior to 0.0.113, the u128 is serialized as two separate u64 values. Therefore, | ||
|
@@ -8718,6 +8757,7 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider { | |
if !self.context.monitor_pending_update_adds.is_empty() { | ||
monitor_pending_update_adds = Some(&self.context.monitor_pending_update_adds); | ||
} | ||
let is_manual_broadcast = Some(self.context.is_manual_broadcast); | ||
|
||
// `current_point` will become optional when async signing is implemented. | ||
let cur_holder_commitment_point = Some(self.context.holder_commitment_point.current_point()); | ||
|
@@ -8762,6 +8802,8 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider { | |
(45, cur_holder_commitment_point, option), | ||
(47, next_holder_commitment_point, option), | ||
(49, self.context.local_initiated_shutdown, option), // Added in 0.0.122 | ||
(51, is_manual_broadcast, option), // Added in 0.0.124 | ||
(53, funding_tx_broadcast_safe_event_emitted, option) // Added in 0.0.124 | ||
}); | ||
|
||
Ok(()) | ||
|
@@ -9050,6 +9092,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch | |
let mut outbound_scid_alias = None; | ||
let mut channel_pending_event_emitted = None; | ||
let mut channel_ready_event_emitted = None; | ||
let mut funding_tx_broadcast_safe_event_emitted = None; | ||
|
||
let mut user_id_high_opt: Option<u64> = None; | ||
let mut channel_keys_id: Option<[u8; 32]> = None; | ||
|
@@ -9073,6 +9116,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch | |
|
||
let mut cur_holder_commitment_point_opt: Option<PublicKey> = None; | ||
let mut next_holder_commitment_point_opt: Option<PublicKey> = None; | ||
let mut is_manual_broadcast = None; | ||
|
||
read_tlv_fields!(reader, { | ||
(0, announcement_sigs, option), | ||
|
@@ -9107,6 +9151,8 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch | |
(45, cur_holder_commitment_point_opt, option), | ||
(47, next_holder_commitment_point_opt, option), | ||
(49, local_initiated_shutdown, option), | ||
(51, is_manual_broadcast, option), | ||
tnull marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(53, funding_tx_broadcast_safe_event_emitted, option), | ||
}); | ||
|
||
let (channel_keys_id, holder_signer) = if let Some(channel_keys_id) = channel_keys_id { | ||
|
@@ -9347,6 +9393,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch | |
// Later in the ChannelManager deserialization phase we scan for channels and assign scid aliases if its missing | ||
outbound_scid_alias: outbound_scid_alias.unwrap_or(0), | ||
|
||
funding_tx_broadcast_safe_event_emitted: funding_tx_broadcast_safe_event_emitted.unwrap_or(false), | ||
channel_pending_event_emitted: channel_pending_event_emitted.unwrap_or(true), | ||
channel_ready_event_emitted: channel_ready_event_emitted.unwrap_or(true), | ||
|
||
|
@@ -9359,6 +9406,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch | |
local_initiated_shutdown, | ||
|
||
blocked_monitor_updates: blocked_monitor_updates.unwrap(), | ||
is_manual_broadcast: is_manual_broadcast.unwrap_or(false), | ||
}, | ||
#[cfg(any(dual_funding, splicing))] | ||
dual_funding_channel_context: None, | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.