Skip to content

Commit 578f97c

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 6ede18a commit 578f97c

1 file changed

Lines changed: 136 additions & 2 deletions

File tree

src/ffi/types.rs

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

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

1588-
/// Whether the peer supports `option_zeroconf` (bit 51).
1596+
/// Whether the peer requires `option_zeroconf` (bit 51).
15891597
///
15901598
/// Zero-conf channels can be used immediately without waiting for
15911599
/// on-chain funding confirmations.
1592-
pub fn supports_zero_conf(&self) -> bool {
1600+
pub fn requires_zero_conf(&self) -> bool {
15931601
self.inner.requires_zero_conf()
15941602
}
15951603

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

16131747
impl From<LdkInitFeatures> for InitFeatures {

0 commit comments

Comments
 (0)