Skip to content

Commit 10b3030

Browse files
committed
f: expose channel type feature flags
Expose typed UniFFI accessors for option_scid_alias and option_zeroconf on ChannelTypeFeatures, matching the underlying LDK feature API. Add coverage for optional and required flag forms. Co-Authored-By: HAL 9000
1 parent 00826a1 commit 10b3030

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

src/ffi/types.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,6 +1879,26 @@ impl ChannelTypeFeatures {
18791879
self.inner.requires_taproot()
18801880
}
18811881

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+
18821902
/// Whether this channel type advertises support for `option_zero_fee_commitments`.
18831903
pub fn supports_anchor_zero_fee_commitments(&self) -> bool {
18841904
self.inner.supports_anchor_zero_fee_commitments()
@@ -2270,6 +2290,27 @@ mod tests {
22702290
(ldk_invoice, wrapped_invoice)
22712291
}
22722292

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+
22732314
#[test]
22742315
fn test_invoice_description_conversion() {
22752316
let hash = "09d08d4865e8af9266f6cc7c0ae23a1d6bf868207cf8f7c5979b9f6ed850dfb0".to_string();

0 commit comments

Comments
 (0)