@ledgerhq/hw-app-btc 9.0.1 → 9.1.0-next.0

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 (44) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +33 -111
  3. package/lib/Btc.d.ts +12 -11
  4. package/lib/Btc.d.ts.map +1 -1
  5. package/lib/Btc.js +47 -143
  6. package/lib/Btc.js.map +1 -1
  7. package/lib/BtcNew.d.ts +2 -4
  8. package/lib/BtcNew.d.ts.map +1 -1
  9. package/lib/BtcNew.js +54 -13
  10. package/lib/BtcNew.js.map +1 -1
  11. package/lib/BtcOld.d.ts +2 -37
  12. package/lib/BtcOld.d.ts.map +1 -1
  13. package/lib/BtcOld.js +3 -45
  14. package/lib/BtcOld.js.map +1 -1
  15. package/lib/getAppAndVersion.d.ts +1 -0
  16. package/lib/getAppAndVersion.d.ts.map +1 -1
  17. package/lib/getAppAndVersion.js +21 -1
  18. package/lib/getAppAndVersion.js.map +1 -1
  19. package/lib-es/Btc.d.ts +12 -11
  20. package/lib-es/Btc.d.ts.map +1 -1
  21. package/lib-es/Btc.js +47 -120
  22. package/lib-es/Btc.js.map +1 -1
  23. package/lib-es/BtcNew.d.ts +2 -4
  24. package/lib-es/BtcNew.d.ts.map +1 -1
  25. package/lib-es/BtcNew.js +54 -8
  26. package/lib-es/BtcNew.js.map +1 -1
  27. package/lib-es/BtcOld.d.ts +2 -37
  28. package/lib-es/BtcOld.d.ts.map +1 -1
  29. package/lib-es/BtcOld.js +3 -45
  30. package/lib-es/BtcOld.js.map +1 -1
  31. package/lib-es/getAppAndVersion.d.ts +1 -0
  32. package/lib-es/getAppAndVersion.d.ts.map +1 -1
  33. package/lib-es/getAppAndVersion.js +19 -0
  34. package/lib-es/getAppAndVersion.js.map +1 -1
  35. package/package.json +1 -1
  36. package/src/Btc.ts +54 -146
  37. package/src/BtcNew.ts +60 -15
  38. package/src/BtcOld.ts +4 -59
  39. package/src/getAppAndVersion.ts +12 -0
  40. package/tests/{Btc.test.ts → Btc.test.ts.disabled} +16 -132
  41. package/tests/newops/BtcNew.test.ts +0 -5
  42. package/tests/newops/integrationtools.ts +4 -4
  43. package/tests/parseTx.test.ts +1 -1
  44. package/tests/{trustedInputs.test.ts → trustedInputs.test.ts.disabled} +6 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ledgerhq/hw-app-btc
2
2
 
3
+ ## 9.1.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1959](https://github.com/LedgerHQ/ledger-live/pull/1959) [`2aa8cc9c33`](https://github.com/LedgerHQ/ledger-live/commit/2aa8cc9c339ce8c9677b24e70218cc45847d799b) Thanks [@hzheng-ledger](https://github.com/hzheng-ledger)! - Change hw-app-btc to remove any dependency to the legacy Bitcoin Nano app API. Update hw-app-btc API (refer to hw-app-btc/src/Btc.ts for new method signature)
8
+
3
9
  ## 9.0.1
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -35,10 +35,10 @@ For a smooth and quick integration:
35
35
  * [getWalletPublicKey](#getwalletpublickey)
36
36
  * [Parameters](#parameters-2)
37
37
  * [Examples](#examples-1)
38
- * [signMessageNew](#signmessagenew)
38
+ * [signMessage](#signmessage)
39
39
  * [Parameters](#parameters-3)
40
40
  * [Examples](#examples-2)
41
- * [createPaymentTransactionNew](#createpaymenttransactionnew)
41
+ * [createPaymentTransaction](#createpaymenttransaction)
42
42
  * [Parameters](#parameters-4)
43
43
  * [Examples](#examples-3)
44
44
  * [signP2SHTransaction](#signp2shtransaction)
@@ -50,14 +50,13 @@ For a smooth and quick integration:
50
50
  * [serializeTransactionOutputs](#serializetransactionoutputs)
51
51
  * [Parameters](#parameters-7)
52
52
  * [Examples](#examples-6)
53
- * [impl](#impl)
54
53
  * [BtcNew](#btcnew)
55
54
  * [Parameters](#parameters-8)
56
55
  * [getWalletXpub](#getwalletxpub-1)
57
56
  * [Parameters](#parameters-9)
58
57
  * [getWalletPublicKey](#getwalletpublickey-1)
59
58
  * [Parameters](#parameters-10)
60
- * [createPaymentTransactionNew](#createpaymenttransactionnew-1)
59
+ * [createPaymentTransaction](#createpaymenttransaction-1)
61
60
  * [Parameters](#parameters-11)
62
61
  * [BtcOld](#btcold)
63
62
  * [Parameters](#parameters-12)
@@ -65,53 +64,47 @@ For a smooth and quick integration:
65
64
  * [getWalletPublicKey](#getwalletpublickey-2)
66
65
  * [Parameters](#parameters-13)
67
66
  * [Examples](#examples-8)
68
- * [signMessageNew](#signmessagenew-1)
67
+ * [createPaymentTransaction](#createpaymenttransaction-2)
69
68
  * [Parameters](#parameters-14)
70
69
  * [Examples](#examples-9)
71
- * [createPaymentTransactionNew](#createpaymenttransactionnew-2)
72
- * [Parameters](#parameters-15)
73
- * [Examples](#examples-10)
74
- * [signP2SHTransaction](#signp2shtransaction-1)
75
- * [Parameters](#parameters-16)
76
- * [Examples](#examples-11)
77
70
  * [CreateTransactionArg](#createtransactionarg)
78
71
  * [Properties](#properties)
79
72
  * [AddressFormat](#addressformat)
80
73
  * [AccountType](#accounttype)
81
74
  * [spendingCondition](#spendingcondition)
82
- * [Parameters](#parameters-17)
75
+ * [Parameters](#parameters-15)
83
76
  * [setInput](#setinput)
84
- * [Parameters](#parameters-18)
77
+ * [Parameters](#parameters-16)
85
78
  * [setOwnOutput](#setownoutput)
86
- * [Parameters](#parameters-19)
79
+ * [Parameters](#parameters-17)
87
80
  * [getDescriptorTemplate](#getdescriptortemplate)
88
81
  * [SingleKeyAccount](#singlekeyaccount)
89
82
  * [getTaprootOutputKey](#gettaprootoutputkey)
90
- * [Parameters](#parameters-20)
83
+ * [Parameters](#parameters-18)
91
84
  * [AppClient](#appclient)
92
- * [Parameters](#parameters-21)
85
+ * [Parameters](#parameters-19)
93
86
  * [ClientCommandInterpreter](#clientcommandinterpreter)
94
- * [Parameters](#parameters-22)
87
+ * [Parameters](#parameters-20)
95
88
  * [MerkelizedPsbt](#merkelizedpsbt)
96
- * [Parameters](#parameters-23)
89
+ * [Parameters](#parameters-21)
97
90
  * [Merkle](#merkle)
98
- * [Parameters](#parameters-24)
91
+ * [Parameters](#parameters-22)
99
92
  * [MerkleMap](#merklemap)
100
- * [Parameters](#parameters-25)
93
+ * [Parameters](#parameters-23)
101
94
  * [WalletPolicy](#walletpolicy)
102
- * [Parameters](#parameters-26)
95
+ * [Parameters](#parameters-24)
103
96
  * [extract](#extract)
104
- * [Parameters](#parameters-27)
97
+ * [Parameters](#parameters-25)
105
98
  * [finalize](#finalize)
106
- * [Parameters](#parameters-28)
99
+ * [Parameters](#parameters-26)
107
100
  * [clearFinalizedInput](#clearfinalizedinput)
108
- * [Parameters](#parameters-29)
101
+ * [Parameters](#parameters-27)
109
102
  * [writePush](#writepush)
110
- * [Parameters](#parameters-30)
103
+ * [Parameters](#parameters-28)
111
104
  * [PsbtV2](#psbtv2)
112
105
  * [serializeTransactionOutputs](#serializetransactionoutputs-1)
113
- * [Parameters](#parameters-31)
114
- * [Examples](#examples-12)
106
+ * [Parameters](#parameters-29)
107
+ * [Examples](#examples-10)
115
108
  * [SignP2SHTransactionArg](#signp2shtransactionarg)
116
109
  * [Properties](#properties-1)
117
110
  * [TransactionInput](#transactioninput)
@@ -124,14 +117,17 @@ Bitcoin API.
124
117
 
125
118
  #### Parameters
126
119
 
127
- * `transport` **Transport**
128
- * `scrambleKey` (optional, default `"BTC"`)
120
+ * `$0` **{transport: Transport, scrambleKey: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, currency: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?}**
121
+
122
+ * `$0.transport`
123
+ * `$0.scrambleKey` (optional, default `"BTC"`)
124
+ * `$0.currency` (optional, default `"bitcoin"`)
129
125
 
130
126
  #### Examples
131
127
 
132
128
  ```javascript
133
129
  import Btc from "@ledgerhq/hw-app-btc";
134
- const btc = new Btc(transport)
130
+ const btc = new Btc({ transport, currency: "bitcoin" });
135
131
  ```
136
132
 
137
133
  #### getWalletXpub
@@ -170,7 +166,7 @@ btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinA
170
166
 
171
167
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{publicKey: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), bitcoinAddress: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), chainCode: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>**
172
168
 
173
- #### signMessageNew
169
+ #### signMessage
174
170
 
175
171
  You can sign a message according to the Bitcoin Signature format and retrieve v, r, s given the message and the BIP 32 path of the account to sign.
176
172
 
@@ -182,7 +178,7 @@ You can sign a message according to the Bitcoin Signature format and retrieve v,
182
178
  ##### Examples
183
179
 
184
180
  ```javascript
185
- btc.signMessageNew_async("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
181
+ btc.signMessage("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
186
182
  var v = result['v'] + 27 + 4;
187
183
  var signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');
188
184
  console.log("Signature : " + signature);
@@ -191,7 +187,7 @@ console.log("Signature : " + signature);
191
187
 
192
188
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{v: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), r: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), s: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>**
193
189
 
194
- #### createPaymentTransactionNew
190
+ #### createPaymentTransaction
195
191
 
196
192
  To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
197
193
 
@@ -293,31 +289,6 @@ const outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');
293
289
 
294
290
  Returns **[Buffer](https://nodejs.org/api/buffer.html)**
295
291
 
296
- ### impl
297
-
298
- Definition: A "normal path" is a prefix of a standard path where all
299
- the hardened steps of the standard path are included. For example, the
300
- paths m/44'/1'/17' and m/44'/1'/17'/1 are normal paths, but m/44'/1'
301
- is not. m/'199/1'/17'/0/1 is not a normal path either.
302
-
303
- There's a compatiblity issue between old and new app: When exporting
304
- the key of a non-normal path with verify=false, the new app would
305
- return an error, whereas the old app would return the key.
306
-
307
- See
308
- https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#get_extended_pubkey
309
-
310
- If format bech32m is used, we'll not use old, because it doesn't
311
- support it.
312
-
313
- When to use new (given the app supports it)
314
-
315
- * format is bech32m or
316
- * path is normal or
317
- * verify is true
318
-
319
- Otherwise use old.
320
-
321
292
  ### BtcNew
322
293
 
323
294
  This class implements the same interface as BtcOld (formerly
@@ -391,9 +362,9 @@ will be the empty string "", see this.getWalletAddress() for details.
391
362
 
392
363
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{publicKey: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), bitcoinAddress: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), chainCode: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>**
393
364
 
394
- #### createPaymentTransactionNew
365
+ #### createPaymentTransaction
395
366
 
396
- Build and sign a transaction. See Btc.createPaymentTransactionNew for
367
+ Build and sign a transaction. See Btc.createPaymentTransaction for
397
368
  details on how to use this method.
398
369
 
399
370
  This method will convert the legacy arguments, CreateTransactionArg, into
@@ -418,7 +389,7 @@ Bitcoin API.
418
389
 
419
390
  ```javascript
420
391
  import Btc from "@ledgerhq/hw-app-btc";
421
- const btc = new Btc(transport)
392
+ const btc = new Btc({ transport, currency: "zcash" });
422
393
  ```
423
394
 
424
395
  #### getWalletPublicKey
@@ -446,28 +417,7 @@ btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinA
446
417
 
447
418
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{publicKey: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), bitcoinAddress: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), chainCode: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>**
448
419
 
449
- #### signMessageNew
450
-
451
- You can sign a message according to the Bitcoin Signature format and retrieve v, r, s given the message and the BIP 32 path of the account to sign.
452
-
453
- ##### Parameters
454
-
455
- * `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
456
- * `messageHex` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
457
-
458
- ##### Examples
459
-
460
- ```javascript
461
- btc.signMessageNew_async("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
462
- var v = result['v'] + 27 + 4;
463
- var signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');
464
- console.log("Signature : " + signature);
465
- }).catch(function(ex) {console.log(ex);});
466
- ```
467
-
468
- Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{v: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), r: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), s: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>**
469
-
470
- #### createPaymentTransactionNew
420
+ #### createPaymentTransaction
471
421
 
472
422
  To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
473
423
 
@@ -505,34 +455,6 @@ outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d
505
455
 
506
456
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** the signed transaction ready to be broadcast
507
457
 
508
- #### signP2SHTransaction
509
-
510
- To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters
511
-
512
- ##### Parameters
513
-
514
- * `arg` **[SignP2SHTransactionArg](#signp2shtransactionarg)**
515
- * `inputs` is an array of \[ transaction, output_index, redeem script, optional sequence ] where* transaction is the previously computed transaction object for this UTXO
516
- * output_index is the output in the transaction used as input for this UTXO (counting from 0)
517
- * redeem script is the mandatory redeem script associated to the current P2SH input
518
- * sequence is the sequence number to use for this input (when using RBF), or non present
519
- * `associatedKeysets` is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
520
- * `outputScriptHex` is the hexadecimal serialized outputs of the transaction to sign
521
- * `lockTime` is the optional lockTime of the transaction to sign, or default (0)
522
- * `sigHashType` is the hash type of the transaction to sign, or default (all)
523
-
524
- ##### Examples
525
-
526
- ```javascript
527
- btc.signP2SHTransaction({
528
- inputs: [ [tx, 1, "52210289b4a3ad52a919abd2bdd6920d8a6879b1e788c38aa76f0440a6f32a9f1996d02103a3393b1439d1693b063482c04bd40142db97bdf139eedd1b51ffb7070a37eac321030b9a409a1e476b0d5d17b804fcdb81cf30f9b99c6f3ae1178206e08bc500639853ae"] ],
529
- associatedKeysets: ["0'/0/0"],
530
- outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
531
- }).then(result => ...);
532
- ```
533
-
534
- Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>>** the signed transaction ready to be broadcast
535
-
536
458
  ### CreateTransactionArg
537
459
 
538
460
  Type: {inputs: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<\[[Transaction](#transaction), [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)), ([number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))]>, associatedKeysets: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>, changePath: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, outputScriptHex: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), lockTime: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?, sigHashType: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?, segwit: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, initialTimestamp: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?, additionals: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>, expiryHeight: [Buffer](https://nodejs.org/api/buffer.html)?, useTrustedInputForSegwit: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, onDeviceStreaming: function (arg0: {progress: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), total: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), index: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)}): void?, onDeviceSignatureRequested: function (): void?, onDeviceSignatureGranted: function (): void?}
package/lib/Btc.d.ts CHANGED
@@ -12,11 +12,16 @@ export type { AddressFormat };
12
12
  *
13
13
  * @example
14
14
  * import Btc from "@ledgerhq/hw-app-btc";
15
- * const btc = new Btc(transport)
15
+ * const btc = new Btc({ transport, currency: "bitcoin" });
16
16
  */
17
17
  export default class Btc {
18
- transport: Transport;
19
- constructor(transport: Transport, scrambleKey?: string);
18
+ private _transport;
19
+ private _impl;
20
+ constructor({ transport, scrambleKey, currency, }: {
21
+ transport: Transport;
22
+ scrambleKey?: string;
23
+ currency?: string;
24
+ });
20
25
  /**
21
26
  * Get an XPUB with a ledger device
22
27
  * @param arg derivation parameter
@@ -61,13 +66,13 @@ export default class Btc {
61
66
  /**
62
67
  * You can sign a message according to the Bitcoin Signature format and retrieve v, r, s given the message and the BIP 32 path of the account to sign.
63
68
  * @example
64
- btc.signMessageNew_async("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
69
+ btc.signMessage("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
65
70
  var v = result['v'] + 27 + 4;
66
71
  var signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');
67
72
  console.log("Signature : " + signature);
68
73
  }).catch(function(ex) {console.log(ex);});
69
74
  */
70
- signMessageNew(path: string, messageHex: string): Promise<{
75
+ signMessage(path: string, messageHex: string): Promise<{
71
76
  v: number;
72
77
  r: string;
73
78
  s: string;
@@ -105,7 +110,7 @@ export default class Btc {
105
110
  outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
106
111
  }).then(res => ...);
107
112
  */
108
- createPaymentTransactionNew(arg: CreateTransactionArg): Promise<string>;
113
+ createPaymentTransaction(arg: CreateTransactionArg): Promise<string>;
109
114
  /**
110
115
  * To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters
111
116
  * @param inputs is an array of [ transaction, output_index, redeem script, optional sequence ] where
@@ -140,10 +145,6 @@ export default class Btc {
140
145
  serializeTransactionOutputs(t: Transaction): Buffer;
141
146
  getTrustedInput(indexLookup: number, transaction: Transaction, additionals?: Array<string>): Promise<string>;
142
147
  getTrustedInputBIP143(indexLookup: number, transaction: Transaction, additionals?: Array<string>): string;
143
- private _lazyImpl;
144
- private getCorrectImpl;
145
- private inferCorrectImpl;
146
- protected old(): BtcOld;
147
- protected new(): BtcNew;
148
+ changeImplIfNecessary(): Promise<BtcOld | BtcNew>;
148
149
  }
149
150
  //# sourceMappingURL=Btc.d.ts.map
package/lib/Btc.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Btc.d.ts","sourceRoot":"","sources":["../src/Btc.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AAEpD,OAAO,MAAyB,MAAM,UAAU,CAAC;AACjD,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAIhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,YAAY,EAAE,aAAa,EAAE,CAAC;AAC9B;;;;;;GAMG;AAEH,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,SAAS,EAAE,SAAS,CAAC;gBAET,SAAS,EAAE,SAAS,EAAE,WAAW,SAAQ;IAiBrD;;;;;;OAMG;IACH,aAAa,CAAC,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAI1E;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,kBAAkB,CAChB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,aAAa,CAAC;KACxB,GACA,OAAO,CAAC;QACT,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAiFF;;;;;;;;OAQG;IACH,cAAc,CACZ,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC;QACT,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,2BAA2B,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC;IAWvE;;;;;;;;;;;;;;;;;;OAkBG;IACH,mBAAmB,CAAC,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAInE;;;;OAIG;IACH,gBAAgB,CACd,cAAc,EAAE,MAAM,EACtB,iBAAiB,GAAE,OAAO,GAAG,IAAI,GAAG,SAAiB,EACrD,YAAY,UAAQ,EACpB,YAAY,UAAQ,EACpB,WAAW,GAAE,KAAK,CAAC,MAAM,CAAM,GAC9B,WAAW;IAUd;;;;MAIE;IACF,2BAA2B,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM;IAInD,eAAe,CACb,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,WAAW,GAAE,KAAK,CAAC,MAAM,CAAM,GAC9B,OAAO,CAAC,MAAM,CAAC;IASlB,qBAAqB,CACnB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,WAAW,GAAE,KAAK,CAAC,MAAM,CAAM,GAC9B,MAAM;IAUT,OAAO,CAAC,SAAS,CAAgC;YACnC,cAAc;YAQd,gBAAgB;IAU9B,SAAS,CAAC,GAAG,IAAI,MAAM;IAIvB,SAAS,CAAC,GAAG,IAAI,MAAM;CAGxB"}
1
+ {"version":3,"file":"Btc.d.ts","sourceRoot":"","sources":["../src/Btc.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AACpD,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,YAAY,EAAE,aAAa,EAAE,CAAC;AAK9B;;;;;;GAMG;AAEH,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,KAAK,CAAkB;gBAEnB,EACV,SAAS,EACT,WAAmB,EACnB,QAAoB,GACrB,EAAE;QACD,SAAS,EAAE,SAAS,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;IAuBD;;;;;;OAMG;IACH,aAAa,CAAC,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAM1E;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,kBAAkB,CAChB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,aAAa,CAAC;KACxB,GACA,OAAO,CAAC;QACT,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAmBF;;;;;;;;OAQG;IACH,WAAW,CACT,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC;QACT,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IAOF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,wBAAwB,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC;IAWpE;;;;;;;;;;;;;;;;;;OAkBG;IACH,mBAAmB,CAAC,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAInE;;;;OAIG;IACH,gBAAgB,CACd,cAAc,EAAE,MAAM,EACtB,iBAAiB,GAAE,OAAO,GAAG,IAAI,GAAG,SAAiB,EACrD,YAAY,UAAQ,EACpB,YAAY,UAAQ,EACpB,WAAW,GAAE,KAAK,CAAC,MAAM,CAAM,GAC9B,WAAW;IAUd;;;;MAIE;IACF,2BAA2B,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM;IAInD,eAAe,CACb,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,WAAW,GAAE,KAAK,CAAC,MAAM,CAAM,GAC9B,OAAO,CAAC,MAAM,CAAC;IASlB,qBAAqB,CACnB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,WAAW,GAAE,KAAK,CAAC,MAAM,CAAM,GAC9B,MAAM;IASH,qBAAqB,IAAI,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;CAUxD"}
package/lib/Btc.js CHANGED
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -62,37 +39,43 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
62
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
63
40
  };
64
41
  exports.__esModule = true;
65
- var bip32_1 = require("./bip32");
66
- var BtcNew_1 = __importStar(require("./BtcNew"));
42
+ var BtcNew_1 = __importDefault(require("./BtcNew"));
67
43
  var BtcOld_1 = __importDefault(require("./BtcOld"));
68
- var getAppAndVersion_1 = require("./getAppAndVersion");
69
44
  var getTrustedInput_1 = require("./getTrustedInput");
70
45
  var getTrustedInputBIP143_1 = require("./getTrustedInputBIP143");
71
46
  var appClient_1 = require("./newops/appClient");
72
47
  var serializeTransaction_1 = require("./serializeTransaction");
73
48
  var splitTransaction_1 = require("./splitTransaction");
49
+ var signP2SHTransaction_1 = require("./signP2SHTransaction");
50
+ var signMessage_1 = require("./signMessage");
51
+ var getAppAndVersion_1 = require("./getAppAndVersion");
74
52
  /**
75
53
  * Bitcoin API.
76
54
  *
77
55
  * @example
78
56
  * import Btc from "@ledgerhq/hw-app-btc";
79
- * const btc = new Btc(transport)
57
+ * const btc = new Btc({ transport, currency: "bitcoin" });
80
58
  */
81
59
  var Btc = /** @class */ (function () {
82
- function Btc(transport, scrambleKey) {
83
- if (scrambleKey === void 0) { scrambleKey = "BTC"; }
84
- // cache the underlying implementation (only once)
85
- this._lazyImpl = null;
86
- this.transport = transport;
87
- transport.decorateAppAPIMethods(this, [
60
+ function Btc(_a) {
61
+ var transport = _a.transport, _b = _a.scrambleKey, scrambleKey = _b === void 0 ? "BTC" : _b, _c = _a.currency, currency = _c === void 0 ? "bitcoin" : _c;
62
+ this._transport = transport;
63
+ this._transport.decorateAppAPIMethods(this, [
88
64
  "getWalletXpub",
89
65
  "getWalletPublicKey",
90
66
  "signP2SHTransaction",
91
- "signMessageNew",
92
- "createPaymentTransactionNew",
67
+ "signMessage",
68
+ "createPaymentTransaction",
93
69
  "getTrustedInput",
94
70
  "getTrustedInputBIP143",
95
71
  ], scrambleKey);
72
+ // new APDU (nano app API) for bitcoin and old APDU for altcoin
73
+ if (currency === "bitcoin" || currency === "bitcoin_testnet") {
74
+ this._impl = new BtcNew_1["default"](new appClient_1.AppClient(this._transport));
75
+ }
76
+ else {
77
+ this._impl = new BtcOld_1["default"](this._transport);
78
+ }
96
79
  }
97
80
  /**
98
81
  * Get an XPUB with a ledger device
@@ -102,7 +85,9 @@ var Btc = /** @class */ (function () {
102
85
  * @returns XPUB of the account
103
86
  */
104
87
  Btc.prototype.getWalletXpub = function (arg) {
105
- return this.getCorrectImpl().then(function (impl) { return impl.getWalletXpub(arg); });
88
+ return this.changeImplIfNecessary().then(function (impl) {
89
+ return impl.getWalletXpub(arg);
90
+ });
106
91
  };
107
92
  /**
108
93
  * @param path a BIP 32 path
@@ -127,7 +112,6 @@ var Btc = /** @class */ (function () {
127
112
  * btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinAddress)
128
113
  */
129
114
  Btc.prototype.getWalletPublicKey = function (path, opts) {
130
- var _this = this;
131
115
  var options;
132
116
  if (arguments.length > 2 || typeof opts === "boolean") {
133
117
  console.warn("btc.getWalletPublicKey deprecated signature used. Please switch to getWalletPublicKey(path, { format, verify })");
@@ -140,53 +124,24 @@ var Btc = /** @class */ (function () {
140
124
  else {
141
125
  options = opts || {};
142
126
  }
143
- return this.getCorrectImpl().then(function (impl) {
144
- /**
145
- * Definition: A "normal path" is a prefix of a standard path where all
146
- * the hardened steps of the standard path are included. For example, the
147
- * paths m/44'/1'/17' and m/44'/1'/17'/1 are normal paths, but m/44'/1'
148
- * is not. m/'199/1'/17'/0/1 is not a normal path either.
149
- *
150
- * There's a compatiblity issue between old and new app: When exporting
151
- * the key of a non-normal path with verify=false, the new app would
152
- * return an error, whereas the old app would return the key.
153
- *
154
- * See
155
- * https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#get_extended_pubkey
156
- *
157
- * If format bech32m is used, we'll not use old, because it doesn't
158
- * support it.
159
- *
160
- * When to use new (given the app supports it)
161
- * * format is bech32m or
162
- * * path is normal or
163
- * * verify is true
164
- *
165
- * Otherwise use old.
166
- */
167
- if (impl instanceof BtcNew_1["default"] &&
168
- options.format != "bech32m" &&
169
- (!options.verify || options.verify == false) &&
170
- !isPathNormal(path)) {
171
- console.warn("WARNING: Using deprecated device protocol to get the public key because\n \n * a non-standard path is requested, and\n * verify flag is false\n \n The new protocol only allows export of non-standard paths if the \n verify flag is true. Standard paths are (currently):\n\n M/44'/(1|0)'/X'\n M/49'/(1|0)'/X'\n M/84'/(1|0)'/X'\n M/86'/(1|0)'/X'\n M/48'/(1|0)'/X'/Y'\n\n followed by \"\", \"(0|1)\", or \"(0|1)/b\", where a and b are \n non-hardened. For example, the following paths are standard\n \n M/48'/1'/99'/7'\n M/86'/1'/99'/0\n M/48'/0'/99'/7'/1/17\n\n The following paths are non-standard\n\n M/48'/0'/99' // Not deepest hardened path\n M/48'/0'/99'/7'/1/17/2 // Too many non-hardened derivation steps\n M/199'/0'/1'/0/88 // Not a known purpose 199\n M/86'/1'/99'/2 // Change path item must be 0 or 1\n\n This compatibility safeguard will be removed in the future.\n Please consider calling Btc.getWalletXpub() instead.");
172
- return _this.old().getWalletPublicKey(path, options);
173
- }
174
- else {
175
- return impl.getWalletPublicKey(path, options);
176
- }
127
+ return this.changeImplIfNecessary().then(function (impl) {
128
+ return impl.getWalletPublicKey(path, options);
177
129
  });
178
130
  };
179
131
  /**
180
132
  * You can sign a message according to the Bitcoin Signature format and retrieve v, r, s given the message and the BIP 32 path of the account to sign.
181
133
  * @example
182
- btc.signMessageNew_async("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
134
+ btc.signMessage("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
183
135
  var v = result['v'] + 27 + 4;
184
136
  var signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');
185
137
  console.log("Signature : " + signature);
186
138
  }).catch(function(ex) {console.log(ex);});
187
139
  */
188
- Btc.prototype.signMessageNew = function (path, messageHex) {
189
- return this.old().signMessageNew(path, messageHex);
140
+ Btc.prototype.signMessage = function (path, messageHex) {
141
+ return (0, signMessage_1.signMessage)(this._transport, {
142
+ path: path,
143
+ messageHex: messageHex
144
+ });
190
145
  };
191
146
  /**
192
147
  * To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
@@ -221,12 +176,12 @@ var Btc = /** @class */ (function () {
221
176
  outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
222
177
  }).then(res => ...);
223
178
  */
224
- Btc.prototype.createPaymentTransactionNew = function (arg) {
179
+ Btc.prototype.createPaymentTransaction = function (arg) {
225
180
  if (arguments.length > 1) {
226
- console.warn("@ledgerhq/hw-app-btc: createPaymentTransactionNew multi argument signature is deprecated. please switch to named parameters.");
181
+ throw new Error("@ledgerhq/hw-app-btc: createPaymentTransaction multi argument signature is deprecated. please switch to named parameters.");
227
182
  }
228
- return this.getCorrectImpl().then(function (impl) {
229
- return impl.createPaymentTransactionNew(arg);
183
+ return this.changeImplIfNecessary().then(function (impl) {
184
+ return impl.createPaymentTransaction(arg);
230
185
  });
231
186
  };
232
187
  /**
@@ -249,7 +204,7 @@ var Btc = /** @class */ (function () {
249
204
  }).then(result => ...);
250
205
  */
251
206
  Btc.prototype.signP2SHTransaction = function (arg) {
252
- return this.old().signP2SHTransaction(arg);
207
+ return (0, signP2SHTransaction_1.signP2SHTransaction)(this._transport, arg);
253
208
  };
254
209
  /**
255
210
  * For each UTXO included in your transaction, create a transaction object from the raw serialized version of the transaction used in this UTXO.
@@ -273,85 +228,34 @@ var Btc = /** @class */ (function () {
273
228
  };
274
229
  Btc.prototype.getTrustedInput = function (indexLookup, transaction, additionals) {
275
230
  if (additionals === void 0) { additionals = []; }
276
- return (0, getTrustedInput_1.getTrustedInput)(this.transport, indexLookup, transaction, additionals);
231
+ return (0, getTrustedInput_1.getTrustedInput)(this._transport, indexLookup, transaction, additionals);
277
232
  };
278
233
  Btc.prototype.getTrustedInputBIP143 = function (indexLookup, transaction, additionals) {
279
234
  if (additionals === void 0) { additionals = []; }
280
- return (0, getTrustedInputBIP143_1.getTrustedInputBIP143)(this.transport, indexLookup, transaction, additionals);
281
- };
282
- Btc.prototype.getCorrectImpl = function () {
283
- return __awaiter(this, void 0, void 0, function () {
284
- var _lazyImpl, impl;
285
- return __generator(this, function (_a) {
286
- switch (_a.label) {
287
- case 0:
288
- _lazyImpl = this._lazyImpl;
289
- if (_lazyImpl)
290
- return [2 /*return*/, _lazyImpl];
291
- return [4 /*yield*/, this.inferCorrectImpl()];
292
- case 1:
293
- impl = _a.sent();
294
- this._lazyImpl = impl;
295
- return [2 /*return*/, impl];
296
- }
297
- });
298
- });
235
+ return (0, getTrustedInputBIP143_1.getTrustedInputBIP143)(this._transport, indexLookup, transaction, additionals);
299
236
  };
300
- Btc.prototype.inferCorrectImpl = function () {
237
+ Btc.prototype.changeImplIfNecessary = function () {
301
238
  return __awaiter(this, void 0, void 0, function () {
302
- var appAndVersion, canUseNewImplementation;
239
+ var appAndVersion, isBtcLegacy;
303
240
  return __generator(this, function (_a) {
304
241
  switch (_a.label) {
305
- case 0: return [4 /*yield*/, (0, getAppAndVersion_1.getAppAndVersion)(this.transport)];
242
+ case 0: return [4 /*yield*/, (0, getAppAndVersion_1.getAppAndVersion)(this._transport)];
306
243
  case 1:
307
244
  appAndVersion = _a.sent();
308
- canUseNewImplementation = (0, BtcNew_1.canSupportApp)(appAndVersion);
309
- if (!canUseNewImplementation) {
310
- return [2 /*return*/, this.old()];
311
- }
312
- else {
313
- return [2 /*return*/, this["new"]()];
245
+ if (!(appAndVersion.name === "Exchange" && this._impl instanceof BtcNew_1["default"])) return [3 /*break*/, 3];
246
+ return [4 /*yield*/, (0, getAppAndVersion_1.checkIsBtcLegacy)(this._transport)];
247
+ case 2:
248
+ isBtcLegacy = _a.sent();
249
+ if (isBtcLegacy) {
250
+ this._impl = new BtcOld_1["default"](this._transport);
314
251
  }
315
- return [2 /*return*/];
252
+ _a.label = 3;
253
+ case 3: return [2 /*return*/, this._impl];
316
254
  }
317
255
  });
318
256
  });
319
257
  };
320
- Btc.prototype.old = function () {
321
- return new BtcOld_1["default"](this.transport);
322
- };
323
- Btc.prototype["new"] = function () {
324
- return new BtcNew_1["default"](new appClient_1.AppClient(this.transport));
325
- };
326
258
  return Btc;
327
259
  }());
328
260
  exports["default"] = Btc;
329
- function isPathNormal(path) {
330
- //path is not deepest hardened node of a standard path or deeper, use BtcOld
331
- var h = 0x80000000;
332
- var pathElems = (0, bip32_1.pathStringToArray)(path);
333
- var hard = function (n) { return n >= h; };
334
- var soft = function (n) { return !n || n < h; };
335
- var change = function (n) { return !n || n == 0 || n == 1; };
336
- if (pathElems.length >= 3 &&
337
- pathElems.length <= 5 &&
338
- [44 + h, 49 + h, 84 + h, 86 + h].some(function (v) { return v == pathElems[0]; }) &&
339
- [0 + h, 1 + h].some(function (v) { return v == pathElems[1]; }) &&
340
- hard(pathElems[2]) &&
341
- change(pathElems[3]) &&
342
- soft(pathElems[4])) {
343
- return true;
344
- }
345
- if (pathElems.length >= 4 &&
346
- pathElems.length <= 6 &&
347
- 48 + h == pathElems[0] &&
348
- [0 + h, 1 + h].some(function (v) { return v == pathElems[1]; }) &&
349
- hard(pathElems[2]) &&
350
- hard(pathElems[3]) &&
351
- change(pathElems[4]) &&
352
- soft(pathElems[5])) {
353
- return true;
354
- }
355
- return false;
356
- }
357
261
  //# sourceMappingURL=Btc.js.map