Skip to content

Commit 0132852

Browse files
Add from_script method on Address type
1 parent fba1dd3 commit 0132852

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

bdk-ffi/src/bdk.udl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ interface Address {
405405
[Throws=BdkError]
406406
constructor(string address);
407407

408+
[Name=from_script, Throws=BdkError]
409+
constructor(Script script, Network network);
410+
408411
Payload payload();
409412

410413
Network network();

bdk-ffi/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ impl Address {
269269
.map_err(|e| BdkError::Generic(e.to_string()))
270270
}
271271

272+
fn from_script(script: Arc<Script>, network: Network) -> Result<Self, BdkError> {
273+
BdkAddress::from_script(&script.script, network)
274+
.map(|a| Address { address: a })
275+
.map_err(|e| BdkError::Generic(e.to_string()))
276+
}
277+
272278
fn payload(&self) -> Payload {
273279
match &self.address.payload.clone() {
274280
BdkPayload::PubkeyHash(pubkey_hash) => Payload::PubkeyHash {

0 commit comments

Comments
 (0)