Skip to content

Commit eb7f021

Browse files
committed
fixup! Expose per-channel features in ChannelDetails
We expose the complete set of InitFeatures query methods Add support/require query methods for all BOLT 9 features in the InitContext, including standard features, as well as taproot and the experimental anchor_zero_fee_commitments and htlc_hold features. Also rename supports_zero_conf to requires_zero_conf to match the underlying LDK method being called.
1 parent 9529650 commit eb7f021

File tree

1 file changed

+136
-2
lines changed

1 file changed

+136
-2
lines changed

src/ffi/types.rs

Lines changed: 136 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,14 @@ impl InitFeatures {
15521552
self.inner.supports_anchors_zero_fee_htlc_tx()
15531553
}
15541554

1555+
/// Whether the peer supports `option_anchors_nonzero_fee_htlc_tx` (bit 21).
1556+
///
1557+
/// The initial version of anchor outputs, which was later found to be
1558+
/// vulnerable and superseded by `option_anchors_zero_fee_htlc_tx`.
1559+
pub fn supports_anchors_nonzero_fee_htlc_tx(&self) -> bool {
1560+
self.inner.supports_anchors_nonzero_fee_htlc_tx()
1561+
}
1562+
15551563
/// Whether the peer supports `option_support_large_channel` (bit 19).
15561564
///
15571565
/// When supported, channels larger than 2^24 satoshis (≈0.168 BTC) may be opened.
@@ -1583,11 +1591,11 @@ impl InitFeatures {
15831591
self.inner.supports_scid_privacy()
15841592
}
15851593

1586-
/// Whether the peer supports `option_zeroconf` (bit 51).
1594+
/// Whether the peer requires `option_zeroconf` (bit 51).
15871595
///
15881596
/// Zero-conf channels can be used immediately without waiting for
15891597
/// on-chain funding confirmations.
1590-
pub fn supports_zero_conf(&self) -> bool {
1598+
pub fn requires_zero_conf(&self) -> bool {
15911599
self.inner.requires_zero_conf()
15921600
}
15931601

@@ -1606,6 +1614,132 @@ impl InitFeatures {
16061614
pub fn supports_quiescence(&self) -> bool {
16071615
self.inner.supports_quiescence()
16081616
}
1617+
1618+
/// Whether the peer supports `option_data_loss_protect` (bit 1).
1619+
///
1620+
/// Allows a node that has fallen behind (e.g., restored from backup)
1621+
/// to detect that it is out of date and close the channel safely.
1622+
pub fn supports_data_loss_protect(&self) -> bool {
1623+
self.inner.supports_data_loss_protect()
1624+
}
1625+
1626+
/// Whether the peer supports `option_upfront_shutdown_script` (bit 5).
1627+
///
1628+
/// Commits to a shutdown scriptpubkey when opening a channel,
1629+
/// preventing a compromised key from redirecting closing funds.
1630+
pub fn supports_upfront_shutdown_script(&self) -> bool {
1631+
self.inner.supports_upfront_shutdown_script()
1632+
}
1633+
1634+
/// Whether the peer supports `gossip_queries` (bit 7).
1635+
///
1636+
/// Enables more sophisticated gossip synchronization, allowing
1637+
/// nodes to request specific ranges of channel announcements.
1638+
pub fn supports_gossip_queries(&self) -> bool {
1639+
self.inner.supports_gossip_queries()
1640+
}
1641+
1642+
/// Whether the peer supports `var_onion_optin` (bit 9).
1643+
///
1644+
/// Requires variable-length routing onion payloads, which is
1645+
/// assumed to be supported by all modern Lightning nodes.
1646+
pub fn supports_variable_length_onion(&self) -> bool {
1647+
self.inner.supports_variable_length_onion()
1648+
}
1649+
1650+
/// Whether the peer supports `payment_secret` (bit 15).
1651+
///
1652+
/// Payment secrets prevent forwarding nodes from probing
1653+
/// payment recipients. Assumed to be supported by all modern nodes.
1654+
pub fn supports_payment_secret(&self) -> bool {
1655+
self.inner.supports_payment_secret()
1656+
}
1657+
1658+
/// Whether the peer supports `basic_mpp` (bit 17).
1659+
///
1660+
/// Multi-part payments allow splitting a payment across multiple
1661+
/// routes for improved reliability and liquidity utilization.
1662+
pub fn supports_basic_mpp(&self) -> bool {
1663+
self.inner.supports_basic_mpp()
1664+
}
1665+
1666+
/// Whether the peer supports `opt_shutdown_anysegwit` (bit 27).
1667+
///
1668+
/// Allows future segwit versions in the shutdown script,
1669+
/// enabling closing to Taproot or later output types.
1670+
pub fn supports_shutdown_anysegwit(&self) -> bool {
1671+
self.inner.supports_shutdown_anysegwit()
1672+
}
1673+
1674+
/// Whether the peer supports `option_channel_type` (bit 45).
1675+
///
1676+
/// Supports explicit channel type negotiation during channel opening.
1677+
pub fn supports_channel_type(&self) -> bool {
1678+
self.inner.supports_channel_type()
1679+
}
1680+
1681+
/// Whether the peer supports `option_trampoline` (bit 57).
1682+
///
1683+
/// Trampoline routing allows lightweight nodes to delegate
1684+
/// pathfinding to an intermediate trampoline node.
1685+
pub fn supports_trampoline_routing(&self) -> bool {
1686+
self.inner.supports_trampoline_routing()
1687+
}
1688+
1689+
/// Whether the peer supports `option_simple_close` (bit 61).
1690+
///
1691+
/// Simplified closing negotiation reduces the number of
1692+
/// round trips needed for a cooperative channel close.
1693+
pub fn supports_simple_close(&self) -> bool {
1694+
self.inner.supports_simple_close()
1695+
}
1696+
1697+
/// Whether the peer supports `option_splice` (bit 63).
1698+
///
1699+
/// Splicing allows replacing the funding transaction with a new one,
1700+
/// enabling on-the-fly capacity changes without closing the channel.
1701+
pub fn supports_splicing(&self) -> bool {
1702+
self.inner.supports_splicing()
1703+
}
1704+
1705+
/// Whether the peer supports `option_provide_storage` (bit 43).
1706+
///
1707+
/// Indicates the node offers to store encrypted backup data
1708+
/// on behalf of its peers.
1709+
pub fn supports_provide_storage(&self) -> bool {
1710+
self.inner.supports_provide_storage()
1711+
}
1712+
1713+
/// Whether the peer set `initial_routing_sync` (bit 3).
1714+
///
1715+
/// Indicates the sending node needs a complete routing information dump.
1716+
/// Per BOLT #9, this feature has no even (required) bit.
1717+
pub fn initial_routing_sync(&self) -> bool {
1718+
self.inner.initial_routing_sync()
1719+
}
1720+
1721+
/// Whether the peer supports `option_taproot` (bit 31).
1722+
///
1723+
/// Taproot channels use MuSig2-based multisig for funding outputs,
1724+
/// improving privacy and efficiency.
1725+
pub fn supports_taproot(&self) -> bool {
1726+
self.inner.supports_taproot()
1727+
}
1728+
1729+
/// Whether the peer supports `option_zero_fee_commitments` (bit 141, experimental).
1730+
///
1731+
/// A channel type which always uses zero transaction fee on commitment
1732+
/// transactions, combined with anchor outputs.
1733+
pub fn supports_anchor_zero_fee_commitments(&self) -> bool {
1734+
self.inner.supports_anchor_zero_fee_commitments()
1735+
}
1736+
1737+
/// Whether the peer supports HTLC hold (bit 153, experimental).
1738+
///
1739+
/// Supports holding HTLCs and forwarding on receipt of an onion message.
1740+
pub fn supports_htlc_hold(&self) -> bool {
1741+
self.inner.supports_htlc_hold()
1742+
}
16091743
}
16101744

16111745
impl From<LdkInitFeatures> for InitFeatures {

0 commit comments

Comments
 (0)