Skip to content

Commit 28d1a56

Browse files
committed
Expose required features APIs for init message
Add requires_* counterparts for every supports_* method on InitFeatures, completing the BOLT 9 feature flag coverage for FFI consumers.
1 parent 91c95f2 commit 28d1a56

1 file changed

Lines changed: 200 additions & 2 deletions

File tree

src/ffi/types.rs

Lines changed: 200 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,14 @@ impl InitFeatures {
18401840
self.inner.supports_static_remote_key()
18411841
}
18421842

1843+
/// Whether the peer requires `option_static_remotekey` (bit 12).
1844+
///
1845+
/// This ensures the non-broadcaster's output pays directly to their specified key,
1846+
/// simplifying recovery if a channel is force-closed.
1847+
pub fn requires_static_remote_key(&self) -> bool {
1848+
self.inner.requires_static_remote_key()
1849+
}
1850+
18431851
/// Whether the peer supports `option_anchors_zero_fee_htlc_tx`.
18441852
///
18451853
/// Anchor channels allow fee-bumping commitment transactions after broadcast,
@@ -1848,6 +1856,14 @@ impl InitFeatures {
18481856
self.inner.supports_anchors_zero_fee_htlc_tx()
18491857
}
18501858

1859+
/// Whether the peer requires `option_anchors_zero_fee_htlc_tx` (bit 22).
1860+
///
1861+
/// Anchor channels allow fee-bumping commitment transactions after broadcast,
1862+
/// improving on-chain fee management.
1863+
pub fn requires_anchors_zero_fee_htlc_tx(&self) -> bool {
1864+
self.inner.requires_anchors_zero_fee_htlc_tx()
1865+
}
1866+
18511867
/// Whether the peer supports `option_anchors_nonzero_fee_htlc_tx`.
18521868
///
18531869
/// The initial version of anchor outputs, which was later found to be
@@ -1856,13 +1872,29 @@ impl InitFeatures {
18561872
self.inner.supports_anchors_nonzero_fee_htlc_tx()
18571873
}
18581874

1875+
/// Whether the peer requires `option_anchors_nonzero_fee_htlc_tx` (bit 20).
1876+
///
1877+
/// The initial version of anchor outputs, which was later found to be
1878+
/// vulnerable and superseded by `option_anchors_zero_fee_htlc_tx`.
1879+
pub fn requires_anchors_nonzero_fee_htlc_tx(&self) -> bool {
1880+
self.inner.requires_anchors_nonzero_fee_htlc_tx()
1881+
}
1882+
18591883
/// Whether the peer supports `option_support_large_channel`.
18601884
///
18611885
/// When supported, channels larger than 2^24 satoshis (≈0.168 BTC) may be opened.
18621886
pub fn supports_wumbo(&self) -> bool {
18631887
self.inner.supports_wumbo()
18641888
}
18651889

1890+
/// Whether the peer requires `option_support_large_channel` (bit 18).
1891+
///
1892+
/// When required, the peer will only connect to nodes that support
1893+
/// channels larger than 2^24 satoshis (≈0.168 BTC).
1894+
pub fn requires_wumbo(&self) -> bool {
1895+
self.inner.requires_wumbo()
1896+
}
1897+
18661898
/// Whether the peer supports `option_route_blinding`.
18671899
///
18681900
/// Route blinding allows the recipient to hide their node identity and
@@ -1871,6 +1903,14 @@ impl InitFeatures {
18711903
self.inner.supports_route_blinding()
18721904
}
18731905

1906+
/// Whether the peer requires `option_route_blinding` (bit 24).
1907+
///
1908+
/// Route blinding allows the recipient to hide their node identity and
1909+
/// last-hop channel from the sender.
1910+
pub fn requires_route_blinding(&self) -> bool {
1911+
self.inner.requires_route_blinding()
1912+
}
1913+
18741914
/// Whether the peer supports `option_onion_messages`.
18751915
///
18761916
/// Onion messages enable communication over the Lightning Network without
@@ -1879,6 +1919,14 @@ impl InitFeatures {
18791919
self.inner.supports_onion_messages()
18801920
}
18811921

1922+
/// Whether the peer requires `option_onion_messages` (bit 38).
1923+
///
1924+
/// Onion messages enable communication over the Lightning Network without
1925+
/// requiring a payment, used by BOLT 12 offers and async payments.
1926+
pub fn requires_onion_messages(&self) -> bool {
1927+
self.inner.requires_onion_messages()
1928+
}
1929+
18821930
/// Whether the peer supports `option_scid_alias`.
18831931
///
18841932
/// When supported, the peer will only forward using short channel ID aliases,
@@ -1887,6 +1935,14 @@ impl InitFeatures {
18871935
self.inner.supports_scid_privacy()
18881936
}
18891937

1938+
/// Whether the peer requires `option_scid_alias` (bit 46).
1939+
///
1940+
/// When required, the peer will only forward using short channel ID aliases,
1941+
/// preventing the real channel UTXO from being revealed during routing.
1942+
pub fn requires_scid_privacy(&self) -> bool {
1943+
self.inner.requires_scid_privacy()
1944+
}
1945+
18901946
/// Whether the peer supports `option_zeroconf`.
18911947
///
18921948
/// Zero-conf channels can be used immediately without waiting for
@@ -1895,6 +1951,14 @@ impl InitFeatures {
18951951
self.inner.supports_zero_conf()
18961952
}
18971953

1954+
/// Whether the peer requires `option_zeroconf` (bit 50).
1955+
///
1956+
/// Zero-conf channels can be used immediately without waiting for
1957+
/// on-chain funding confirmations.
1958+
pub fn requires_zero_conf(&self) -> bool {
1959+
self.inner.requires_zero_conf()
1960+
}
1961+
18981962
/// Whether the peer supports `option_dual_fund`.
18991963
///
19001964
/// Dual-funded channels allow both parties to contribute funds
@@ -1903,6 +1967,14 @@ impl InitFeatures {
19031967
self.inner.supports_dual_fund()
19041968
}
19051969

1970+
/// Whether the peer requires `option_dual_fund` (bit 28).
1971+
///
1972+
/// Dual-funded channels allow both parties to contribute funds
1973+
/// to the channel opening transaction.
1974+
pub fn requires_dual_fund(&self) -> bool {
1975+
self.inner.requires_dual_fund()
1976+
}
1977+
19061978
/// Whether the peer supports `option_quiesce`.
19071979
///
19081980
/// Quiescence is a prerequisite for splicing, allowing both sides to
@@ -1911,6 +1983,14 @@ impl InitFeatures {
19111983
self.inner.supports_quiescence()
19121984
}
19131985

1986+
/// Whether the peer requires `option_quiesce` (bit 34).
1987+
///
1988+
/// Quiescence is a prerequisite for splicing, allowing both sides to
1989+
/// pause HTLC activity before modifying the funding transaction.
1990+
pub fn requires_quiescence(&self) -> bool {
1991+
self.inner.requires_quiescence()
1992+
}
1993+
19141994
/// Whether the peer supports `option_data_loss_protect`.
19151995
///
19161996
/// Allows a node that has fallen behind (e.g., restored from backup)
@@ -1919,6 +1999,14 @@ impl InitFeatures {
19191999
self.inner.supports_data_loss_protect()
19202000
}
19212001

2002+
/// Whether the peer requires `option_data_loss_protect` (bit 0).
2003+
///
2004+
/// Allows a node that has fallen behind (e.g., restored from backup)
2005+
/// to detect that it is out of date and close the channel safely.
2006+
pub fn requires_data_loss_protect(&self) -> bool {
2007+
self.inner.requires_data_loss_protect()
2008+
}
2009+
19222010
/// Whether the peer supports `option_upfront_shutdown_script`.
19232011
///
19242012
/// Commits to a shutdown scriptpubkey when opening a channel,
@@ -1927,6 +2015,14 @@ impl InitFeatures {
19272015
self.inner.supports_upfront_shutdown_script()
19282016
}
19292017

2018+
/// Whether the peer requires `option_upfront_shutdown_script` (bit 4).
2019+
///
2020+
/// Commits to a shutdown scriptpubkey when opening a channel,
2021+
/// preventing a compromised key from redirecting closing funds.
2022+
pub fn requires_upfront_shutdown_script(&self) -> bool {
2023+
self.inner.requires_upfront_shutdown_script()
2024+
}
2025+
19302026
/// Whether the peer supports `gossip_queries`.
19312027
///
19322028
/// Indicates the peer has useful gossip to share and supports
@@ -1935,14 +2031,30 @@ impl InitFeatures {
19352031
self.inner.supports_gossip_queries()
19362032
}
19372033

2034+
/// Whether the peer requires `gossip_queries` (bit 6).
2035+
///
2036+
/// Indicates the peer has useful gossip to share and supports
2037+
/// gossip query messages for synchronization.
2038+
pub fn requires_gossip_queries(&self) -> bool {
2039+
self.inner.requires_gossip_queries()
2040+
}
2041+
19382042
/// Whether the peer supports `var_onion_optin`.
19392043
///
1940-
/// Requires variable-length routing onion payloads, which is
1941-
/// assumed to be supported by all modern Lightning nodes.
2044+
/// Supports variable-length routing onion payloads, which is
2045+
/// assumed to be supported and required by all modern Lightning nodes.
19422046
pub fn supports_variable_length_onion(&self) -> bool {
19432047
self.inner.supports_variable_length_onion()
19442048
}
19452049

2050+
/// Whether the peer requires `var_onion_optin` (bit 8).
2051+
///
2052+
/// Requires variable-length routing onion payloads, which is
2053+
/// assumed to be supported and required by all modern Lightning nodes.
2054+
pub fn requires_variable_length_onion(&self) -> bool {
2055+
self.inner.requires_variable_length_onion()
2056+
}
2057+
19462058
/// Whether the peer supports `payment_secret`.
19472059
///
19482060
/// Payment secrets prevent forwarding nodes from probing
@@ -1951,6 +2063,14 @@ impl InitFeatures {
19512063
self.inner.supports_payment_secret()
19522064
}
19532065

2066+
/// Whether the peer requires `payment_secret` (bit 14).
2067+
///
2068+
/// Payment secrets prevent forwarding nodes from probing
2069+
/// payment recipients. Assumed to be supported by all modern nodes.
2070+
pub fn requires_payment_secret(&self) -> bool {
2071+
self.inner.requires_payment_secret()
2072+
}
2073+
19542074
/// Whether the peer supports `basic_mpp`.
19552075
///
19562076
/// Multi-part payments allow splitting a payment across multiple
@@ -1959,6 +2079,14 @@ impl InitFeatures {
19592079
self.inner.supports_basic_mpp()
19602080
}
19612081

2082+
/// Whether the peer requires `basic_mpp` (bit 16).
2083+
///
2084+
/// Multi-part payments allow splitting a payment across multiple
2085+
/// routes for improved reliability and liquidity utilization.
2086+
pub fn requires_basic_mpp(&self) -> bool {
2087+
self.inner.requires_basic_mpp()
2088+
}
2089+
19622090
/// Whether the peer supports `opt_shutdown_anysegwit`.
19632091
///
19642092
/// Allows future segwit versions in the shutdown script,
@@ -1967,13 +2095,28 @@ impl InitFeatures {
19672095
self.inner.supports_shutdown_anysegwit()
19682096
}
19692097

2098+
/// Whether the peer requires `opt_shutdown_anysegwit` (bit 26).
2099+
///
2100+
/// Allows future segwit versions in the shutdown script,
2101+
/// enabling closing to Taproot or later output types.
2102+
pub fn requires_shutdown_anysegwit(&self) -> bool {
2103+
self.inner.requires_shutdown_anysegwit()
2104+
}
2105+
19702106
/// Whether the peer supports `option_channel_type`.
19712107
///
19722108
/// Supports explicit channel type negotiation during channel opening.
19732109
pub fn supports_channel_type(&self) -> bool {
19742110
self.inner.supports_channel_type()
19752111
}
19762112

2113+
/// Whether the peer requires `option_channel_type` (bit 44).
2114+
///
2115+
/// Requires explicit channel type negotiation during channel opening.
2116+
pub fn requires_channel_type(&self) -> bool {
2117+
self.inner.requires_channel_type()
2118+
}
2119+
19772120
/// Whether the peer supports `option_trampoline`.
19782121
///
19792122
/// Trampoline routing allows lightweight nodes to delegate
@@ -1982,6 +2125,14 @@ impl InitFeatures {
19822125
self.inner.supports_trampoline_routing()
19832126
}
19842127

2128+
/// Whether the peer requires `option_trampoline` (bit 56).
2129+
///
2130+
/// Trampoline routing allows lightweight nodes to delegate
2131+
/// pathfinding to an intermediate trampoline node.
2132+
pub fn requires_trampoline_routing(&self) -> bool {
2133+
self.inner.requires_trampoline_routing()
2134+
}
2135+
19852136
/// Whether the peer supports `option_simple_close`.
19862137
///
19872138
/// Simplified closing negotiation reduces the number of
@@ -1990,6 +2141,14 @@ impl InitFeatures {
19902141
self.inner.supports_simple_close()
19912142
}
19922143

2144+
/// Whether the peer requires `option_simple_close` (bit 60).
2145+
///
2146+
/// Simplified closing negotiation reduces the number of
2147+
/// round trips needed for a cooperative channel close.
2148+
pub fn requires_simple_close(&self) -> bool {
2149+
self.inner.requires_simple_close()
2150+
}
2151+
19932152
/// Whether the peer supports `option_splice`.
19942153
///
19952154
/// Splicing allows replacing the funding transaction with a new one,
@@ -1998,6 +2157,14 @@ impl InitFeatures {
19982157
self.inner.supports_splicing()
19992158
}
20002159

2160+
/// Whether the peer requires `option_splice` (bit 62).
2161+
///
2162+
/// Splicing allows replacing the funding transaction with a new one,
2163+
/// enabling on-the-fly capacity changes without closing the channel.
2164+
pub fn requires_splicing(&self) -> bool {
2165+
self.inner.requires_splicing()
2166+
}
2167+
20012168
/// Whether the peer supports `option_provide_storage`.
20022169
///
20032170
/// Indicates the node offers to store encrypted backup data
@@ -2006,6 +2173,14 @@ impl InitFeatures {
20062173
self.inner.supports_provide_storage()
20072174
}
20082175

2176+
/// Whether the peer requires `option_provide_storage` (bit 42).
2177+
///
2178+
/// Indicates the node offers to store encrypted backup data
2179+
/// on behalf of its peers.
2180+
pub fn requires_provide_storage(&self) -> bool {
2181+
self.inner.requires_provide_storage()
2182+
}
2183+
20092184
/// Whether the peer set `initial_routing_sync`.
20102185
///
20112186
/// Indicates the sending node needs a complete routing information dump.
@@ -2022,6 +2197,14 @@ impl InitFeatures {
20222197
self.inner.supports_taproot()
20232198
}
20242199

2200+
/// Whether the peer requires `option_taproot` (bit 30).
2201+
///
2202+
/// Taproot channels use MuSig2-based multisig for funding outputs,
2203+
/// improving privacy and efficiency.
2204+
pub fn requires_taproot(&self) -> bool {
2205+
self.inner.requires_taproot()
2206+
}
2207+
20252208
/// Whether the peer supports `option_zero_fee_commitments`.
20262209
///
20272210
/// A channel type which always uses zero transaction fee on commitment
@@ -2030,12 +2213,27 @@ impl InitFeatures {
20302213
self.inner.supports_anchor_zero_fee_commitments()
20312214
}
20322215

2216+
/// Whether the peer requires `option_zero_fee_commitments` (bit 140, experimental).
2217+
///
2218+
/// A channel type which always uses zero transaction fee on commitment
2219+
/// transactions, combined with anchor outputs.
2220+
pub fn requires_anchor_zero_fee_commitments(&self) -> bool {
2221+
self.inner.requires_anchor_zero_fee_commitments()
2222+
}
2223+
20332224
/// Whether the peer supports HTLC hold.
20342225
///
20352226
/// Supports holding HTLCs and forwarding on receipt of an onion message.
20362227
pub fn supports_htlc_hold(&self) -> bool {
20372228
self.inner.supports_htlc_hold()
20382229
}
2230+
2231+
/// Whether the peer requires HTLC hold (bit 152, experimental).
2232+
///
2233+
/// Requires holding HTLCs and forwarding on receipt of an onion message.
2234+
pub fn requires_htlc_hold(&self) -> bool {
2235+
self.inner.requires_htlc_hold()
2236+
}
20392237
}
20402238

20412239
impl From<LdkInitFeatures> for InitFeatures {

0 commit comments

Comments
 (0)