Skip to content

Commit 7c2b74c

Browse files
committed
wasm: descriptor: is_mainnet
1 parent 3713285 commit 7c2b74c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lwk_wasm/src/descriptor.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ impl WolletDescriptor {
6767
let desc = lwk_wollet::WolletDescriptor::from_str(&desc)?;
6868
Ok(desc.into())
6969
}
70+
71+
#[wasm_bindgen(js_name = isMainnet)]
72+
pub fn is_mainnet(&self) -> bool {
73+
self.inner.is_mainnet()
74+
}
7075
}
7176

7277
impl std::fmt::Display for WolletDescriptor {
@@ -93,5 +98,7 @@ mod tests {
9398
let second = "ct(slip77(0371e66dde8ab9f3cb19d2c20c8fa2d7bd1ddc73454e6b7ef15f0c5f624d4a86),elsh(wpkh([75ea4a43/49'/1776'/0']xpub6D3Y5EKNsmegjE7azkF2foAYFivHrV5u7tcnN2TXELxv1djNtabCHtp3jMvxqEhTU737mYSUqHD1sA5MdZXQ8DWJLNft1gwtpzXZDsRnrZd/1/*)))";
9499
let both = format!("{first}\n{second}");
95100
assert_eq!(desc, WolletDescriptor::new(&both).unwrap().to_string());
101+
102+
assert!(WolletDescriptor::new(desc).unwrap().is_mainnet());
96103
}
97104
}

0 commit comments

Comments
 (0)