Skip to content

Commit d67aaa8

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 d67aaa8

1 file changed

Lines changed: 151 additions & 101 deletions

File tree

src/ffi/types.rs

Lines changed: 151 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,210 +1832,260 @@ impl InitFeatures {
18321832
self.inner.encode()
18331833
}
18341834

1835-
/// Whether the peer supports `option_static_remotekey`.
1836-
///
1837-
/// This ensures the non-broadcaster's output pays directly to their specified key,
1838-
/// simplifying recovery if a channel is force-closed.
1835+
/// Whether the peer's `init` message advertises support for `option_static_remotekey`.
18391836
pub fn supports_static_remote_key(&self) -> bool {
18401837
self.inner.supports_static_remote_key()
18411838
}
18421839

1843-
/// Whether the peer supports `option_anchors_zero_fee_htlc_tx`.
1844-
///
1845-
/// Anchor channels allow fee-bumping commitment transactions after broadcast,
1846-
/// improving on-chain fee management.
1840+
/// Whether the peer's `init` message requires `option_static_remotekey`.
1841+
pub fn requires_static_remote_key(&self) -> bool {
1842+
self.inner.requires_static_remote_key()
1843+
}
1844+
1845+
/// Whether the peer's `init` message advertises support for `option_anchors_zero_fee_htlc_tx`.
18471846
pub fn supports_anchors_zero_fee_htlc_tx(&self) -> bool {
18481847
self.inner.supports_anchors_zero_fee_htlc_tx()
18491848
}
18501849

1851-
/// Whether the peer supports `option_anchors_nonzero_fee_htlc_tx`.
1852-
///
1853-
/// The initial version of anchor outputs, which was later found to be
1854-
/// vulnerable and superseded by `option_anchors_zero_fee_htlc_tx`.
1850+
/// Whether the peer's `init` message requires `option_anchors_zero_fee_htlc_tx`.
1851+
pub fn requires_anchors_zero_fee_htlc_tx(&self) -> bool {
1852+
self.inner.requires_anchors_zero_fee_htlc_tx()
1853+
}
1854+
1855+
/// Whether the peer's `init` message advertises support for `option_anchors_nonzero_fee_htlc_tx`.
18551856
pub fn supports_anchors_nonzero_fee_htlc_tx(&self) -> bool {
18561857
self.inner.supports_anchors_nonzero_fee_htlc_tx()
18571858
}
18581859

1859-
/// Whether the peer supports `option_support_large_channel`.
1860-
///
1861-
/// When supported, channels larger than 2^24 satoshis (≈0.168 BTC) may be opened.
1860+
/// Whether the peer's `init` message requires `option_anchors_nonzero_fee_htlc_tx`.
1861+
pub fn requires_anchors_nonzero_fee_htlc_tx(&self) -> bool {
1862+
self.inner.requires_anchors_nonzero_fee_htlc_tx()
1863+
}
1864+
1865+
/// Whether the peer's `init` message advertises support for `option_support_large_channel`.
18621866
pub fn supports_wumbo(&self) -> bool {
18631867
self.inner.supports_wumbo()
18641868
}
18651869

1866-
/// Whether the peer supports `option_route_blinding`.
1867-
///
1868-
/// Route blinding allows the recipient to hide their node identity and
1869-
/// last-hop channel from the sender.
1870+
/// Whether the peer's `init` message requires `option_support_large_channel`.
1871+
pub fn requires_wumbo(&self) -> bool {
1872+
self.inner.requires_wumbo()
1873+
}
1874+
1875+
/// Whether the peer's `init` message advertises support for `option_route_blinding`.
18701876
pub fn supports_route_blinding(&self) -> bool {
18711877
self.inner.supports_route_blinding()
18721878
}
18731879

1874-
/// Whether the peer supports `option_onion_messages`.
1875-
///
1876-
/// Onion messages enable communication over the Lightning Network without
1877-
/// requiring a payment, used by BOLT 12 offers and async payments.
1880+
/// Whether the peer's `init` message requires `option_route_blinding`.
1881+
pub fn requires_route_blinding(&self) -> bool {
1882+
self.inner.requires_route_blinding()
1883+
}
1884+
1885+
/// Whether the peer's `init` message advertises support for `option_onion_messages`.
18781886
pub fn supports_onion_messages(&self) -> bool {
18791887
self.inner.supports_onion_messages()
18801888
}
18811889

1882-
/// Whether the peer supports `option_scid_alias`.
1883-
///
1884-
/// When supported, the peer will only forward using short channel ID aliases,
1885-
/// preventing the real channel UTXO from being revealed during routing.
1890+
/// Whether the peer's `init` message requires `option_onion_messages`.
1891+
pub fn requires_onion_messages(&self) -> bool {
1892+
self.inner.requires_onion_messages()
1893+
}
1894+
1895+
/// Whether the peer's `init` message advertises support for `option_scid_alias`.
18861896
pub fn supports_scid_privacy(&self) -> bool {
18871897
self.inner.supports_scid_privacy()
18881898
}
18891899

1890-
/// Whether the peer supports `option_zeroconf`.
1891-
///
1892-
/// Zero-conf channels can be used immediately without waiting for
1893-
/// on-chain funding confirmations.
1900+
/// Whether the peer's `init` message requires `option_scid_alias`.
1901+
pub fn requires_scid_privacy(&self) -> bool {
1902+
self.inner.requires_scid_privacy()
1903+
}
1904+
1905+
/// Whether the peer's `init` message advertises support for `option_zeroconf`.
18941906
pub fn supports_zero_conf(&self) -> bool {
18951907
self.inner.supports_zero_conf()
18961908
}
18971909

1898-
/// Whether the peer supports `option_dual_fund`.
1899-
///
1900-
/// Dual-funded channels allow both parties to contribute funds
1901-
/// to the channel opening transaction.
1910+
/// Whether the peer's `init` message requires `option_zeroconf`.
1911+
pub fn requires_zero_conf(&self) -> bool {
1912+
self.inner.requires_zero_conf()
1913+
}
1914+
1915+
/// Whether the peer's `init` message advertises support for `option_dual_fund`.
19021916
pub fn supports_dual_fund(&self) -> bool {
19031917
self.inner.supports_dual_fund()
19041918
}
19051919

1906-
/// Whether the peer supports `option_quiesce`.
1907-
///
1908-
/// Quiescence is a prerequisite for splicing, allowing both sides to
1909-
/// pause HTLC activity before modifying the funding transaction.
1920+
/// Whether the peer's `init` message requires `option_dual_fund`.
1921+
pub fn requires_dual_fund(&self) -> bool {
1922+
self.inner.requires_dual_fund()
1923+
}
1924+
1925+
/// Whether the peer's `init` message advertises support for `option_quiesce`.
19101926
pub fn supports_quiescence(&self) -> bool {
19111927
self.inner.supports_quiescence()
19121928
}
19131929

1914-
/// Whether the peer supports `option_data_loss_protect`.
1915-
///
1916-
/// Allows a node that has fallen behind (e.g., restored from backup)
1917-
/// to detect that it is out of date and close the channel safely.
1930+
/// Whether the peer's `init` message requires `option_quiesce`.
1931+
pub fn requires_quiescence(&self) -> bool {
1932+
self.inner.requires_quiescence()
1933+
}
1934+
1935+
/// Whether the peer's `init` message advertises support for `option_data_loss_protect`.
19181936
pub fn supports_data_loss_protect(&self) -> bool {
19191937
self.inner.supports_data_loss_protect()
19201938
}
19211939

1922-
/// Whether the peer supports `option_upfront_shutdown_script`.
1923-
///
1924-
/// Commits to a shutdown scriptpubkey when opening a channel,
1925-
/// preventing a compromised key from redirecting closing funds.
1940+
/// Whether the peer's `init` message requires `option_data_loss_protect`.
1941+
pub fn requires_data_loss_protect(&self) -> bool {
1942+
self.inner.requires_data_loss_protect()
1943+
}
1944+
1945+
/// Whether the peer's `init` message advertises support for `option_upfront_shutdown_script`.
19261946
pub fn supports_upfront_shutdown_script(&self) -> bool {
19271947
self.inner.supports_upfront_shutdown_script()
19281948
}
19291949

1930-
/// Whether the peer supports `gossip_queries`.
1931-
///
1932-
/// Indicates the peer has useful gossip to share and supports
1933-
/// gossip query messages for synchronization.
1950+
/// Whether the peer's `init` message requires `option_upfront_shutdown_script`.
1951+
pub fn requires_upfront_shutdown_script(&self) -> bool {
1952+
self.inner.requires_upfront_shutdown_script()
1953+
}
1954+
1955+
/// Whether the peer's `init` message advertises support for `gossip_queries`.
19341956
pub fn supports_gossip_queries(&self) -> bool {
19351957
self.inner.supports_gossip_queries()
19361958
}
19371959

1938-
/// Whether the peer supports `var_onion_optin`.
1939-
///
1940-
/// Requires variable-length routing onion payloads, which is
1941-
/// assumed to be supported by all modern Lightning nodes.
1960+
/// Whether the peer's `init` message requires `gossip_queries`.
1961+
pub fn requires_gossip_queries(&self) -> bool {
1962+
self.inner.requires_gossip_queries()
1963+
}
1964+
1965+
/// Whether the peer's `init` message advertises support for `var_onion_optin`.
19421966
pub fn supports_variable_length_onion(&self) -> bool {
19431967
self.inner.supports_variable_length_onion()
19441968
}
19451969

1946-
/// Whether the peer supports `payment_secret`.
1947-
///
1948-
/// Payment secrets prevent forwarding nodes from probing
1949-
/// payment recipients. Assumed to be supported by all modern nodes.
1970+
/// Whether the peer's `init` message requires `var_onion_optin`.
1971+
pub fn requires_variable_length_onion(&self) -> bool {
1972+
self.inner.requires_variable_length_onion()
1973+
}
1974+
1975+
/// Whether the peer's `init` message advertises support for `payment_secret`.
19501976
pub fn supports_payment_secret(&self) -> bool {
19511977
self.inner.supports_payment_secret()
19521978
}
19531979

1954-
/// Whether the peer supports `basic_mpp`.
1955-
///
1956-
/// Multi-part payments allow splitting a payment across multiple
1957-
/// routes for improved reliability and liquidity utilization.
1980+
/// Whether the peer's `init` message requires `payment_secret`.
1981+
pub fn requires_payment_secret(&self) -> bool {
1982+
self.inner.requires_payment_secret()
1983+
}
1984+
1985+
/// Whether the peer's `init` message advertises support for `basic_mpp`.
19581986
pub fn supports_basic_mpp(&self) -> bool {
19591987
self.inner.supports_basic_mpp()
19601988
}
19611989

1962-
/// Whether the peer supports `opt_shutdown_anysegwit`.
1963-
///
1964-
/// Allows future segwit versions in the shutdown script,
1965-
/// enabling closing to Taproot or later output types.
1990+
/// Whether the peer's `init` message requires `basic_mpp`.
1991+
pub fn requires_basic_mpp(&self) -> bool {
1992+
self.inner.requires_basic_mpp()
1993+
}
1994+
1995+
/// Whether the peer's `init` message advertises support for `opt_shutdown_anysegwit`.
19661996
pub fn supports_shutdown_anysegwit(&self) -> bool {
19671997
self.inner.supports_shutdown_anysegwit()
19681998
}
19691999

1970-
/// Whether the peer supports `option_channel_type`.
1971-
///
1972-
/// Supports explicit channel type negotiation during channel opening.
2000+
/// Whether the peer's `init` message requires `opt_shutdown_anysegwit`.
2001+
pub fn requires_shutdown_anysegwit(&self) -> bool {
2002+
self.inner.requires_shutdown_anysegwit()
2003+
}
2004+
2005+
/// Whether the peer's `init` message advertises support for `option_channel_type`.
19732006
pub fn supports_channel_type(&self) -> bool {
19742007
self.inner.supports_channel_type()
19752008
}
19762009

1977-
/// Whether the peer supports `option_trampoline`.
1978-
///
1979-
/// Trampoline routing allows lightweight nodes to delegate
1980-
/// pathfinding to an intermediate trampoline node.
2010+
/// Whether the peer's `init` message requires `option_channel_type`.
2011+
pub fn requires_channel_type(&self) -> bool {
2012+
self.inner.requires_channel_type()
2013+
}
2014+
2015+
/// Whether the peer's `init` message advertises support for `option_trampoline`.
19812016
pub fn supports_trampoline_routing(&self) -> bool {
19822017
self.inner.supports_trampoline_routing()
19832018
}
19842019

1985-
/// Whether the peer supports `option_simple_close`.
1986-
///
1987-
/// Simplified closing negotiation reduces the number of
1988-
/// round trips needed for a cooperative channel close.
2020+
/// Whether the peer's `init` message requires `option_trampoline`.
2021+
pub fn requires_trampoline_routing(&self) -> bool {
2022+
self.inner.requires_trampoline_routing()
2023+
}
2024+
2025+
/// Whether the peer's `init` message advertises support for `option_simple_close`.
19892026
pub fn supports_simple_close(&self) -> bool {
19902027
self.inner.supports_simple_close()
19912028
}
19922029

1993-
/// Whether the peer supports `option_splice`.
1994-
///
1995-
/// Splicing allows replacing the funding transaction with a new one,
1996-
/// enabling on-the-fly capacity changes without closing the channel.
2030+
/// Whether the peer's `init` message requires `option_simple_close`.
2031+
pub fn requires_simple_close(&self) -> bool {
2032+
self.inner.requires_simple_close()
2033+
}
2034+
2035+
/// Whether the peer's `init` message advertises support for `option_splice`.
19972036
pub fn supports_splicing(&self) -> bool {
19982037
self.inner.supports_splicing()
19992038
}
20002039

2001-
/// Whether the peer supports `option_provide_storage`.
2002-
///
2003-
/// Indicates the node offers to store encrypted backup data
2004-
/// on behalf of its peers.
2040+
/// Whether the peer's `init` message requires `option_splice`.
2041+
pub fn requires_splicing(&self) -> bool {
2042+
self.inner.requires_splicing()
2043+
}
2044+
2045+
/// Whether the peer's `init` message advertises support for `option_provide_storage`.
20052046
pub fn supports_provide_storage(&self) -> bool {
20062047
self.inner.supports_provide_storage()
20072048
}
20082049

2009-
/// Whether the peer set `initial_routing_sync`.
2010-
///
2011-
/// Indicates the sending node needs a complete routing information dump.
2012-
/// Per BOLT #9, this feature has no even (required) bit.
2050+
/// Whether the peer's `init` message requires `option_provide_storage`.
2051+
pub fn requires_provide_storage(&self) -> bool {
2052+
self.inner.requires_provide_storage()
2053+
}
2054+
2055+
/// Whether the peer's `init` message set `initial_routing_sync`.
20132056
pub fn initial_routing_sync(&self) -> bool {
20142057
self.inner.initial_routing_sync()
20152058
}
20162059

2017-
/// Whether the peer supports `option_taproot`.
2018-
///
2019-
/// Taproot channels use MuSig2-based multisig for funding outputs,
2020-
/// improving privacy and efficiency.
2060+
/// Whether the peer's `init` message advertises support for `option_taproot`.
20212061
pub fn supports_taproot(&self) -> bool {
20222062
self.inner.supports_taproot()
20232063
}
20242064

2025-
/// Whether the peer supports `option_zero_fee_commitments`.
2026-
///
2027-
/// A channel type which always uses zero transaction fee on commitment
2028-
/// transactions, combined with anchor outputs.
2065+
/// Whether the peer's `init` message requires `option_taproot`.
2066+
pub fn requires_taproot(&self) -> bool {
2067+
self.inner.requires_taproot()
2068+
}
2069+
2070+
/// Whether the peer's `init` message advertises support for `option_zero_fee_commitments`.
20292071
pub fn supports_anchor_zero_fee_commitments(&self) -> bool {
20302072
self.inner.supports_anchor_zero_fee_commitments()
20312073
}
20322074

2033-
/// Whether the peer supports HTLC hold.
2034-
///
2035-
/// Supports holding HTLCs and forwarding on receipt of an onion message.
2075+
/// Whether the peer's `init` message requires `option_zero_fee_commitments`.
2076+
pub fn requires_anchor_zero_fee_commitments(&self) -> bool {
2077+
self.inner.requires_anchor_zero_fee_commitments()
2078+
}
2079+
2080+
/// Whether the peer's `init` message advertises support for HTLC hold.
20362081
pub fn supports_htlc_hold(&self) -> bool {
20372082
self.inner.supports_htlc_hold()
20382083
}
2084+
2085+
/// Whether the peer's `init` message requires HTLC hold.
2086+
pub fn requires_htlc_hold(&self) -> bool {
2087+
self.inner.requires_htlc_hold()
2088+
}
20392089
}
20402090

20412091
impl From<LdkInitFeatures> for InitFeatures {

0 commit comments

Comments
 (0)