@@ -44,7 +44,10 @@ pub use lightning_liquidity::lsps0::ser::LSPSDateTime;
4444pub use lightning_liquidity:: lsps1:: msgs:: {
4545 LSPS1ChannelInfo , LSPS1OrderId , LSPS1OrderParams , LSPS1PaymentState ,
4646} ;
47- use lightning_types:: features:: { InitFeatures as LdkInitFeatures , NodeFeatures as LdkNodeFeatures } ;
47+ use lightning_types:: features:: {
48+ ChannelTypeFeatures as LdkChannelTypeFeatures , InitFeatures as LdkInitFeatures ,
49+ NodeFeatures as LdkNodeFeatures ,
50+ } ;
4851pub use lightning_types:: payment:: { PaymentHash , PaymentPreimage , PaymentSecret } ;
4952pub use lightning_types:: string:: UntrustedString ;
5053use vss_client:: headers:: {
@@ -1817,6 +1820,102 @@ impl From<LdkNodeFeatures> for NodeFeatures {
18171820 }
18181821}
18191822
1823+ #[ derive( Debug , Clone , PartialEq , Eq , uniffi:: Object ) ]
1824+ #[ uniffi:: export( Debug , Eq ) ]
1825+ pub struct ChannelTypeFeatures {
1826+ pub ( crate ) inner : LdkChannelTypeFeatures ,
1827+ }
1828+
1829+ #[ uniffi:: export]
1830+ impl ChannelTypeFeatures {
1831+ /// Constructs channel type features from big-endian BOLT 9 encoded bytes.
1832+ #[ uniffi:: constructor]
1833+ pub fn from_bytes ( bytes : & [ u8 ] ) -> Self {
1834+ Self { inner : LdkChannelTypeFeatures :: from_be_bytes ( bytes. to_vec ( ) ) }
1835+ }
1836+
1837+ /// Returns the BOLT 9 big-endian encoded representation of these features.
1838+ pub fn to_bytes ( & self ) -> Vec < u8 > {
1839+ self . inner . encode ( )
1840+ }
1841+
1842+ /// Whether this channel type advertises support for `option_static_remotekey`.
1843+ pub fn supports_static_remote_key ( & self ) -> bool {
1844+ self . inner . supports_static_remote_key ( )
1845+ }
1846+
1847+ /// Whether this channel type requires `option_static_remotekey`.
1848+ pub fn requires_static_remote_key ( & self ) -> bool {
1849+ self . inner . requires_static_remote_key ( )
1850+ }
1851+
1852+ /// Whether this channel type advertises support for `option_anchors_zero_fee_htlc_tx`.
1853+ pub fn supports_anchors_zero_fee_htlc_tx ( & self ) -> bool {
1854+ self . inner . supports_anchors_zero_fee_htlc_tx ( )
1855+ }
1856+
1857+ /// Whether this channel type requires `option_anchors_zero_fee_htlc_tx`.
1858+ pub fn requires_anchors_zero_fee_htlc_tx ( & self ) -> bool {
1859+ self . inner . requires_anchors_zero_fee_htlc_tx ( )
1860+ }
1861+
1862+ /// Whether this channel type advertises support for `option_anchors_nonzero_fee_htlc_tx`.
1863+ pub fn supports_anchors_nonzero_fee_htlc_tx ( & self ) -> bool {
1864+ self . inner . supports_anchors_nonzero_fee_htlc_tx ( )
1865+ }
1866+
1867+ /// Whether this channel type requires `option_anchors_nonzero_fee_htlc_tx`.
1868+ pub fn requires_anchors_nonzero_fee_htlc_tx ( & self ) -> bool {
1869+ self . inner . requires_anchors_nonzero_fee_htlc_tx ( )
1870+ }
1871+
1872+ /// Whether this channel type advertises support for `option_taproot`.
1873+ pub fn supports_taproot ( & self ) -> bool {
1874+ self . inner . supports_taproot ( )
1875+ }
1876+
1877+ /// Whether this channel type requires `option_taproot`.
1878+ pub fn requires_taproot ( & self ) -> bool {
1879+ self . inner . requires_taproot ( )
1880+ }
1881+
1882+ /// Whether this channel type advertises support for `option_scid_alias`.
1883+ pub fn supports_scid_privacy ( & self ) -> bool {
1884+ self . inner . supports_scid_privacy ( )
1885+ }
1886+
1887+ /// Whether this channel type requires `option_scid_alias`.
1888+ pub fn requires_scid_privacy ( & self ) -> bool {
1889+ self . inner . requires_scid_privacy ( )
1890+ }
1891+
1892+ /// Whether this channel type advertises support for `option_zeroconf`.
1893+ pub fn supports_zero_conf ( & self ) -> bool {
1894+ self . inner . supports_zero_conf ( )
1895+ }
1896+
1897+ /// Whether this channel type requires `option_zeroconf`.
1898+ pub fn requires_zero_conf ( & self ) -> bool {
1899+ self . inner . requires_zero_conf ( )
1900+ }
1901+
1902+ /// Whether this channel type advertises support for `option_zero_fee_commitments`.
1903+ pub fn supports_anchor_zero_fee_commitments ( & self ) -> bool {
1904+ self . inner . supports_anchor_zero_fee_commitments ( )
1905+ }
1906+
1907+ /// Whether this channel type requires `option_zero_fee_commitments`.
1908+ pub fn requires_anchor_zero_fee_commitments ( & self ) -> bool {
1909+ self . inner . requires_anchor_zero_fee_commitments ( )
1910+ }
1911+ }
1912+
1913+ impl From < LdkChannelTypeFeatures > for ChannelTypeFeatures {
1914+ fn from ( features : LdkChannelTypeFeatures ) -> Self {
1915+ Self { inner : features }
1916+ }
1917+ }
1918+
18201919#[ derive( Debug , Clone , PartialEq , Eq , uniffi:: Object ) ]
18211920#[ uniffi:: export( Debug , Eq ) ]
18221921pub struct InitFeatures {
@@ -2191,6 +2290,27 @@ mod tests {
21912290 ( ldk_invoice, wrapped_invoice)
21922291 }
21932292
2293+ #[ test]
2294+ fn test_channel_type_feature_accessors ( ) {
2295+ let mut optional = LdkChannelTypeFeatures :: empty ( ) ;
2296+ optional. set_scid_privacy_optional ( ) ;
2297+ optional. set_zero_conf_optional ( ) ;
2298+ let optional = ChannelTypeFeatures :: from ( optional) ;
2299+ assert ! ( optional. supports_scid_privacy( ) ) ;
2300+ assert ! ( !optional. requires_scid_privacy( ) ) ;
2301+ assert ! ( optional. supports_zero_conf( ) ) ;
2302+ assert ! ( !optional. requires_zero_conf( ) ) ;
2303+
2304+ let mut required = LdkChannelTypeFeatures :: empty ( ) ;
2305+ required. set_scid_privacy_required ( ) ;
2306+ required. set_zero_conf_required ( ) ;
2307+ let required = ChannelTypeFeatures :: from ( required) ;
2308+ assert ! ( required. supports_scid_privacy( ) ) ;
2309+ assert ! ( required. requires_scid_privacy( ) ) ;
2310+ assert ! ( required. supports_zero_conf( ) ) ;
2311+ assert ! ( required. requires_zero_conf( ) ) ;
2312+ }
2313+
21942314 #[ test]
21952315 fn test_invoice_description_conversion ( ) {
21962316 let hash = "09d08d4865e8af9266f6cc7c0ae23a1d6bf868207cf8f7c5979b9f6ed850dfb0" . to_string ( ) ;
0 commit comments