@ledgerhq/hw-app-btc 10.2.1 → 10.2.2-new-wc.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.
- package/CHANGELOG.md +9 -0
- package/README.md +104 -58
- package/lib/Btc.d.ts +31 -7
- package/lib/Btc.d.ts.map +1 -1
- package/lib/Btc.js +31 -7
- package/lib/Btc.js.map +1 -1
- package/lib/BtcNew.d.ts +4 -2
- package/lib/BtcNew.d.ts.map +1 -1
- package/lib/BtcNew.js +9 -2
- package/lib/BtcNew.js.map +1 -1
- package/lib/BtcOld.d.ts +8 -6
- package/lib/BtcOld.d.ts.map +1 -1
- package/lib/BtcOld.js +8 -6
- package/lib/BtcOld.js.map +1 -1
- package/lib/bip32.d.ts +9 -0
- package/lib/bip32.d.ts.map +1 -1
- package/lib/bip32.js +9 -0
- package/lib/bip32.js.map +1 -1
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +6 -1
- package/lib/constants.js.map +1 -1
- package/lib/createTransaction.d.ts.map +1 -1
- package/lib/createTransaction.js +2 -1
- package/lib/createTransaction.js.map +1 -1
- package/lib/getWalletPublicKey.d.ts +1 -1
- package/lib/types.d.ts.map +1 -1
- package/lib-es/Btc.d.ts +31 -7
- package/lib-es/Btc.d.ts.map +1 -1
- package/lib-es/Btc.js +31 -7
- package/lib-es/Btc.js.map +1 -1
- package/lib-es/BtcNew.d.ts +4 -2
- package/lib-es/BtcNew.d.ts.map +1 -1
- package/lib-es/BtcNew.js +9 -2
- package/lib-es/BtcNew.js.map +1 -1
- package/lib-es/BtcOld.d.ts +8 -6
- package/lib-es/BtcOld.d.ts.map +1 -1
- package/lib-es/BtcOld.js +8 -6
- package/lib-es/BtcOld.js.map +1 -1
- package/lib-es/bip32.d.ts +9 -0
- package/lib-es/bip32.d.ts.map +1 -1
- package/lib-es/bip32.js +9 -0
- package/lib-es/bip32.js.map +1 -1
- package/lib-es/constants.d.ts.map +1 -1
- package/lib-es/constants.js +6 -1
- package/lib-es/constants.js.map +1 -1
- package/lib-es/createTransaction.d.ts.map +1 -1
- package/lib-es/createTransaction.js +2 -1
- package/lib-es/createTransaction.js.map +1 -1
- package/lib-es/getWalletPublicKey.d.ts +1 -1
- package/lib-es/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/Btc.ts +34 -8
- package/src/BtcNew.ts +9 -2
- package/src/BtcOld.ts +8 -6
- package/src/bip32.ts +10 -0
- package/src/constants.ts +6 -1
- package/src/createTransaction.ts +2 -1
- package/src/getWalletPublicKey.ts +1 -1
- package/src/types.ts +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @ledgerhq/hw-app-btc
|
|
2
2
|
|
|
3
|
+
## 10.2.2-new-wc.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#6105](https://github.com/LedgerHQ/ledger-live/pull/6105) [`6d40673`](https://github.com/LedgerHQ/ledger-live/commit/6d4067382b55827b00806a1b71ac0b249563d90f) Thanks [@hzheng-ledger](https://github.com/hzheng-ledger)! - update hw-app-btc doc
|
|
8
|
+
|
|
9
|
+
- Updated dependencies []:
|
|
10
|
+
- @ledgerhq/hw-transport@6.30.4-new-wc.0
|
|
11
|
+
|
|
3
12
|
## 10.2.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ For a smooth and quick integration:
|
|
|
27
27
|
|
|
28
28
|
#### Table of Contents
|
|
29
29
|
|
|
30
|
+
* [bippath](#bippath)
|
|
30
31
|
* [Btc](#btc)
|
|
31
32
|
* [Parameters](#parameters)
|
|
32
33
|
* [Examples](#examples)
|
|
@@ -50,80 +51,90 @@ For a smooth and quick integration:
|
|
|
50
51
|
* [serializeTransactionOutputs](#serializetransactionoutputs)
|
|
51
52
|
* [Parameters](#parameters-7)
|
|
52
53
|
* [Examples](#examples-6)
|
|
54
|
+
* [getTrustedInput](#gettrustedinput)
|
|
55
|
+
* [Parameters](#parameters-8)
|
|
56
|
+
* [getTrustedInputBIP143](#gettrustedinputbip143)
|
|
57
|
+
* [Parameters](#parameters-9)
|
|
53
58
|
* [BtcNew](#btcnew)
|
|
54
|
-
* [Parameters](#parameters-8)
|
|
55
59
|
* [getWalletXpub](#getwalletxpub-1)
|
|
56
|
-
* [Parameters](#parameters-9)
|
|
57
|
-
* [getWalletPublicKey](#getwalletpublickey-1)
|
|
58
60
|
* [Parameters](#parameters-10)
|
|
59
|
-
* [
|
|
61
|
+
* [getWalletPublicKey](#getwalletpublickey-1)
|
|
60
62
|
* [Parameters](#parameters-11)
|
|
61
|
-
* [
|
|
63
|
+
* [createPaymentTransaction](#createpaymenttransaction-1)
|
|
62
64
|
* [Parameters](#parameters-12)
|
|
65
|
+
* [signMessage](#signmessage-1)
|
|
66
|
+
* [Parameters](#parameters-13)
|
|
67
|
+
* [descrTemplFrom](#descrtemplfrom)
|
|
68
|
+
* [Parameters](#parameters-14)
|
|
63
69
|
* [BtcOld](#btcold)
|
|
64
|
-
* [Parameters](#parameters-13)
|
|
65
|
-
* [Examples](#examples-7)
|
|
66
70
|
* [getWalletPublicKey](#getwalletpublickey-2)
|
|
67
|
-
* [Parameters](#parameters-14)
|
|
68
|
-
* [Examples](#examples-8)
|
|
69
|
-
* [createPaymentTransaction](#createpaymenttransaction-2)
|
|
70
71
|
* [Parameters](#parameters-15)
|
|
71
|
-
* [Examples](#examples-
|
|
72
|
+
* [Examples](#examples-7)
|
|
73
|
+
* [createPaymentTransaction](#createpaymenttransaction-2)
|
|
74
|
+
* [Parameters](#parameters-16)
|
|
75
|
+
* [Examples](#examples-8)
|
|
72
76
|
* [CreateTransactionArg](#createtransactionarg)
|
|
73
77
|
* [Properties](#properties)
|
|
74
78
|
* [AddressFormat](#addressformat)
|
|
75
79
|
* [AccountType](#accounttype)
|
|
76
80
|
* [spendingCondition](#spendingcondition)
|
|
77
|
-
* [Parameters](#parameters-16)
|
|
78
|
-
* [setInput](#setinput)
|
|
79
81
|
* [Parameters](#parameters-17)
|
|
80
|
-
* [
|
|
82
|
+
* [setInput](#setinput)
|
|
81
83
|
* [Parameters](#parameters-18)
|
|
84
|
+
* [setOwnOutput](#setownoutput)
|
|
85
|
+
* [Parameters](#parameters-19)
|
|
82
86
|
* [getDescriptorTemplate](#getdescriptortemplate)
|
|
83
87
|
* [SingleKeyAccount](#singlekeyaccount)
|
|
84
88
|
* [getTaprootOutputKey](#gettaprootoutputkey)
|
|
85
|
-
* [Parameters](#parameters-19)
|
|
86
|
-
* [AppClient](#appclient)
|
|
87
89
|
* [Parameters](#parameters-20)
|
|
88
|
-
* [
|
|
90
|
+
* [AppClient](#appclient)
|
|
89
91
|
* [Parameters](#parameters-21)
|
|
90
|
-
* [
|
|
92
|
+
* [ClientCommandInterpreter](#clientcommandinterpreter)
|
|
91
93
|
* [Parameters](#parameters-22)
|
|
92
|
-
* [
|
|
94
|
+
* [MerkelizedPsbt](#merkelizedpsbt)
|
|
93
95
|
* [Parameters](#parameters-23)
|
|
94
|
-
* [
|
|
96
|
+
* [Merkle](#merkle)
|
|
95
97
|
* [Parameters](#parameters-24)
|
|
96
|
-
* [
|
|
98
|
+
* [MerkleMap](#merklemap)
|
|
97
99
|
* [Parameters](#parameters-25)
|
|
98
|
-
* [
|
|
100
|
+
* [WalletPolicy](#walletpolicy)
|
|
99
101
|
* [Parameters](#parameters-26)
|
|
100
|
-
* [
|
|
102
|
+
* [extract](#extract)
|
|
101
103
|
* [Parameters](#parameters-27)
|
|
102
|
-
* [
|
|
104
|
+
* [finalize](#finalize)
|
|
103
105
|
* [Parameters](#parameters-28)
|
|
104
|
-
* [
|
|
106
|
+
* [clearFinalizedInput](#clearfinalizedinput)
|
|
105
107
|
* [Parameters](#parameters-29)
|
|
108
|
+
* [writePush](#writepush)
|
|
109
|
+
* [Parameters](#parameters-30)
|
|
106
110
|
* [PsbtV2](#psbtv2)
|
|
107
111
|
* [serializeTransactionOutputs](#serializetransactionoutputs-1)
|
|
108
|
-
* [Parameters](#parameters-
|
|
109
|
-
* [Examples](#examples-
|
|
112
|
+
* [Parameters](#parameters-31)
|
|
113
|
+
* [Examples](#examples-9)
|
|
110
114
|
* [SignP2SHTransactionArg](#signp2shtransactionarg)
|
|
111
115
|
* [Properties](#properties-1)
|
|
112
116
|
* [TransactionInput](#transactioninput)
|
|
113
117
|
* [TransactionOutput](#transactionoutput)
|
|
114
118
|
* [Transaction](#transaction)
|
|
115
119
|
|
|
120
|
+
### bippath
|
|
121
|
+
|
|
122
|
+
BIP32 Path Handling for Bitcoin Wallets
|
|
123
|
+
|
|
124
|
+
This file provides utility functions to handle BIP32 paths,
|
|
125
|
+
which are commonly used in hierarchical deterministic (HD) wallets.
|
|
126
|
+
It includes functions to convert BIP32 paths to and from different formats,
|
|
127
|
+
extract components from extended public keys (xpubs), and manipulate path elements.
|
|
128
|
+
|
|
116
129
|
### Btc
|
|
117
130
|
|
|
118
131
|
Bitcoin API.
|
|
119
132
|
|
|
120
133
|
#### Parameters
|
|
121
134
|
|
|
122
|
-
*
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
* `$0.scrambleKey` (optional, default `"BTC"`)
|
|
126
|
-
* `$0.currency` (optional, default `"bitcoin"`)
|
|
135
|
+
* `transport` The transport layer used for communication.
|
|
136
|
+
* `scrambleKey` This parameter is deprecated and no longer needed.
|
|
137
|
+
* `currency` The currency to use, defaults to "bitcoin".
|
|
127
138
|
|
|
128
139
|
#### Examples
|
|
129
140
|
|
|
@@ -138,8 +149,10 @@ Get an XPUB with a ledger device
|
|
|
138
149
|
|
|
139
150
|
##### Parameters
|
|
140
151
|
|
|
141
|
-
* `arg` **{path: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), xpubVersion: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)}** derivation parameter* path: a BIP 32 path of the account level. e.g. `84'/0'/0'`
|
|
142
|
-
|
|
152
|
+
* `arg` **{path: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), xpubVersion: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)}** derivation parameter* path: a BIP 32 path of the account level. (e.g. The derivation path `84'/0'/0'`
|
|
153
|
+
follows the `purpose' / coin_type' / account'` standard, with purpose=84, coin\_type=0, account=0)
|
|
154
|
+
* xpubVersion: the XPUBVersion of the coin used. (refer to ledgerjs/packages/cryptoassets/src/currencies.ts
|
|
155
|
+
for the XPUBVersion value if needed)
|
|
143
156
|
|
|
144
157
|
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)>** XPUB of the account
|
|
145
158
|
|
|
@@ -147,9 +160,9 @@ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
|
|
|
147
160
|
|
|
148
161
|
##### Parameters
|
|
149
162
|
|
|
150
|
-
* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a BIP 32 path
|
|
163
|
+
* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a BIP 32 path (i.e. the `purpose’ / coin_type’ / account’ / change / address_index` standard)
|
|
151
164
|
* `opts` **{verify: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, format: [AddressFormat](#addressformat)?}?** 
|
|
152
|
-
* `options` an object with optional these fields:* verify (boolean)
|
|
165
|
+
* `options` an object with optional these fields:* verify (boolean) whether ask user to confirm the address on the device
|
|
153
166
|
|
|
154
167
|
* format ("legacy" | "p2sh" | "bech32" | "bech32m" | "cashaddr") to use different bitcoin address formatter.NB The normal usage is to use:* legacy format with 44' paths
|
|
155
168
|
|
|
@@ -157,6 +170,8 @@ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
|
|
|
157
170
|
|
|
158
171
|
* bech32 format with 84' paths
|
|
159
172
|
|
|
173
|
+
* bech32m format with 86' paths
|
|
174
|
+
|
|
160
175
|
* cashaddr in case of Bitcoin Cash
|
|
161
176
|
|
|
162
177
|
##### Examples
|
|
@@ -211,6 +226,8 @@ To sign a transaction involving standard (P2PKH) inputs, call createTransaction
|
|
|
211
226
|
* "bech32m" for spending segwit v1+ outputs
|
|
212
227
|
* "abc" for bch
|
|
213
228
|
* "gold" for btg
|
|
229
|
+
* "decred" for decred
|
|
230
|
+
* "zcash" for zcash
|
|
214
231
|
* "bipxxx" for using BIPxxx
|
|
215
232
|
* "sapling" to indicate a zec transaction is supporting sapling (to be set over block 419200)
|
|
216
233
|
* `expiryHeight` is an optional Buffer for zec overwinter / sapling Txs
|
|
@@ -262,11 +279,11 @@ For each UTXO included in your transaction, create a transaction object from the
|
|
|
262
279
|
|
|
263
280
|
##### Parameters
|
|
264
281
|
|
|
265
|
-
* `transactionHex` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
|
|
266
|
-
* `isSegwitSupported` **([boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
|
|
267
|
-
* `hasTimestamp`
|
|
268
|
-
* `hasExtraData`
|
|
269
|
-
* `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)>**
|
|
282
|
+
* `transactionHex` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a raw hexadecimal serialized transaction
|
|
283
|
+
* `isSegwitSupported` **([boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))** is a boolean indicating if the segwit is supported (optional, default `false`)
|
|
284
|
+
* `hasTimestamp` is a boolean (peercoin includes timestamp in their transactions, others don't) (optional, default `false`)
|
|
285
|
+
* `hasExtraData` is a boolean (komodo, zencash and zcash include extraData in their transactions, others don't) (optional, default `false`)
|
|
286
|
+
* `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)>** list of additionnal options (optional, default `[]`)
|
|
270
287
|
|
|
271
288
|
##### Examples
|
|
272
289
|
|
|
@@ -274,10 +291,12 @@ For each UTXO included in your transaction, create a transaction object from the
|
|
|
274
291
|
const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
|
|
275
292
|
```
|
|
276
293
|
|
|
277
|
-
Returns **[Transaction](#transaction)
|
|
294
|
+
Returns **[Transaction](#transaction)** the transaction object deserialized from the raw hexadecimal transaction
|
|
278
295
|
|
|
279
296
|
#### serializeTransactionOutputs
|
|
280
297
|
|
|
298
|
+
Serialize a transaction's outputs to hexadecimal
|
|
299
|
+
|
|
281
300
|
##### Parameters
|
|
282
301
|
|
|
283
302
|
* `t` **[Transaction](#transaction)** 
|
|
@@ -291,10 +310,36 @@ const outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');
|
|
|
291
310
|
|
|
292
311
|
Returns **[Buffer](https://nodejs.org/api/buffer.html)** 
|
|
293
312
|
|
|
313
|
+
#### getTrustedInput
|
|
314
|
+
|
|
315
|
+
Trusted input is the hash of a UTXO that needs to be signed
|
|
316
|
+
For Legacy transactions, the app has some APDUs flows that do the amount check for an UTXO,
|
|
317
|
+
by parsing the transaction that created this UTXO
|
|
318
|
+
|
|
319
|
+
##### Parameters
|
|
320
|
+
|
|
321
|
+
* `indexLookup` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 
|
|
322
|
+
* `transaction` **[Transaction](#transaction)** 
|
|
323
|
+
* `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)>** (optional, default `[]`)
|
|
324
|
+
|
|
325
|
+
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)>** 
|
|
326
|
+
|
|
327
|
+
#### getTrustedInputBIP143
|
|
328
|
+
|
|
329
|
+
Trusted input is the hash of a UTXO that needs to be signed. BIP143 is used for Segwit inputs.
|
|
330
|
+
|
|
331
|
+
##### Parameters
|
|
332
|
+
|
|
333
|
+
* `indexLookup` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 
|
|
334
|
+
* `transaction` **[Transaction](#transaction)** 
|
|
335
|
+
* `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)>** (optional, default `[]`)
|
|
336
|
+
|
|
337
|
+
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
|
|
338
|
+
|
|
294
339
|
### BtcNew
|
|
295
340
|
|
|
296
341
|
This class implements the same interface as BtcOld (formerly
|
|
297
|
-
named Btc), but interacts with Bitcoin hardware app version 2+
|
|
342
|
+
named Btc), but interacts with Bitcoin hardware app version 2.1.0+
|
|
298
343
|
which uses a totally new APDU protocol. This new
|
|
299
344
|
protocol is documented at
|
|
300
345
|
<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md>
|
|
@@ -305,10 +350,6 @@ input data into the PSBT process. In the future, a new interface should
|
|
|
305
350
|
be developed that exposes PSBT to the outer world, which would render
|
|
306
351
|
a much cleaner implementation.
|
|
307
352
|
|
|
308
|
-
#### Parameters
|
|
309
|
-
|
|
310
|
-
* ``  
|
|
311
|
-
|
|
312
353
|
#### getWalletXpub
|
|
313
354
|
|
|
314
355
|
This is a new method that allow users to get an xpub at a standard path.
|
|
@@ -394,20 +435,21 @@ and returns v, r, s.
|
|
|
394
435
|
|
|
395
436
|
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)}>** 
|
|
396
437
|
|
|
397
|
-
###
|
|
438
|
+
### descrTemplFrom
|
|
398
439
|
|
|
399
|
-
|
|
440
|
+
This function returns a descriptor template based on the address format.
|
|
441
|
+
See <https://github.com/LedgerHQ/app-bitcoin-new/blob/develop/doc/wallet.md> for details of
|
|
442
|
+
the bitcoin descriptor template.
|
|
400
443
|
|
|
401
444
|
#### Parameters
|
|
402
445
|
|
|
403
|
-
*
|
|
446
|
+
* `addressFormat` **[AddressFormat](#addressformat)** 
|
|
404
447
|
|
|
405
|
-
|
|
448
|
+
Returns **DefaultDescriptorTemplate** 
|
|
406
449
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
```
|
|
450
|
+
### BtcOld
|
|
451
|
+
|
|
452
|
+
This Bitcoin old API is compatible with versions of the Bitcoin nano app that are earlier than 2.1.0
|
|
411
453
|
|
|
412
454
|
#### getWalletPublicKey
|
|
413
455
|
|
|
@@ -417,11 +459,13 @@ const btc = new Btc({ transport, currency: "zcash" });
|
|
|
417
459
|
* `opts` **{verify: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, format: [AddressFormat](#addressformat)?}?** 
|
|
418
460
|
* `options` an object with optional these fields:* verify (boolean) will ask user to confirm the address on the device
|
|
419
461
|
|
|
420
|
-
* format ("legacy" | "p2sh" | "bech32" | "cashaddr") to use different bitcoin address formatter.NB The normal usage is to use:* legacy format with 44' paths
|
|
462
|
+
* format ("legacy" | "p2sh" | "bech32" | "bech32m" | "cashaddr") to use different bitcoin address formatter.NB The normal usage is to use:* legacy format with 44' paths
|
|
421
463
|
|
|
422
464
|
* p2sh format with 49' paths
|
|
423
465
|
|
|
424
|
-
* bech32 format with
|
|
466
|
+
* bech32 format with 84' paths
|
|
467
|
+
|
|
468
|
+
* bech32m format with 86' paths
|
|
425
469
|
|
|
426
470
|
* cashaddr in case of Bitcoin Cash
|
|
427
471
|
|
|
@@ -455,6 +499,8 @@ To sign a transaction involving standard (P2PKH) inputs, call createTransaction
|
|
|
455
499
|
* `additionals` list of additionnal options* "bech32" for spending native segwit outputs
|
|
456
500
|
* "abc" for bch
|
|
457
501
|
* "gold" for btg
|
|
502
|
+
* "decred" for decred
|
|
503
|
+
* "zcash" for zcash
|
|
458
504
|
* "bipxxx" for using BIPxxx
|
|
459
505
|
* "sapling" to indicate a zec transaction is supporting sapling (to be set over block 419200)
|
|
460
506
|
* `expiryHeight` is an optional Buffer for zec overwinter / sapling Txs
|
|
@@ -495,7 +541,7 @@ Type: {inputs: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Referen
|
|
|
495
541
|
|
|
496
542
|
### AddressFormat
|
|
497
543
|
|
|
498
|
-
address format is one of legacy | p2sh | bech32 | cashaddr
|
|
544
|
+
address format is one of legacy | p2sh | bech32 | bech32m | cashaddr
|
|
499
545
|
|
|
500
546
|
Type: (`"legacy"` | `"p2sh"` | `"bech32"` | `"bech32m"` | `"cashaddr"`)
|
|
501
547
|
|
package/lib/Btc.d.ts
CHANGED
|
@@ -8,8 +8,11 @@ import type { SignP2SHTransactionArg } from "./signP2SHTransaction";
|
|
|
8
8
|
import type { Transaction } from "./types";
|
|
9
9
|
export type { AddressFormat };
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* @class Btc
|
|
12
|
+
* @description Bitcoin API.
|
|
13
|
+
* @param transport The transport layer used for communication.
|
|
14
|
+
* @param scrambleKey This parameter is deprecated and no longer needed.
|
|
15
|
+
* @param currency The currency to use, defaults to "bitcoin".
|
|
13
16
|
* @example
|
|
14
17
|
* import Btc from "@ledgerhq/hw-app-btc";
|
|
15
18
|
* const btc = new Btc({ transport, currency: "bitcoin" });
|
|
@@ -25,8 +28,10 @@ export default class Btc {
|
|
|
25
28
|
/**
|
|
26
29
|
* Get an XPUB with a ledger device
|
|
27
30
|
* @param arg derivation parameter
|
|
28
|
-
* - path: a BIP 32 path of the account level. e.g. `84'/0'/0'`
|
|
29
|
-
*
|
|
31
|
+
* - path: a BIP 32 path of the account level. (e.g. The derivation path `84'/0'/0'`
|
|
32
|
+
* follows the `purpose' / coin_type' / account'` standard, with purpose=84, coin_type=0, account=0)
|
|
33
|
+
* - xpubVersion: the XPUBVersion of the coin used. (refer to ledgerjs/packages/cryptoassets/src/currencies.ts
|
|
34
|
+
* for the XPUBVersion value if needed)
|
|
30
35
|
* @returns XPUB of the account
|
|
31
36
|
*/
|
|
32
37
|
getWalletXpub(arg: {
|
|
@@ -34,10 +39,10 @@ export default class Btc {
|
|
|
34
39
|
xpubVersion: number;
|
|
35
40
|
}): Promise<string>;
|
|
36
41
|
/**
|
|
37
|
-
* @param path a BIP 32 path
|
|
42
|
+
* @param path a BIP 32 path (i.e. the `purpose’ / coin_type’ / account’ / change / address_index` standard)
|
|
38
43
|
* @param options an object with optional these fields:
|
|
39
44
|
*
|
|
40
|
-
* - verify (boolean)
|
|
45
|
+
* - verify (boolean) whether ask user to confirm the address on the device
|
|
41
46
|
*
|
|
42
47
|
* - format ("legacy" | "p2sh" | "bech32" | "bech32m" | "cashaddr") to use different bitcoin address formatter.
|
|
43
48
|
*
|
|
@@ -49,6 +54,8 @@ export default class Btc {
|
|
|
49
54
|
*
|
|
50
55
|
* - bech32 format with 84' paths
|
|
51
56
|
*
|
|
57
|
+
* - bech32m format with 86' paths
|
|
58
|
+
*
|
|
52
59
|
* - cashaddr in case of Bitcoin Cash
|
|
53
60
|
*
|
|
54
61
|
* @example
|
|
@@ -98,6 +105,8 @@ export default class Btc {
|
|
|
98
105
|
* - "bech32m" for spending segwit v1+ outputs
|
|
99
106
|
* - "abc" for bch
|
|
100
107
|
* - "gold" for btg
|
|
108
|
+
* - "decred" for decred
|
|
109
|
+
* - "zcash" for zcash
|
|
101
110
|
* - "bipxxx" for using BIPxxx
|
|
102
111
|
* - "sapling" to indicate a zec transaction is supporting sapling (to be set over block 419200)
|
|
103
112
|
* @param expiryHeight is an optional Buffer for zec overwinter / sapling Txs
|
|
@@ -133,17 +142,32 @@ export default class Btc {
|
|
|
133
142
|
signP2SHTransaction(arg: SignP2SHTransactionArg): Promise<string[]>;
|
|
134
143
|
/**
|
|
135
144
|
* For each UTXO included in your transaction, create a transaction object from the raw serialized version of the transaction used in this UTXO.
|
|
145
|
+
* @param transactionHex a raw hexadecimal serialized transaction
|
|
146
|
+
* @param isSegwitSupported is a boolean indicating if the segwit is supported
|
|
147
|
+
* @param hasTimestamp is a boolean (peercoin includes timestamp in their transactions, others don't)
|
|
148
|
+
* @param hasExtraData is a boolean (komodo, zencash and zcash include extraData in their transactions, others don't)
|
|
149
|
+
* @param additionals list of additionnal options
|
|
150
|
+
* @return the transaction object deserialized from the raw hexadecimal transaction
|
|
136
151
|
* @example
|
|
137
152
|
const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
|
|
138
153
|
*/
|
|
139
154
|
splitTransaction(transactionHex: string, isSegwitSupported?: boolean | null | undefined, hasTimestamp?: boolean, hasExtraData?: boolean, additionals?: Array<string>): Transaction;
|
|
140
155
|
/**
|
|
141
|
-
|
|
156
|
+
* Serialize a transaction's outputs to hexadecimal
|
|
157
|
+
* @example
|
|
142
158
|
const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
|
|
143
159
|
const outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');
|
|
144
160
|
*/
|
|
145
161
|
serializeTransactionOutputs(t: Transaction): Buffer;
|
|
162
|
+
/**
|
|
163
|
+
* Trusted input is the hash of a UTXO that needs to be signed
|
|
164
|
+
* For Legacy transactions, the app has some APDUs flows that do the amount check for an UTXO,
|
|
165
|
+
* by parsing the transaction that created this UTXO
|
|
166
|
+
*/
|
|
146
167
|
getTrustedInput(indexLookup: number, transaction: Transaction, additionals?: Array<string>): Promise<string>;
|
|
168
|
+
/**
|
|
169
|
+
* Trusted input is the hash of a UTXO that needs to be signed. BIP143 is used for Segwit inputs.
|
|
170
|
+
*/
|
|
147
171
|
getTrustedInputBIP143(indexLookup: number, transaction: Transaction, additionals?: Array<string>): string;
|
|
148
172
|
changeImplIfNecessary(): Promise<BtcOld | BtcNew>;
|
|
149
173
|
}
|
package/lib/Btc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Btc.d.ts","sourceRoot":"","sources":["../src/Btc.ts"],"names":[],"mappings":";AACA,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;AAI9B
|
|
1
|
+
{"version":3,"file":"Btc.d.ts","sourceRoot":"","sources":["../src/Btc.ts"],"names":[],"mappings":";AACA,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;AAI9B;;;;;;;;;GASG;AAEH,MAAM,CAAC,OAAO,OAAO,GAAG;IAEtB,OAAO,CAAC,UAAU,CAAY;IAG9B,OAAO,CAAC,KA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AAM,GAC9B,WAAW;IAUd;;;;;MAKE;IACF,2BAA2B,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM;IAInD;;;;OAIG;IACH,eAAe,CACb,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,WAAW,GAAE,KAAK,CAAC,MAAM,CAAM,GAC9B,OAAO,CAAC,MAAM,CAAC;IAIlB;;OAEG;IACH,qBAAqB,CACnB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,WAAW,GAAE,KAAK,CAAC,MAAM,CAAM,GAC9B,MAAM;IAIH,qBAAqB,IAAI,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;CAmCxD"}
|
package/lib/Btc.js
CHANGED
|
@@ -23,8 +23,11 @@ const splitTransaction_1 = require("./splitTransaction");
|
|
|
23
23
|
const signP2SHTransaction_1 = require("./signP2SHTransaction");
|
|
24
24
|
const getAppAndVersion_1 = require("./getAppAndVersion");
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* @class Btc
|
|
27
|
+
* @description Bitcoin API.
|
|
28
|
+
* @param transport The transport layer used for communication.
|
|
29
|
+
* @param scrambleKey This parameter is deprecated and no longer needed.
|
|
30
|
+
* @param currency The currency to use, defaults to "bitcoin".
|
|
28
31
|
* @example
|
|
29
32
|
* import Btc from "@ledgerhq/hw-app-btc";
|
|
30
33
|
* const btc = new Btc({ transport, currency: "bitcoin" });
|
|
@@ -57,8 +60,10 @@ class Btc {
|
|
|
57
60
|
/**
|
|
58
61
|
* Get an XPUB with a ledger device
|
|
59
62
|
* @param arg derivation parameter
|
|
60
|
-
* - path: a BIP 32 path of the account level. e.g. `84'/0'/0'`
|
|
61
|
-
*
|
|
63
|
+
* - path: a BIP 32 path of the account level. (e.g. The derivation path `84'/0'/0'`
|
|
64
|
+
* follows the `purpose' / coin_type' / account'` standard, with purpose=84, coin_type=0, account=0)
|
|
65
|
+
* - xpubVersion: the XPUBVersion of the coin used. (refer to ledgerjs/packages/cryptoassets/src/currencies.ts
|
|
66
|
+
* for the XPUBVersion value if needed)
|
|
62
67
|
* @returns XPUB of the account
|
|
63
68
|
*/
|
|
64
69
|
getWalletXpub(arg) {
|
|
@@ -67,10 +72,10 @@ class Btc {
|
|
|
67
72
|
});
|
|
68
73
|
}
|
|
69
74
|
/**
|
|
70
|
-
* @param path a BIP 32 path
|
|
75
|
+
* @param path a BIP 32 path (i.e. the `purpose’ / coin_type’ / account’ / change / address_index` standard)
|
|
71
76
|
* @param options an object with optional these fields:
|
|
72
77
|
*
|
|
73
|
-
* - verify (boolean)
|
|
78
|
+
* - verify (boolean) whether ask user to confirm the address on the device
|
|
74
79
|
*
|
|
75
80
|
* - format ("legacy" | "p2sh" | "bech32" | "bech32m" | "cashaddr") to use different bitcoin address formatter.
|
|
76
81
|
*
|
|
@@ -82,6 +87,8 @@ class Btc {
|
|
|
82
87
|
*
|
|
83
88
|
* - bech32 format with 84' paths
|
|
84
89
|
*
|
|
90
|
+
* - bech32m format with 86' paths
|
|
91
|
+
*
|
|
85
92
|
* - cashaddr in case of Bitcoin Cash
|
|
86
93
|
*
|
|
87
94
|
* @example
|
|
@@ -143,6 +150,8 @@ class Btc {
|
|
|
143
150
|
* - "bech32m" for spending segwit v1+ outputs
|
|
144
151
|
* - "abc" for bch
|
|
145
152
|
* - "gold" for btg
|
|
153
|
+
* - "decred" for decred
|
|
154
|
+
* - "zcash" for zcash
|
|
146
155
|
* - "bipxxx" for using BIPxxx
|
|
147
156
|
* - "sapling" to indicate a zec transaction is supporting sapling (to be set over block 419200)
|
|
148
157
|
* @param expiryHeight is an optional Buffer for zec overwinter / sapling Txs
|
|
@@ -187,6 +196,12 @@ class Btc {
|
|
|
187
196
|
}
|
|
188
197
|
/**
|
|
189
198
|
* For each UTXO included in your transaction, create a transaction object from the raw serialized version of the transaction used in this UTXO.
|
|
199
|
+
* @param transactionHex a raw hexadecimal serialized transaction
|
|
200
|
+
* @param isSegwitSupported is a boolean indicating if the segwit is supported
|
|
201
|
+
* @param hasTimestamp is a boolean (peercoin includes timestamp in their transactions, others don't)
|
|
202
|
+
* @param hasExtraData is a boolean (komodo, zencash and zcash include extraData in their transactions, others don't)
|
|
203
|
+
* @param additionals list of additionnal options
|
|
204
|
+
* @return the transaction object deserialized from the raw hexadecimal transaction
|
|
190
205
|
* @example
|
|
191
206
|
const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
|
|
192
207
|
*/
|
|
@@ -194,16 +209,25 @@ class Btc {
|
|
|
194
209
|
return (0, splitTransaction_1.splitTransaction)(transactionHex, isSegwitSupported, hasTimestamp, hasExtraData, additionals);
|
|
195
210
|
}
|
|
196
211
|
/**
|
|
197
|
-
|
|
212
|
+
* Serialize a transaction's outputs to hexadecimal
|
|
213
|
+
* @example
|
|
198
214
|
const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
|
|
199
215
|
const outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');
|
|
200
216
|
*/
|
|
201
217
|
serializeTransactionOutputs(t) {
|
|
202
218
|
return (0, serializeTransaction_1.serializeTransactionOutputs)(t);
|
|
203
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Trusted input is the hash of a UTXO that needs to be signed
|
|
222
|
+
* For Legacy transactions, the app has some APDUs flows that do the amount check for an UTXO,
|
|
223
|
+
* by parsing the transaction that created this UTXO
|
|
224
|
+
*/
|
|
204
225
|
getTrustedInput(indexLookup, transaction, additionals = []) {
|
|
205
226
|
return (0, getTrustedInput_1.getTrustedInput)(this._transport, indexLookup, transaction, additionals);
|
|
206
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Trusted input is the hash of a UTXO that needs to be signed. BIP143 is used for Segwit inputs.
|
|
230
|
+
*/
|
|
207
231
|
getTrustedInputBIP143(indexLookup, transaction, additionals = []) {
|
|
208
232
|
return (0, getTrustedInputBIP143_1.getTrustedInputBIP143)(this._transport, indexLookup, transaction, additionals);
|
|
209
233
|
}
|
package/lib/Btc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Btc.js","sourceRoot":"","sources":["../src/Btc.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oDAA4B;AAE5B,sDAA8B;AAC9B,sDAA8B;AAE9B,uDAAoD;AACpD,mEAAgE;AAEhE,kDAA+C;AAC/C,iEAAqE;AAErE,yDAAsD;AAGtD,+DAA4D;AAC5D,yDAAwE;AAExE
|
|
1
|
+
{"version":3,"file":"Btc.js","sourceRoot":"","sources":["../src/Btc.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oDAA4B;AAE5B,sDAA8B;AAC9B,sDAA8B;AAE9B,uDAAoD;AACpD,mEAAgE;AAEhE,kDAA+C;AAC/C,iEAAqE;AAErE,yDAAsD;AAGtD,+DAA4D;AAC5D,yDAAwE;AAExE;;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;wBACT,uEAAuE;wBACvE,OAAO,gBAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;oBACrC;wBACE,OAAO,IAAI,CAAC;iBACf;YACH,CAAC,CAAA,CAAC,EAAE,CAAC;YAEL,IAAI,WAAW,EAAE;gBACf,IAAI,CAAC,KAAK,GAAG,IAAI,gBAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;aAC1C;YACD,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;KAAA;CACF;AA9SD,sBA8SC"}
|
package/lib/BtcNew.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import type { CreateTransactionArg } from "./createTransaction";
|
|
|
2
2
|
import type { AddressFormat } from "./getWalletPublicKey";
|
|
3
3
|
import { AppClient as Client } from "./newops/appClient";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* @class BtcNew
|
|
6
|
+
* @description This class implements the same interface as BtcOld (formerly
|
|
7
|
+
* named Btc), but interacts with Bitcoin hardware app version 2.1.0+
|
|
7
8
|
* which uses a totally new APDU protocol. This new
|
|
8
9
|
* protocol is documented at
|
|
9
10
|
* https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md
|
|
@@ -13,6 +14,7 @@ import { AppClient as Client } from "./newops/appClient";
|
|
|
13
14
|
* input data into the PSBT process. In the future, a new interface should
|
|
14
15
|
* be developed that exposes PSBT to the outer world, which would render
|
|
15
16
|
* a much cleaner implementation.
|
|
17
|
+
*
|
|
16
18
|
*/
|
|
17
19
|
export default class BtcNew {
|
|
18
20
|
private client;
|
package/lib/BtcNew.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BtcNew.d.ts","sourceRoot":"","sources":["../src/BtcNew.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,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E,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IAiBF;;;;;;;OAOG;YACW,cAAc;IAoB5B;;;;OAIG;YACW,QAAQ;IAuCtB;;;;;;;;OAQG;YACW,QAAQ;CA6BvB;AA4ED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CA8BlD"}
|
package/lib/BtcNew.js
CHANGED
|
@@ -21,8 +21,9 @@ const psbtFinalizer_1 = require("./newops/psbtFinalizer");
|
|
|
21
21
|
const psbtv2_1 = require("./newops/psbtv2");
|
|
22
22
|
const serializeTransaction_1 = require("./serializeTransaction");
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* @class BtcNew
|
|
25
|
+
* @description This class implements the same interface as BtcOld (formerly
|
|
26
|
+
* named Btc), but interacts with Bitcoin hardware app version 2.1.0+
|
|
26
27
|
* which uses a totally new APDU protocol. This new
|
|
27
28
|
* protocol is documented at
|
|
28
29
|
* https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md
|
|
@@ -32,6 +33,7 @@ const serializeTransaction_1 = require("./serializeTransaction");
|
|
|
32
33
|
* input data into the PSBT process. In the future, a new interface should
|
|
33
34
|
* be developed that exposes PSBT to the outer world, which would render
|
|
34
35
|
* a much cleaner implementation.
|
|
36
|
+
*
|
|
35
37
|
*/
|
|
36
38
|
class BtcNew {
|
|
37
39
|
constructor(client) {
|
|
@@ -347,6 +349,11 @@ class BtcNew {
|
|
|
347
349
|
}
|
|
348
350
|
}
|
|
349
351
|
exports.default = BtcNew;
|
|
352
|
+
/**
|
|
353
|
+
* This function returns a descriptor template based on the address format.
|
|
354
|
+
* See https://github.com/LedgerHQ/app-bitcoin-new/blob/develop/doc/wallet.md for details of
|
|
355
|
+
* the bitcoin descriptor template.
|
|
356
|
+
*/
|
|
350
357
|
function descrTemplFrom(addressFormat) {
|
|
351
358
|
if (addressFormat == "legacy")
|
|
352
359
|
return "pkh(@0)";
|