@ledgerhq/hw-app-btc 9.0.0-nightly.4 → 9.0.1-nightly.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +7 -16
- package/README.md +111 -33
- package/lib/Btc.d.ts +13 -11
- package/lib/Btc.d.ts.map +1 -1
- package/lib/Btc.js +191 -31
- 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 +13 -54
- package/lib/BtcNew.js.map +1 -1
- package/lib/BtcOld.d.ts +37 -2
- package/lib/BtcOld.d.ts.map +1 -1
- package/lib/BtcOld.js +45 -3
- package/lib/BtcOld.js.map +1 -1
- package/lib-es/Btc.d.ts +13 -11
- package/lib-es/Btc.d.ts.map +1 -1
- package/lib-es/Btc.js +168 -31
- 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 +8 -54
- package/lib-es/BtcNew.js.map +1 -1
- package/lib-es/BtcOld.d.ts +37 -2
- package/lib-es/BtcOld.d.ts.map +1 -1
- package/lib-es/BtcOld.js +45 -3
- package/lib-es/BtcOld.js.map +1 -1
- package/package.json +7 -7
- package/src/Btc.ts +151 -41
- package/src/BtcNew.ts +15 -60
- package/src/BtcOld.ts +59 -4
- package/tests/Btc.test.ts +132 -16
- package/tests/newops/BtcNew.test.ts +5 -0
- package/tests/newops/integrationtools.ts +4 -4
- package/tests/parseTx.test.ts +1 -1
- package/tests/trustedInputs.test.ts +8 -6
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @ledgerhq/hw-app-btc@9.0.0
|
|
2
|
+
> @ledgerhq/hw-app-btc@9.0.0 build /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/hw-app-btc
|
|
3
3
|
> tsc && tsc -m ES6 --outDir lib-es
|
|
4
4
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
# @ledgerhq/hw-app-btc
|
|
2
2
|
|
|
3
|
-
## 9.0.
|
|
3
|
+
## 9.0.1-nightly.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- Updated dependencies []:
|
|
8
|
-
- @ledgerhq/hw-transport@6.27.
|
|
8
|
+
- @ledgerhq/hw-transport@6.27.8-nightly.0
|
|
9
9
|
|
|
10
|
-
## 9.0.0
|
|
10
|
+
## 9.0.0
|
|
11
11
|
|
|
12
12
|
### Patch Changes
|
|
13
13
|
|
|
14
|
-
- Updated dependencies []:
|
|
15
|
-
- @ledgerhq/hw-transport@6.27.7
|
|
14
|
+
- Updated dependencies [[`d3c91a53e0`](https://github.com/LedgerHQ/ledger-live/commit/d3c91a53e06f9f47817e96c452f69e2d9f71d80f)]:
|
|
15
|
+
- @ledgerhq/hw-transport@6.27.7
|
|
16
16
|
|
|
17
|
-
## 9.0.0-
|
|
17
|
+
## 9.0.0-next.0
|
|
18
18
|
|
|
19
19
|
### Major Changes
|
|
20
20
|
|
|
21
21
|
- [#1493](https://github.com/LedgerHQ/ledger-live/pull/1493) [`658303322b`](https://github.com/LedgerHQ/ledger-live/commit/658303322b767f5ed3821def8384b5342ab03089) 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)
|
|
22
22
|
|
|
23
|
-
## 8.1.2-nightly.1
|
|
24
|
-
|
|
25
23
|
### Patch Changes
|
|
26
24
|
|
|
27
25
|
- Updated dependencies [[`d3c91a53e0`](https://github.com/LedgerHQ/ledger-live/commit/d3c91a53e06f9f47817e96c452f69e2d9f71d80f)]:
|
|
28
|
-
- @ledgerhq/hw-transport@6.27.7-
|
|
29
|
-
|
|
30
|
-
## 8.1.2-nightly.0
|
|
31
|
-
|
|
32
|
-
### Patch Changes
|
|
33
|
-
|
|
34
|
-
- Updated dependencies []:
|
|
35
|
-
- @ledgerhq/hw-transport@6.27.7-nightly.0
|
|
26
|
+
- @ledgerhq/hw-transport@6.27.7-next.0
|
|
36
27
|
|
|
37
28
|
## 8.1.1
|
|
38
29
|
|
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
|
-
* [
|
|
38
|
+
* [signMessageNew](#signmessagenew)
|
|
39
39
|
* [Parameters](#parameters-3)
|
|
40
40
|
* [Examples](#examples-2)
|
|
41
|
-
* [
|
|
41
|
+
* [createPaymentTransactionNew](#createpaymenttransactionnew)
|
|
42
42
|
* [Parameters](#parameters-4)
|
|
43
43
|
* [Examples](#examples-3)
|
|
44
44
|
* [signP2SHTransaction](#signp2shtransaction)
|
|
@@ -50,13 +50,14 @@ For a smooth and quick integration:
|
|
|
50
50
|
* [serializeTransactionOutputs](#serializetransactionoutputs)
|
|
51
51
|
* [Parameters](#parameters-7)
|
|
52
52
|
* [Examples](#examples-6)
|
|
53
|
+
* [impl](#impl)
|
|
53
54
|
* [BtcNew](#btcnew)
|
|
54
55
|
* [Parameters](#parameters-8)
|
|
55
56
|
* [getWalletXpub](#getwalletxpub-1)
|
|
56
57
|
* [Parameters](#parameters-9)
|
|
57
58
|
* [getWalletPublicKey](#getwalletpublickey-1)
|
|
58
59
|
* [Parameters](#parameters-10)
|
|
59
|
-
* [
|
|
60
|
+
* [createPaymentTransactionNew](#createpaymenttransactionnew-1)
|
|
60
61
|
* [Parameters](#parameters-11)
|
|
61
62
|
* [BtcOld](#btcold)
|
|
62
63
|
* [Parameters](#parameters-12)
|
|
@@ -64,47 +65,53 @@ For a smooth and quick integration:
|
|
|
64
65
|
* [getWalletPublicKey](#getwalletpublickey-2)
|
|
65
66
|
* [Parameters](#parameters-13)
|
|
66
67
|
* [Examples](#examples-8)
|
|
67
|
-
* [
|
|
68
|
+
* [signMessageNew](#signmessagenew-1)
|
|
68
69
|
* [Parameters](#parameters-14)
|
|
69
70
|
* [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)
|
|
70
77
|
* [CreateTransactionArg](#createtransactionarg)
|
|
71
78
|
* [Properties](#properties)
|
|
72
79
|
* [AddressFormat](#addressformat)
|
|
73
80
|
* [AccountType](#accounttype)
|
|
74
81
|
* [spendingCondition](#spendingcondition)
|
|
75
|
-
* [Parameters](#parameters-
|
|
82
|
+
* [Parameters](#parameters-17)
|
|
76
83
|
* [setInput](#setinput)
|
|
77
|
-
* [Parameters](#parameters-
|
|
84
|
+
* [Parameters](#parameters-18)
|
|
78
85
|
* [setOwnOutput](#setownoutput)
|
|
79
|
-
* [Parameters](#parameters-
|
|
86
|
+
* [Parameters](#parameters-19)
|
|
80
87
|
* [getDescriptorTemplate](#getdescriptortemplate)
|
|
81
88
|
* [SingleKeyAccount](#singlekeyaccount)
|
|
82
89
|
* [getTaprootOutputKey](#gettaprootoutputkey)
|
|
83
|
-
* [Parameters](#parameters-
|
|
90
|
+
* [Parameters](#parameters-20)
|
|
84
91
|
* [AppClient](#appclient)
|
|
85
|
-
* [Parameters](#parameters-
|
|
92
|
+
* [Parameters](#parameters-21)
|
|
86
93
|
* [ClientCommandInterpreter](#clientcommandinterpreter)
|
|
87
|
-
* [Parameters](#parameters-
|
|
94
|
+
* [Parameters](#parameters-22)
|
|
88
95
|
* [MerkelizedPsbt](#merkelizedpsbt)
|
|
89
|
-
* [Parameters](#parameters-
|
|
96
|
+
* [Parameters](#parameters-23)
|
|
90
97
|
* [Merkle](#merkle)
|
|
91
|
-
* [Parameters](#parameters-
|
|
98
|
+
* [Parameters](#parameters-24)
|
|
92
99
|
* [MerkleMap](#merklemap)
|
|
93
|
-
* [Parameters](#parameters-
|
|
100
|
+
* [Parameters](#parameters-25)
|
|
94
101
|
* [WalletPolicy](#walletpolicy)
|
|
95
|
-
* [Parameters](#parameters-
|
|
102
|
+
* [Parameters](#parameters-26)
|
|
96
103
|
* [extract](#extract)
|
|
97
|
-
* [Parameters](#parameters-
|
|
104
|
+
* [Parameters](#parameters-27)
|
|
98
105
|
* [finalize](#finalize)
|
|
99
|
-
* [Parameters](#parameters-
|
|
106
|
+
* [Parameters](#parameters-28)
|
|
100
107
|
* [clearFinalizedInput](#clearfinalizedinput)
|
|
101
|
-
* [Parameters](#parameters-
|
|
108
|
+
* [Parameters](#parameters-29)
|
|
102
109
|
* [writePush](#writepush)
|
|
103
|
-
* [Parameters](#parameters-
|
|
110
|
+
* [Parameters](#parameters-30)
|
|
104
111
|
* [PsbtV2](#psbtv2)
|
|
105
112
|
* [serializeTransactionOutputs](#serializetransactionoutputs-1)
|
|
106
|
-
* [Parameters](#parameters-
|
|
107
|
-
* [Examples](#examples-
|
|
113
|
+
* [Parameters](#parameters-31)
|
|
114
|
+
* [Examples](#examples-12)
|
|
108
115
|
* [SignP2SHTransactionArg](#signp2shtransactionarg)
|
|
109
116
|
* [Properties](#properties-1)
|
|
110
117
|
* [TransactionInput](#transactioninput)
|
|
@@ -117,17 +124,14 @@ Bitcoin API.
|
|
|
117
124
|
|
|
118
125
|
#### Parameters
|
|
119
126
|
|
|
120
|
-
*
|
|
121
|
-
|
|
122
|
-
* `$0.transport`
|
|
123
|
-
* `$0.scrambleKey` (optional, default `"BTC"`)
|
|
124
|
-
* `$0.currency` (optional, default `"bitcoin"`)
|
|
127
|
+
* `transport` **Transport**
|
|
128
|
+
* `scrambleKey` (optional, default `"BTC"`)
|
|
125
129
|
|
|
126
130
|
#### Examples
|
|
127
131
|
|
|
128
132
|
```javascript
|
|
129
133
|
import Btc from "@ledgerhq/hw-app-btc";
|
|
130
|
-
const btc = new Btc(
|
|
134
|
+
const btc = new Btc(transport)
|
|
131
135
|
```
|
|
132
136
|
|
|
133
137
|
#### getWalletXpub
|
|
@@ -166,7 +170,7 @@ btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinA
|
|
|
166
170
|
|
|
167
171
|
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)}>**
|
|
168
172
|
|
|
169
|
-
####
|
|
173
|
+
#### signMessageNew
|
|
170
174
|
|
|
171
175
|
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.
|
|
172
176
|
|
|
@@ -178,7 +182,7 @@ You can sign a message according to the Bitcoin Signature format and retrieve v,
|
|
|
178
182
|
##### Examples
|
|
179
183
|
|
|
180
184
|
```javascript
|
|
181
|
-
btc.
|
|
185
|
+
btc.signMessageNew_async("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
|
|
182
186
|
var v = result['v'] + 27 + 4;
|
|
183
187
|
var signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');
|
|
184
188
|
console.log("Signature : " + signature);
|
|
@@ -187,7 +191,7 @@ console.log("Signature : " + signature);
|
|
|
187
191
|
|
|
188
192
|
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)}>**
|
|
189
193
|
|
|
190
|
-
####
|
|
194
|
+
#### createPaymentTransactionNew
|
|
191
195
|
|
|
192
196
|
To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
|
|
193
197
|
|
|
@@ -289,6 +293,31 @@ const outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');
|
|
|
289
293
|
|
|
290
294
|
Returns **[Buffer](https://nodejs.org/api/buffer.html)**
|
|
291
295
|
|
|
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
|
+
|
|
292
321
|
### BtcNew
|
|
293
322
|
|
|
294
323
|
This class implements the same interface as BtcOld (formerly
|
|
@@ -362,9 +391,9 @@ will be the empty string "", see this.getWalletAddress() for details.
|
|
|
362
391
|
|
|
363
392
|
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)}>**
|
|
364
393
|
|
|
365
|
-
####
|
|
394
|
+
#### createPaymentTransactionNew
|
|
366
395
|
|
|
367
|
-
Build and sign a transaction. See Btc.
|
|
396
|
+
Build and sign a transaction. See Btc.createPaymentTransactionNew for
|
|
368
397
|
details on how to use this method.
|
|
369
398
|
|
|
370
399
|
This method will convert the legacy arguments, CreateTransactionArg, into
|
|
@@ -389,7 +418,7 @@ Bitcoin API.
|
|
|
389
418
|
|
|
390
419
|
```javascript
|
|
391
420
|
import Btc from "@ledgerhq/hw-app-btc";
|
|
392
|
-
const btc = new Btc(
|
|
421
|
+
const btc = new Btc(transport)
|
|
393
422
|
```
|
|
394
423
|
|
|
395
424
|
#### getWalletPublicKey
|
|
@@ -417,7 +446,28 @@ btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinA
|
|
|
417
446
|
|
|
418
447
|
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)}>**
|
|
419
448
|
|
|
420
|
-
####
|
|
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
|
|
421
471
|
|
|
422
472
|
To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
|
|
423
473
|
|
|
@@ -455,6 +505,34 @@ outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d
|
|
|
455
505
|
|
|
456
506
|
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
|
|
457
507
|
|
|
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
|
+
|
|
458
536
|
### CreateTransactionArg
|
|
459
537
|
|
|
460
538
|
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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type Transport from "@ledgerhq/hw-transport";
|
|
3
|
+
import BtcNew from "./BtcNew";
|
|
4
|
+
import BtcOld from "./BtcOld";
|
|
3
5
|
import type { CreateTransactionArg } from "./createTransaction";
|
|
4
6
|
import type { AddressFormat } from "./getWalletPublicKey";
|
|
5
7
|
import type { SignP2SHTransactionArg } from "./signP2SHTransaction";
|
|
@@ -10,16 +12,11 @@ export type { AddressFormat };
|
|
|
10
12
|
*
|
|
11
13
|
* @example
|
|
12
14
|
* import Btc from "@ledgerhq/hw-app-btc";
|
|
13
|
-
* const btc = new Btc(
|
|
15
|
+
* const btc = new Btc(transport)
|
|
14
16
|
*/
|
|
15
17
|
export default class Btc {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
constructor({ transport, scrambleKey, currency, }: {
|
|
19
|
-
transport: Transport;
|
|
20
|
-
scrambleKey?: string;
|
|
21
|
-
currency?: string;
|
|
22
|
-
});
|
|
18
|
+
transport: Transport;
|
|
19
|
+
constructor(transport: Transport, scrambleKey?: string);
|
|
23
20
|
/**
|
|
24
21
|
* Get an XPUB with a ledger device
|
|
25
22
|
* @param arg derivation parameter
|
|
@@ -64,13 +61,13 @@ export default class Btc {
|
|
|
64
61
|
/**
|
|
65
62
|
* 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.
|
|
66
63
|
* @example
|
|
67
|
-
btc.
|
|
64
|
+
btc.signMessageNew_async("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
|
|
68
65
|
var v = result['v'] + 27 + 4;
|
|
69
66
|
var signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');
|
|
70
67
|
console.log("Signature : " + signature);
|
|
71
68
|
}).catch(function(ex) {console.log(ex);});
|
|
72
69
|
*/
|
|
73
|
-
|
|
70
|
+
signMessageNew(path: string, messageHex: string): Promise<{
|
|
74
71
|
v: number;
|
|
75
72
|
r: string;
|
|
76
73
|
s: string;
|
|
@@ -108,7 +105,7 @@ export default class Btc {
|
|
|
108
105
|
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
109
106
|
}).then(res => ...);
|
|
110
107
|
*/
|
|
111
|
-
|
|
108
|
+
createPaymentTransactionNew(arg: CreateTransactionArg): Promise<string>;
|
|
112
109
|
/**
|
|
113
110
|
* To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters
|
|
114
111
|
* @param inputs is an array of [ transaction, output_index, redeem script, optional sequence ] where
|
|
@@ -143,5 +140,10 @@ export default class Btc {
|
|
|
143
140
|
serializeTransactionOutputs(t: Transaction): Buffer;
|
|
144
141
|
getTrustedInput(indexLookup: number, transaction: Transaction, additionals?: Array<string>): Promise<string>;
|
|
145
142
|
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;
|
|
146
148
|
}
|
|
147
149
|
//# 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;
|
|
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"}
|