Skip to content

Commit

Permalink
Merge pull request #30 from bitcoinerlab/addr_isSegwit
Browse files Browse the repository at this point in the history
Provide isSegwit also when using addr() descriptors if possible. Bump to 2.0.4
  • Loading branch information
landabaso authored Nov 20, 2023
2 parents 4d6cd91 + 7157e20 commit 4938cc4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@bitcoinerlab/descriptors",
"description": "This library parses and creates Bitcoin Miniscript Descriptors and generates Partially Signed Bitcoin Transactions (PSBTs). It provides PSBT finalizers and signers for single-signature, BIP32 and Hardware Wallets.",
"homepage": "https://github.com/bitcoinerlab/descriptors",
"version": "2.0.3",
"version": "2.0.4",
"author": "Jose-Luis Landabaso",
"license": "MIT",
"repository": {
Expand Down
6 changes: 6 additions & 0 deletions src/descriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,18 +267,24 @@ export function DescriptorsFactory(ecc: TinySecp256k1Interface) {
}
try {
payment = p2pkh({ output, network });
isSegwit = false;
} catch (e) {}
try {
payment = p2sh({ output, network });
//undefined isSegwit. Cannot know from looking at the address. Could
//be sh(wpkh), sh(wsh) or a plain old sh(SCRIPT)
} catch (e) {}
try {
payment = p2wpkh({ output, network });
isSegwit = true;
} catch (e) {}
try {
payment = p2wsh({ output, network });
isSegwit = true;
} catch (e) {}
try {
payment = p2tr({ output, network });
isSegwit = true;
} catch (e) {}
if (!payment) {
throw new Error(`Error: invalid address ${matchedAddress}`);
Expand Down

0 comments on commit 4938cc4

Please sign in to comment.