Skip to content

Commit 60567da

Browse files
committed
Note when we're allowed to unwrap channel parameters in docs
This further documents the parameter-fetching utilities in `InMemorySigner` to hopefully make them more robust against future spurious `unwrap`s.
1 parent 65569ed commit 60567da

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lightning/src/sign/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,7 @@ impl InMemorySigner {
894894
/// Returns the counterparty's pubkeys.
895895
///
896896
/// Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
897+
/// In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
897898
pub fn counterparty_pubkeys(&self) -> Option<&ChannelPublicKeys> {
898899
self.get_channel_parameters()
899900
.and_then(|params| params.counterparty_parameters.as_ref().map(|params| &params.pubkeys))
@@ -904,6 +905,7 @@ impl InMemorySigner {
904905
/// broadcast a transaction.
905906
///
906907
/// Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
908+
/// In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
907909
pub fn counterparty_selected_contest_delay(&self) -> Option<u16> {
908910
self.get_channel_parameters()
909911
.and_then(|params| params.counterparty_parameters.as_ref().map(|params| params.selected_contest_delay))
@@ -914,20 +916,23 @@ impl InMemorySigner {
914916
/// if they broadcast a transaction.
915917
///
916918
/// Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
919+
/// In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
917920
pub fn holder_selected_contest_delay(&self) -> Option<u16> {
918921
self.get_channel_parameters().map(|params| params.holder_selected_contest_delay)
919922
}
920923

921924
/// Returns whether the holder is the initiator.
922925
///
923926
/// Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
927+
/// In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
924928
pub fn is_outbound(&self) -> Option<bool> {
925929
self.get_channel_parameters().map(|params| params.is_outbound_from_holder)
926930
}
927931

928932
/// Funding outpoint
929933
///
930934
/// Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
935+
/// In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
931936
pub fn funding_outpoint(&self) -> Option<&OutPoint> {
932937
self.get_channel_parameters().map(|params| params.funding_outpoint.as_ref()).flatten()
933938
}
@@ -936,6 +941,7 @@ impl InMemorySigner {
936941
/// building transactions.
937942
///
938943
/// Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
944+
/// In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
939945
pub fn get_channel_parameters(&self) -> Option<&ChannelTransactionParameters> {
940946
self.channel_parameters.as_ref()
941947
}
@@ -944,6 +950,7 @@ impl InMemorySigner {
944950
/// determining a channel's category, i. e. legacy/anchors/taproot/etc.
945951
///
946952
/// Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
953+
/// In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
947954
pub fn channel_type_features(&self) -> Option<&ChannelTypeFeatures> {
948955
self.get_channel_parameters().map(|params| &params.channel_type_features)
949956
}

0 commit comments

Comments
 (0)