Skip to content

Commit

Permalink
feat: add address from_script method
Browse files Browse the repository at this point in the history
  • Loading branch information
reez committed Jun 11, 2024
1 parent efef600 commit 84f1329
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bdk-ffi/src/bdk.udl
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,9 @@ interface Address {
[Throws=AddressError]
constructor(string address, Network network);

[Name=from_script, Throws=AddressError]
constructor(Script script, Network network);

Network network();

Script script_pubkey();
Expand Down
6 changes: 6 additions & 0 deletions bdk-ffi/src/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ impl Address {
Ok(Address(network_checked_address))
}

pub fn from_script(script: Arc<Script>, network: Network) -> Result<Self, AddressError> {
let address = BdkAddress::from_script(&script.0.clone(), network)?;

Ok(Address(address))
}

pub fn network(&self) -> Network {
*self.0.network()
}
Expand Down

0 comments on commit 84f1329

Please sign in to comment.