Skip to content

Commit 6e7db5a

Browse files
committed
Add requires_* APIs for InitFeatures
Expose requires_* counterparts for all existing supports_* methods on InitFeatures. supports_zero_conf is commented-out pending an update following an upstream bug fix (lightningdevkit/rust-lightning#4517).
1 parent 578f97c commit 6e7db5a

1 file changed

Lines changed: 204 additions & 5 deletions

File tree

src/ffi/types.rs

Lines changed: 204 additions & 5 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,7 +1641,24 @@ impl InitFeatures {
15931641
self.inner.supports_scid_privacy()
15941642
}
15951643

1596-
/// Whether the peer requires `option_zeroconf` (bit 51).
1644+
/// Whether the peer requires `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+
1652+
/// Whether the peer supports `option_zeroconf` (bit 51).
1653+
///
1654+
/// Zero-conf channels can be used immediately without waiting for
1655+
/// on-chain funding confirmations.
1656+
// TODO: Uncomment once rust-lightning is bumped past PR #4517
1657+
// pub fn supports_zero_conf(&self) -> bool {
1658+
// self.inner.supports_zero_conf()
1659+
// }
1660+
1661+
/// Whether the peer requires `option_zeroconf` (bit 50).
15971662
///
15981663
/// Zero-conf channels can be used immediately without waiting for
15991664
/// on-chain funding confirmations.
@@ -1609,6 +1674,14 @@ impl InitFeatures {
16091674
self.inner.supports_dual_fund()
16101675
}
16111676

1677+
/// Whether the peer requires `option_dual_fund` (bit 28).
1678+
///
1679+
/// Dual-funded channels allow both parties to contribute funds
1680+
/// to the channel opening transaction.
1681+
pub fn requires_dual_fund(&self) -> bool {
1682+
self.inner.requires_dual_fund()
1683+
}
1684+
16121685
/// Whether the peer supports `option_quiesce` (bit 35).
16131686
///
16141687
/// Quiescence is a prerequisite for splicing, allowing both sides to
@@ -1617,6 +1690,14 @@ impl InitFeatures {
16171690
self.inner.supports_quiescence()
16181691
}
16191692

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

1709+
/// Whether the peer requires `option_data_loss_protect` (bit 0).
1710+
///
1711+
/// Allows a node that has fallen behind (e.g., restored from backup)
1712+
/// to detect that it is out of date and close the channel safely.
1713+
pub fn requires_data_loss_protect(&self) -> bool {
1714+
self.inner.requires_data_loss_protect()
1715+
}
1716+
16281717
/// Whether the peer supports `option_upfront_shutdown_script` (bit 5).
16291718
///
16301719
/// Commits to a shutdown scriptpubkey when opening a channel,
@@ -1633,22 +1722,46 @@ impl InitFeatures {
16331722
self.inner.supports_upfront_shutdown_script()
16341723
}
16351724

1725+
/// Whether the peer requires `option_upfront_shutdown_script` (bit 4).
1726+
///
1727+
/// Commits to a shutdown scriptpubkey when opening a channel,
1728+
/// preventing a compromised key from redirecting closing funds.
1729+
pub fn requires_upfront_shutdown_script(&self) -> bool {
1730+
self.inner.requires_upfront_shutdown_script()
1731+
}
1732+
16361733
/// Whether the peer supports `gossip_queries` (bit 7).
16371734
///
1638-
/// Enables more sophisticated gossip synchronization, allowing
1639-
/// nodes to request specific ranges of channel announcements.
1735+
/// Indicates the peer has useful gossip to share and supports
1736+
/// gossip query messages for synchronization.
16401737
pub fn supports_gossip_queries(&self) -> bool {
16411738
self.inner.supports_gossip_queries()
16421739
}
16431740

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

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

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

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

1805+
/// Whether the peer requires `opt_shutdown_anysegwit` (bit 26).
1806+
///
1807+
/// Allows future segwit versions in the shutdown script,
1808+
/// enabling closing to Taproot or later output types.
1809+
pub fn requires_shutdown_anysegwit(&self) -> bool {
1810+
self.inner.requires_shutdown_anysegwit()
1811+
}
1812+
16761813
/// Whether the peer supports `option_channel_type` (bit 45).
16771814
///
16781815
/// Supports explicit channel type negotiation during channel opening.
16791816
pub fn supports_channel_type(&self) -> bool {
16801817
self.inner.supports_channel_type()
16811818
}
16821819

1820+
/// Whether the peer requires `option_channel_type` (bit 44).
1821+
///
1822+
/// Requires explicit channel type negotiation during channel opening.
1823+
pub fn requires_channel_type(&self) -> bool {
1824+
self.inner.requires_channel_type()
1825+
}
1826+
16831827
/// Whether the peer supports `option_trampoline` (bit 57).
16841828
///
16851829
/// Trampoline routing allows lightweight nodes to delegate
@@ -1688,6 +1832,14 @@ impl InitFeatures {
16881832
self.inner.supports_trampoline_routing()
16891833
}
16901834

1835+
/// Whether the peer requires `option_trampoline` (bit 56).
1836+
///
1837+
/// Trampoline routing allows lightweight nodes to delegate
1838+
/// pathfinding to an intermediate trampoline node.
1839+
pub fn requires_trampoline_routing(&self) -> bool {
1840+
self.inner.requires_trampoline_routing()
1841+
}
1842+
16911843
/// Whether the peer supports `option_simple_close` (bit 61).
16921844
///
16931845
/// Simplified closing negotiation reduces the number of
@@ -1696,6 +1848,14 @@ impl InitFeatures {
16961848
self.inner.supports_simple_close()
16971849
}
16981850

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

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

1883+
/// Whether the peer requires `option_provide_storage` (bit 42).
1884+
///
1885+
/// Indicates the node offers to store encrypted backup data
1886+
/// on behalf of its peers.
1887+
pub fn requires_provide_storage(&self) -> bool {
1888+
self.inner.requires_provide_storage()
1889+
}
1890+
17151891
/// Whether the peer set `initial_routing_sync` (bit 3).
17161892
///
17171893
/// Indicates the sending node needs a complete routing information dump.
@@ -1728,6 +1904,14 @@ impl InitFeatures {
17281904
self.inner.supports_taproot()
17291905
}
17301906

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

1923+
/// Whether the peer requires `option_zero_fee_commitments` (bit 140, experimental).
1924+
///
1925+
/// A channel type which always uses zero transaction fee on commitment
1926+
/// transactions, combined with anchor outputs.
1927+
pub fn requires_anchor_zero_fee_commitments(&self) -> bool {
1928+
self.inner.requires_anchor_zero_fee_commitments()
1929+
}
1930+
17391931
/// Whether the peer supports HTLC hold (bit 153, experimental).
17401932
///
17411933
/// Supports holding HTLCs and forwarding on receipt of an onion message.
17421934
pub fn supports_htlc_hold(&self) -> bool {
17431935
self.inner.supports_htlc_hold()
17441936
}
1937+
1938+
/// Whether the peer requires HTLC hold (bit 152, experimental).
1939+
///
1940+
/// Requires holding HTLCs and forwarding on receipt of an onion message.
1941+
pub fn requires_htlc_hold(&self) -> bool {
1942+
self.inner.requires_htlc_hold()
1943+
}
17451944
}
17461945

17471946
impl From<LdkInitFeatures> for InitFeatures {

0 commit comments

Comments
 (0)