@bitcoinerlab/descriptors 2.3.1 → 2.3.3

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.
@@ -111,6 +111,7 @@ const applyPR2137 = (psbt) => {
111
111
  results.push(true);
112
112
  }
113
113
  catch (err) {
114
+ void err;
114
115
  results.push(false);
115
116
  }
116
117
  }
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Network, Payment, Psbt } from 'bitcoinjs-lib';
3
4
  import type { PartialSig } from 'bip174/src/lib/interfaces';
4
5
  import { BIP32API } from 'bip32';
@@ -221,6 +221,7 @@ function DescriptorsFactory(ecc) {
221
221
  output = bitcoinjs_lib_1.address.toOutputScript(matchedAddress, network);
222
222
  }
223
223
  catch (e) {
224
+ void e;
224
225
  throw new Error(`Error: invalid address ${matchedAddress}`);
225
226
  }
226
227
  try {
@@ -228,32 +229,42 @@ function DescriptorsFactory(ecc) {
228
229
  isSegwit = false;
229
230
  isTaproot = false;
230
231
  }
231
- catch (e) { }
232
+ catch (e) {
233
+ void e;
234
+ }
232
235
  try {
233
236
  payment = p2sh({ output, network });
234
237
  // It assumes that an addr(SH_ADDRESS) is always a add(SH_WPKH) address
235
238
  isSegwit = true;
236
239
  isTaproot = false;
237
240
  }
238
- catch (e) { }
241
+ catch (e) {
242
+ void e;
243
+ }
239
244
  try {
240
245
  payment = p2wpkh({ output, network });
241
246
  isSegwit = true;
242
247
  isTaproot = false;
243
248
  }
244
- catch (e) { }
249
+ catch (e) {
250
+ void e;
251
+ }
245
252
  try {
246
253
  payment = p2wsh({ output, network });
247
254
  isSegwit = true;
248
255
  isTaproot = false;
249
256
  }
250
- catch (e) { }
257
+ catch (e) {
258
+ void e;
259
+ }
251
260
  try {
252
261
  payment = p2tr({ output, network });
253
262
  isSegwit = true;
254
263
  isTaproot = true;
255
264
  }
256
- catch (e) { }
265
+ catch (e) {
266
+ void e;
267
+ }
257
268
  if (!payment) {
258
269
  throw new Error(`Error: invalid address ${matchedAddress}`);
259
270
  }
@@ -489,7 +500,7 @@ function DescriptorsFactory(ecc) {
489
500
  return (0, miniscript_1.expandMiniscript)({
490
501
  miniscript,
491
502
  isSegwit,
492
- isTaproot: false,
503
+ isTaproot: false, //TODO:
493
504
  network,
494
505
  BIP32,
495
506
  ECPair
@@ -758,6 +769,7 @@ function DescriptorsFactory(ecc) {
758
769
  return true;
759
770
  }
760
771
  catch (err) {
772
+ void err;
761
773
  return false;
762
774
  }
763
775
  }
@@ -767,6 +779,7 @@ function DescriptorsFactory(ecc) {
767
779
  return true;
768
780
  }
769
781
  catch (err) {
782
+ void err;
770
783
  return false;
771
784
  }
772
785
  }
@@ -776,6 +789,7 @@ function DescriptorsFactory(ecc) {
776
789
  return true;
777
790
  }
778
791
  catch (err) {
792
+ void err;
779
793
  return false;
780
794
  }
781
795
  }
@@ -785,6 +799,7 @@ function DescriptorsFactory(ecc) {
785
799
  return true;
786
800
  }
787
801
  catch (err) {
802
+ void err;
788
803
  return false;
789
804
  }
790
805
  }
@@ -794,6 +809,7 @@ function DescriptorsFactory(ecc) {
794
809
  return true;
795
810
  }
796
811
  catch (err) {
812
+ void err;
797
813
  return false;
798
814
  }
799
815
  }
package/dist/index.js CHANGED
@@ -26,6 +26,30 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
28
  exports.ledger = exports.scriptExpressions = exports.keyExpressionLedger = exports.keyExpressionBIP32 = exports.finalizePsbt = exports.signers = exports.checksum = exports.DescriptorsFactory = void 0;
29
+ // Some dependencies (like hash-base) assume process.version exists.
30
+ // In React Native / Hermes, process is defined but version is not.
31
+ // Note: we only polyfill if process already exists but is incomplete.
32
+ // The user is responsible for providing the process polyfill; this is just
33
+ // a small patch for environments (like Hermes) with partial implementations.
34
+ //
35
+ // More information: https://github.com/browserify/hash-base/issues/21#issuecomment-3476608003
36
+ const g = typeof globalThis !== 'undefined'
37
+ ? globalThis
38
+ : typeof global !== 'undefined'
39
+ ? global
40
+ : {};
41
+ if (typeof g.process !== 'undefined' &&
42
+ typeof g.process.version === 'undefined') {
43
+ const isDev = g['__DEV__'] === true ||
44
+ g.process?.env?.['NODE_ENV'] === 'development';
45
+ if (isDev) {
46
+ //only WARN while developing
47
+ console.warn(`[bitcoinerlab/descriptors] Polyfilled process.version (missing in this non-Node environment).
48
+ Learn more: https://github.com/bitcoinerlab/descriptors/blob/main/src/index.ts#L4`);
49
+ }
50
+ // @ts-expect-error Polyfill for environments missing process.version
51
+ global.process.version = '';
52
+ }
29
53
  var descriptors_1 = require("./descriptors");
30
54
  Object.defineProperty(exports, "DescriptorsFactory", { enumerable: true, get: function () { return descriptors_1.DescriptorsFactory; } });
31
55
  var checksum_1 = require("./checksum");
package/dist/ledger.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { DescriptorInstance, OutputInstance } from './descriptors';
3
4
  import { Network, Psbt } from 'bitcoinjs-lib';
4
5
  import type { TinySecp256k1Interface } from './types';
package/dist/ledger.js CHANGED
@@ -60,9 +60,11 @@ async function importAndValidateLedgerBitcoin(ledgerClient) {
60
60
  // to require 'ledger-bitcoin' unconditionally, leading to potential errors if
61
61
  // 'ledger-bitcoin' is not installed (given it's an optional peerDependency).
62
62
  // To bypass this, we directly use require:
63
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
63
64
  ledgerBitcoinModule = require('ledger-bitcoin');
64
65
  }
65
66
  catch (error) {
67
+ void error;
66
68
  throw new Error('Could not import "ledger-bitcoin". This is a peer dependency and needs to be installed explicitly. Please run "npm install ledger-bitcoin" to use Ledger Hardware Wallet functionality.');
67
69
  }
68
70
  const { AppClient } = ledgerBitcoinModule;
@@ -173,6 +175,7 @@ async function getLedgerXpub({ originPath, ledgerClient, ledgerState, ledgerMana
173
175
  xpub = await ledgerClient.getExtendedPubkey(`m${originPath}`, false);
174
176
  }
175
177
  catch (err) {
178
+ void err;
176
179
  xpub = await ledgerClient.getExtendedPubkey(`m${originPath}`, true);
177
180
  }
178
181
  if (typeof xpub !== 'string')
@@ -438,7 +441,7 @@ async function registerLedgerWallet({ descriptor, ledgerClient, ledgerState, led
438
441
  const { Output } = (0, descriptors_1.DescriptorsFactory)(ledgerManager.ecc);
439
442
  output = new Output({
440
443
  descriptor,
441
- ...(descriptor.includes('*') ? { index: 0 } : {}),
444
+ ...(descriptor.includes('*') ? { index: 0 } : {}), //if ranged set any index
442
445
  network: ledgerManager.network
443
446
  });
444
447
  }
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Network } from 'bitcoinjs-lib';
3
4
  import type { ECPairAPI } from 'ecpair';
4
5
  import type { BIP32API } from 'bip32';
package/dist/psbt.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import type { PsbtInput } from 'bip174/src/lib/interfaces';
3
4
  import type { KeyInfo } from './types';
4
5
  import { Network, Psbt } from 'bitcoinjs-lib';
package/dist/signers.js CHANGED
@@ -74,6 +74,7 @@ function signECPair({ psbt, ecpair }) {
74
74
  results.push(true);
75
75
  }
76
76
  catch (err) {
77
+ void err;
77
78
  results.push(false);
78
79
  }
79
80
  }
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import type { ECPairInterface } from 'ecpair';
3
4
  import type { BIP32Interface } from 'bip32';
4
5
  import type { Payment, Network } from 'bitcoinjs-lib';
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.1",
5
+ "version": "2.3.3",
6
6
  "author": "Jose-Luis Landabaso",
7
7
  "license": "MIT",
8
8
  "repository": {
@@ -34,7 +34,7 @@
34
34
  "build:fixtures": "node test/tools/generateBitcoinCoreFixtures.js -i test/fixtures/descriptor_tests.cpp | npx prettier --parser typescript > test/fixtures/bitcoinCore.ts",
35
35
  "build:test": "npm run build:fixtures && tsc --project ./node_modules/@bitcoinerlab/configs/tsconfig.test.json --resolveJsonModule",
36
36
  "build": "npm run build:src && npm run build:test",
37
- "lint": "eslint --ignore-path .gitignore --ext .ts src/ test/",
37
+ "lint": "if [ \"$ESLINT_USE_FLAT_CONFIG\" != false ]; then echo '\n⚠️ WARNING: ESLINT_USE_FLAT_CONFIG is not set to \"false\".\n Editors may show different results than the CLI linter.\n To fix permanently, add this to your ~/.bashrc or ~/.zshrc:\n\n export ESLINT_USE_FLAT_CONFIG=false\n'; fi; ESLINT_USE_FLAT_CONFIG=false eslint --ignore-path .gitignore --ext .ts src/ test/",
38
38
  "ensureTester": "./node_modules/@bitcoinerlab/configs/scripts/ensureTester.sh",
39
39
  "test:integration:soft": "npm run ensureTester && node test/integration/standardOutputs.js && echo \"\\n\\n\" && node test/integration/miniscript.js",
40
40
  "test:integration:ledger": "npm run ensureTester && node test/integration/ledger.js",
@@ -56,7 +56,6 @@
56
56
  }
57
57
  },
58
58
  "devDependencies": {
59
- "@bitcoinerlab/configs": "github:bitcoinerlab/configs",
60
59
  "@ledgerhq/hw-transport-node-hid": "^6.27.12",
61
60
  "@types/lodash.memoize": "^4.1.9",
62
61
  "bip39": "^3.0.4",
@@ -67,6 +66,7 @@
67
66
  "yargs": "^17.7.2"
68
67
  },
69
68
  "dependencies": {
69
+ "@bitcoinerlab/configs": "^1.3.0",
70
70
  "@bitcoinerlab/miniscript": "^1.4.0",
71
71
  "@bitcoinerlab/secp256k1": "^1.2.0",
72
72
  "bip32": "^4.0.0",