Skip to content

Commit

Permalink
Minor function refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Oct 13, 2023
1 parent d5a2cf5 commit 5122eaa
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions typescript/src/lib/bitcoin/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,15 @@ function addressToPublicKeyHash(

try {
// Try extracting hash from P2PKH address.
const hash = payments.p2pkh({ address: address, network }).hash!
return Hex.from(hash)
return Hex.from(payments.p2pkh({ address: address, network }).hash!)
} catch (err) {}

try {
// Try extracting hash from P2WPKH address.
const hash = payments.p2wpkh({ address: address, network }).hash!
return Hex.from(hash)
return Hex.from(payments.p2wpkh({ address: address, network }).hash!)
} catch (err) {}

// If neither of them succeeded, throw an error.
throw new Error("Address must be P2PKH or P2WPKH valid for given network")
}

Expand Down

0 comments on commit 5122eaa

Please sign in to comment.