Skip to content

Commit fe4597a

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 77dcbc4 commit fe4597a

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
@@ -1532,6 +1532,14 @@ impl InitFeatures {
15321532
self.inner.supports_anchors_zero_fee_htlc_tx()
15331533
}
15341534

1535+
/// Whether the peer supports `option_anchors_nonzero_fee_htlc_tx` (bit 21).
1536+
///
1537+
/// The initial version of anchor outputs, which was later found to be
1538+
/// vulnerable and superseded by `option_anchors_zero_fee_htlc_tx`.
1539+
pub fn supports_anchors_nonzero_fee_htlc_tx(&self) -> bool {
1540+
self.inner.supports_anchors_nonzero_fee_htlc_tx()
1541+
}
1542+
15351543
/// Whether the peer supports `option_support_large_channel` (bit 19).
15361544
///
15371545
/// When supported, channels larger than 2^24 satoshis (≈0.168 BTC) may be opened.
@@ -1563,11 +1571,11 @@ impl InitFeatures {
15631571
self.inner.supports_scid_privacy()
15641572
}
15651573

1566-
/// Whether the peer supports `option_zeroconf` (bit 51).
1574+
/// Whether the peer requires `option_zeroconf` (bit 51).
15671575
///
15681576
/// Zero-conf channels can be used immediately without waiting for
15691577
/// on-chain funding confirmations.
1570-
pub fn supports_zero_conf(&self) -> bool {
1578+
pub fn requires_zero_conf(&self) -> bool {
15711579
self.inner.requires_zero_conf()
15721580
}
15731581

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

15911725
impl From<LdkInitFeatures> for InitFeatures {

0 commit comments

Comments
 (0)