@bitcoinerlab/descriptors 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/descriptors.js +10 -14
  2. package/package.json +1 -1
@@ -848,13 +848,14 @@ function DescriptorsFactory(ecc) {
848
848
  signatures) {
849
849
  if (this.isSegwit() && !isSegwitTx)
850
850
  throw new Error(`a tx is segwit if at least one input is segwit`);
851
- const errorMsg = 'Input type not implemented. Currently supported: pkh(KEY), wpkh(KEY), tr(KEY), \
852
- sh(wpkh(KEY)), sh(wsh(MINISCRIPT)), sh(MINISCRIPT), wsh(MINISCRIPT), \
853
- addr(PKH_ADDRESS), addr(WPKH_ADDRESS), addr(SH_WPKH_ADDRESS), addr(SINGLE_KEY_ADDRESS).';
854
851
  //expand any miniscript-based descriptor. If not miniscript-based, then it's
855
852
  //an addr() descriptor. For those, we can only guess their type.
856
853
  const expansion = this.expand().expandedExpression;
857
854
  const { isPKH, isWPKH, isSH, isTR } = this.guessOutput();
855
+ const errorMsg = `Input type not implemented. Currently supported: pkh(KEY), wpkh(KEY), tr(KEY), \
856
+ sh(wpkh(KEY)), sh(wsh(MINISCRIPT)), sh(MINISCRIPT), wsh(MINISCRIPT), \
857
+ addr(PKH_ADDRESS), addr(WPKH_ADDRESS), addr(SH_WPKH_ADDRESS), addr(SINGLE_KEY_ADDRESS). \
858
+ expansion=${expansion}, isPKH=${isPKH}, isWPKH=${isWPKH}, isSH=${isSH}, isTR=${isTR}.`;
858
859
  if (!expansion && !isPKH && !isWPKH && !isSH && !isTR)
859
860
  throw new Error(errorMsg);
860
861
  const firstSignature = signatures && typeof signatures[0] === 'object'
@@ -967,32 +968,27 @@ addr(PKH_ADDRESS), addr(WPKH_ADDRESS), addr(SH_WPKH_ADDRESS), addr(SINGLE_KEY_AD
967
968
  * output in a tx.
968
969
  */
969
970
  outputWeight() {
970
- const errorMsg = 'Output type not implemented. Currently supported: pkh(KEY), wpkh(KEY), tr(ANYTHING), \
971
- sh(ANYTHING), wsh(ANYTHING), addr(PKH_ADDRESS), addr(WPKH_ADDRESS), \
972
- addr(SH_WPKH_ADDRESS), addr(TR_ADDRESS)';
973
971
  //expand any miniscript-based descriptor. If not miniscript-based, then it's
974
972
  //an addr() descriptor. For those, we can only guess their type.
975
- const expansion = this.expand().expandedExpression;
976
973
  const { isPKH, isWPKH, isSH, isWSH, isTR } = this.guessOutput();
977
- if (!expansion && !isPKH && !isWPKH && !isSH && !isTR)
978
- throw new Error(errorMsg);
979
- if (expansion ? expansion.startsWith('pkh(') : isPKH) {
974
+ const errorMsg = `Output type not implemented. Currently supported: pkh=${isPKH}, wpkh=${isWPKH}, tr=${isTR}, sh=${isSH} and wsh=${isWSH}.`;
975
+ if (isPKH) {
980
976
  // (p2pkh:26) + (amount:8)
981
977
  return 34 * 4;
982
978
  }
983
- else if (expansion ? expansion.startsWith('wpkh(') : isWPKH) {
979
+ else if (isWPKH) {
984
980
  // (p2wpkh:23) + (amount:8)
985
981
  return 31 * 4;
986
982
  }
987
- else if (expansion ? expansion.startsWith('sh(') : isSH) {
983
+ else if (isSH) {
988
984
  // (p2sh:24) + (amount:8)
989
985
  return 32 * 4;
990
986
  }
991
- else if (expansion ? expansion.startsWith('wsh(') : isWSH) {
987
+ else if (isWSH) {
992
988
  // (p2wsh:35) + (amount:8)
993
989
  return 43 * 4;
994
990
  }
995
- else if (expansion ? expansion.startsWith('tr(') : isTR) {
991
+ else if (isTR) {
996
992
  // (script_pubKey_length:1) + (p2t2(OP_1 OP_PUSH32 <schnorr_public_key>):34) + (amount:8)
997
993
  return 43 * 4;
998
994
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@bitcoinerlab/descriptors",
3
3
  "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.",
4
4
  "homepage": "https://github.com/bitcoinerlab/descriptors",
5
- "version": "2.3.0",
5
+ "version": "2.3.1",
6
6
  "author": "Jose-Luis Landabaso",
7
7
  "license": "MIT",
8
8
  "repository": {