Skip to content

Commit b5736f1

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 3c2f05a commit b5736f1

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
@@ -1546,6 +1546,14 @@ impl InitFeatures {
15461546
self.inner.supports_static_remote_key()
15471547
}
15481548

1549+
/// Whether the peer requires `option_static_remotekey` (bit 12).
1550+
///
1551+
/// This ensures the non-broadcaster's output pays directly to their specified key,
1552+
/// simplifying recovery if a channel is force-closed.
1553+
pub fn requires_static_remote_key(&self) -> bool {
1554+
self.inner.requires_static_remote_key()
1555+
}
1556+
15491557
/// Whether the peer supports `option_anchors_zero_fee_htlc_tx` (bit 23).
15501558
///
15511559
/// Anchor channels allow fee-bumping commitment transactions after broadcast,
@@ -1554,6 +1562,14 @@ impl InitFeatures {
15541562
self.inner.supports_anchors_zero_fee_htlc_tx()
15551563
}
15561564

1565+
/// Whether the peer requires `option_anchors_zero_fee_htlc_tx` (bit 22).
1566+
///
1567+
/// Anchor channels allow fee-bumping commitment transactions after broadcast,
1568+
/// improving on-chain fee management.
1569+
pub fn requires_anchors_zero_fee_htlc_tx(&self) -> bool {
1570+
self.inner.requires_anchors_zero_fee_htlc_tx()
1571+
}
1572+
15571573
/// Whether the peer supports `option_anchors_nonzero_fee_htlc_tx` (bit 21).
15581574
///
15591575
/// The initial version of anchor outputs, which was later found to be
@@ -1562,13 +1578,29 @@ impl InitFeatures {
15621578
self.inner.supports_anchors_nonzero_fee_htlc_tx()
15631579
}
15641580

1581+
/// Whether the peer requires `option_anchors_nonzero_fee_htlc_tx` (bit 20).
1582+
///
1583+
/// The initial version of anchor outputs, which was later found to be
1584+
/// vulnerable and superseded by `option_anchors_zero_fee_htlc_tx`.
1585+
pub fn requires_anchors_nonzero_fee_htlc_tx(&self) -> bool {
1586+
self.inner.requires_anchors_nonzero_fee_htlc_tx()
1587+
}
1588+
15651589
/// Whether the peer supports `option_support_large_channel` (bit 19).
15661590
///
15671591
/// When supported, channels larger than 2^24 satoshis (≈0.168 BTC) may be opened.
15681592
pub fn supports_wumbo(&self) -> bool {
15691593
self.inner.supports_wumbo()
15701594
}
15711595

1596+
/// Whether the peer requires `option_support_large_channel` (bit 18).
1597+
///
1598+
/// When required, the peer will only connect to nodes that support
1599+
/// channels larger than 2^24 satoshis (≈0.168 BTC).
1600+
pub fn requires_wumbo(&self) -> bool {
1601+
self.inner.requires_wumbo()
1602+
}
1603+
15721604
/// Whether the peer supports `option_route_blinding` (bit 25).
15731605
///
15741606
/// Route blinding allows the recipient to hide their node identity and
@@ -1577,6 +1609,14 @@ impl InitFeatures {
15771609
self.inner.supports_route_blinding()
15781610
}
15791611

1612+
/// Whether the peer requires `option_route_blinding` (bit 24).
1613+
///
1614+
/// Route blinding allows the recipient to hide their node identity and
1615+
/// last-hop channel from the sender.
1616+
pub fn requires_route_blinding(&self) -> bool {
1617+
self.inner.requires_route_blinding()
1618+
}
1619+
15801620
/// Whether the peer supports `option_onion_messages` (bit 39).
15811621
///
15821622
/// Onion messages enable communication over the Lightning Network without
@@ -1585,6 +1625,14 @@ impl InitFeatures {
15851625
self.inner.supports_onion_messages()
15861626
}
15871627

1628+
/// Whether the peer requires `option_onion_messages` (bit 38).
1629+
///
1630+
/// Onion messages enable communication over the Lightning Network without
1631+
/// requiring a payment, used by BOLT 12 offers and async payments.
1632+
pub fn requires_onion_messages(&self) -> bool {
1633+
self.inner.requires_onion_messages()
1634+
}
1635+
15881636
/// Whether the peer supports `option_scid_alias` (bit 47).
15891637
///
15901638
/// When supported, the peer will only forward using short channel ID aliases,
@@ -1593,6 +1641,14 @@ impl InitFeatures {
15931641
self.inner.supports_scid_privacy()
15941642
}
15951643

1644+
/// Whether the peer supports `option_scid_alias` (bit 46).
1645+
///
1646+
/// When required, the peer will only forward using short channel ID aliases,
1647+
/// preventing the real channel UTXO from being revealed during routing.
1648+
pub fn requires_scid_privacy(&self) -> bool {
1649+
self.inner.requires_scid_privacy()
1650+
}
1651+
15961652
/// Whether the peer supports `option_zeroconf` (bit 51).
15971653
///
15981654
/// Zero-conf channels can be used immediately without waiting for
@@ -1601,6 +1657,14 @@ impl InitFeatures {
16011657
self.inner.supports_zero_conf()
16021658
}
16031659

1660+
/// Whether the peer requires `option_zeroconf` (bit 50).
1661+
///
1662+
/// Zero-conf channels can be used immediately without waiting for
1663+
/// on-chain funding confirmations.
1664+
pub fn requires_zero_conf(&self) -> bool {
1665+
self.inner.requires_zero_conf()
1666+
}
1667+
16041668
/// Whether the peer supports `option_dual_fund` (bit 29).
16051669
///
16061670
/// Dual-funded channels allow both parties to contribute funds
@@ -1609,6 +1673,14 @@ impl InitFeatures {
16091673
self.inner.supports_dual_fund()
16101674
}
16111675

1676+
/// Whether the peer requires `option_dual_fund` (bit 28).
1677+
///
1678+
/// Dual-funded channels allow both parties to contribute funds
1679+
/// to the channel opening transaction.
1680+
pub fn requires_dual_fund(&self) -> bool {
1681+
self.inner.requires_dual_fund()
1682+
}
1683+
16121684
/// Whether the peer supports `option_quiesce` (bit 35).
16131685
///
16141686
/// Quiescence is a prerequisite for splicing, allowing both sides to
@@ -1617,6 +1689,14 @@ impl InitFeatures {
16171689
self.inner.supports_quiescence()
16181690
}
16191691

1692+
/// Whether the peer requires `option_quiesce` (bit 34).
1693+
///
1694+
/// Quiescence is a prerequisite for splicing, allowing both sides to
1695+
/// pause HTLC activity before modifying the funding transaction.
1696+
pub fn requires_quiescence(&self) -> bool {
1697+
self.inner.requires_quiescence()
1698+
}
1699+
16201700
/// Whether the peer supports `option_data_loss_protect` (bit 1).
16211701
///
16221702
/// Allows a node that has fallen behind (e.g., restored from backup)
@@ -1625,6 +1705,14 @@ impl InitFeatures {
16251705
self.inner.supports_data_loss_protect()
16261706
}
16271707

1708+
/// Whether the peer requires `option_data_loss_protect` (bit 0).
1709+
///
1710+
/// Allows a node that has fallen behind (e.g., restored from backup)
1711+
/// to detect that it is out of date and close the channel safely.
1712+
pub fn requires_data_loss_protect(&self) -> bool {
1713+
self.inner.requires_data_loss_protect()
1714+
}
1715+
16281716
/// Whether the peer supports `option_upfront_shutdown_script` (bit 5).
16291717
///
16301718
/// Commits to a shutdown scriptpubkey when opening a channel,
@@ -1633,6 +1721,14 @@ impl InitFeatures {
16331721
self.inner.supports_upfront_shutdown_script()
16341722
}
16351723

1724+
/// Whether the peer requires `option_upfront_shutdown_script` (bit 4).
1725+
///
1726+
/// Commits to a shutdown scriptpubkey when opening a channel,
1727+
/// preventing a compromised key from redirecting closing funds.
1728+
pub fn requires_upfront_shutdown_script(&self) -> bool {
1729+
self.inner.requires_upfront_shutdown_script()
1730+
}
1731+
16361732
/// Whether the peer supports `gossip_queries` (bit 7).
16371733
///
16381734
/// Indicates the peer has useful gossip to share and supports
@@ -1641,14 +1737,30 @@ impl InitFeatures {
16411737
self.inner.supports_gossip_queries()
16421738
}
16431739

1740+
/// Whether the peer requires `gossip_queries` (bit 6).
1741+
///
1742+
/// Indicates the peer has useful gossip to share and supports
1743+
/// gossip query messages for synchronization.
1744+
pub fn requires_gossip_queries(&self) -> bool {
1745+
self.inner.requires_gossip_queries()
1746+
}
1747+
16441748
/// Whether the peer supports `var_onion_optin` (bit 9).
16451749
///
1646-
/// Requires variable-length routing onion payloads, which is
1647-
/// assumed to be supported by all modern Lightning nodes.
1750+
/// Supports variable-length routing onion payloads, which is
1751+
/// assumed to be supported and required by all modern Lightning nodes.
16481752
pub fn supports_variable_length_onion(&self) -> bool {
16491753
self.inner.supports_variable_length_onion()
16501754
}
16511755

1756+
/// Whether the peer requires `var_onion_optin` (bit 8).
1757+
///
1758+
/// Requires variable-length routing onion payloads, which is
1759+
/// assumed to be supported and required by all modern Lightning nodes.
1760+
pub fn requires_variable_length_onion(&self) -> bool {
1761+
self.inner.requires_variable_length_onion()
1762+
}
1763+
16521764
/// Whether the peer supports `payment_secret` (bit 15).
16531765
///
16541766
/// Payment secrets prevent forwarding nodes from probing
@@ -1657,6 +1769,14 @@ impl InitFeatures {
16571769
self.inner.supports_payment_secret()
16581770
}
16591771

1772+
/// Whether the peer requires `payment_secret` (bit 14).
1773+
///
1774+
/// Payment secrets prevent forwarding nodes from probing
1775+
/// payment recipients. Assumed to be supported by all modern nodes.
1776+
pub fn requires_payment_secret(&self) -> bool {
1777+
self.inner.requires_payment_secret()
1778+
}
1779+
16601780
/// Whether the peer supports `basic_mpp` (bit 17).
16611781
///
16621782
/// Multi-part payments allow splitting a payment across multiple
@@ -1665,6 +1785,14 @@ impl InitFeatures {
16651785
self.inner.supports_basic_mpp()
16661786
}
16671787

1788+
/// Whether the peer requires `basic_mpp` (bit 16).
1789+
///
1790+
/// Multi-part payments allow splitting a payment across multiple
1791+
/// routes for improved reliability and liquidity utilization.
1792+
pub fn requires_basic_mpp(&self) -> bool {
1793+
self.inner.requires_basic_mpp()
1794+
}
1795+
16681796
/// Whether the peer supports `opt_shutdown_anysegwit` (bit 27).
16691797
///
16701798
/// Allows future segwit versions in the shutdown script,
@@ -1673,13 +1801,28 @@ impl InitFeatures {
16731801
self.inner.supports_shutdown_anysegwit()
16741802
}
16751803

1804+
/// Whether the peer requires `opt_shutdown_anysegwit` (bit 26).
1805+
///
1806+
/// Allows future segwit versions in the shutdown script,
1807+
/// enabling closing to Taproot or later output types.
1808+
pub fn requires_shutdown_anysegwit(&self) -> bool {
1809+
self.inner.requires_shutdown_anysegwit()
1810+
}
1811+
16761812
/// Whether the peer supports `option_channel_type` (bit 45).
16771813
///
16781814
/// Supports explicit channel type negotiation during channel opening.
16791815
pub fn supports_channel_type(&self) -> bool {
16801816
self.inner.supports_channel_type()
16811817
}
16821818

1819+
/// Whether the peer requires `option_channel_type` (bit 44).
1820+
///
1821+
/// Requires explicit channel type negotiation during channel opening.
1822+
pub fn requires_channel_type(&self) -> bool {
1823+
self.inner.requires_channel_type()
1824+
}
1825+
16831826
/// Whether the peer supports `option_trampoline` (bit 57).
16841827
///
16851828
/// Trampoline routing allows lightweight nodes to delegate
@@ -1688,6 +1831,14 @@ impl InitFeatures {
16881831
self.inner.supports_trampoline_routing()
16891832
}
16901833

1834+
/// Whether the peer requires `option_trampoline` (bit 56).
1835+
///
1836+
/// Trampoline routing allows lightweight nodes to delegate
1837+
/// pathfinding to an intermediate trampoline node.
1838+
pub fn requires_trampoline_routing(&self) -> bool {
1839+
self.inner.requires_trampoline_routing()
1840+
}
1841+
16911842
/// Whether the peer supports `option_simple_close` (bit 61).
16921843
///
16931844
/// Simplified closing negotiation reduces the number of
@@ -1696,6 +1847,14 @@ impl InitFeatures {
16961847
self.inner.supports_simple_close()
16971848
}
16981849

1850+
/// Whether the peer requires `option_simple_close` (bit 60).
1851+
///
1852+
/// Simplified closing negotiation reduces the number of
1853+
/// round trips needed for a cooperative channel close.
1854+
pub fn requires_simple_close(&self) -> bool {
1855+
self.inner.requires_simple_close()
1856+
}
1857+
16991858
/// Whether the peer supports `option_splice` (bit 63).
17001859
///
17011860
/// Splicing allows replacing the funding transaction with a new one,
@@ -1704,6 +1863,14 @@ impl InitFeatures {
17041863
self.inner.supports_splicing()
17051864
}
17061865

1866+
/// Whether the peer requires `option_splice` (bit 62).
1867+
///
1868+
/// Splicing allows replacing the funding transaction with a new one,
1869+
/// enabling on-the-fly capacity changes without closing the channel.
1870+
pub fn requires_splicing(&self) -> bool {
1871+
self.inner.requires_splicing()
1872+
}
1873+
17071874
/// Whether the peer supports `option_provide_storage` (bit 43).
17081875
///
17091876
/// Indicates the node offers to store encrypted backup data
@@ -1712,6 +1879,14 @@ impl InitFeatures {
17121879
self.inner.supports_provide_storage()
17131880
}
17141881

1882+
/// Whether the peer requires `option_provide_storage` (bit 42).
1883+
///
1884+
/// Indicates the node offers to store encrypted backup data
1885+
/// on behalf of its peers.
1886+
pub fn requires_provide_storage(&self) -> bool {
1887+
self.inner.requires_provide_storage()
1888+
}
1889+
17151890
/// Whether the peer set `initial_routing_sync` (bit 3).
17161891
///
17171892
/// Indicates the sending node needs a complete routing information dump.
@@ -1728,6 +1903,14 @@ impl InitFeatures {
17281903
self.inner.supports_taproot()
17291904
}
17301905

1906+
/// Whether the peer requires `option_taproot` (bit 30).
1907+
///
1908+
/// Taproot channels use MuSig2-based multisig for funding outputs,
1909+
/// improving privacy and efficiency.
1910+
pub fn requires_taproot(&self) -> bool {
1911+
self.inner.requires_taproot()
1912+
}
1913+
17311914
/// Whether the peer supports `option_zero_fee_commitments` (bit 141, experimental).
17321915
///
17331916
/// A channel type which always uses zero transaction fee on commitment
@@ -1736,12 +1919,27 @@ impl InitFeatures {
17361919
self.inner.supports_anchor_zero_fee_commitments()
17371920
}
17381921

1922+
/// Whether the peer requires `option_zero_fee_commitments` (bit 140, experimental).
1923+
///
1924+
/// A channel type which always uses zero transaction fee on commitment
1925+
/// transactions, combined with anchor outputs.
1926+
pub fn requires_anchor_zero_fee_commitments(&self) -> bool {
1927+
self.inner.requires_anchor_zero_fee_commitments()
1928+
}
1929+
17391930
/// Whether the peer supports HTLC hold (bit 153, experimental).
17401931
///
17411932
/// Supports holding HTLCs and forwarding on receipt of an onion message.
17421933
pub fn supports_htlc_hold(&self) -> bool {
17431934
self.inner.supports_htlc_hold()
17441935
}
1936+
1937+
/// Whether the peer requires HTLC hold (bit 152, experimental).
1938+
///
1939+
/// Requires holding HTLCs and forwarding on receipt of an onion message.
1940+
pub fn requires_htlc_hold(&self) -> bool {
1941+
self.inner.requires_htlc_hold()
1942+
}
17451943
}
17461944

17471945
impl From<LdkInitFeatures> for InitFeatures {

0 commit comments

Comments
 (0)