Skip to content

Commit

Permalink
feat: add is_valid_for_network method on address type
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderbiscuit committed Jan 17, 2024
1 parent b305f8f commit 25a48e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bdk-ffi/src/bdk.udl
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ interface Address {

string to_qr_uri();

boolean is_valid_for_network(Network network);

string as_string();
};

Expand Down
9 changes: 9 additions & 0 deletions bdk-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,15 @@ impl Address {
self.inner.to_qr_uri()
}

pub fn is_valid_for_network(&self, network: Network) -> bool {
let address_str = self.inner.to_string();
if let Ok(unchecked_address) = address_str.parse::<BdkAddress<NetworkUnchecked>>() {
unchecked_address.is_valid_for_network(network.into())
} else {
false
}
}

fn as_string(&self) -> String {
self.inner.to_string()
}
Expand Down

0 comments on commit 25a48e0

Please sign in to comment.