@ledgerhq/hw-app-btc 8.1.2-ts-llm.0 → 9.0.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.
- package/CHANGELOG.md +7 -3
- package/README.md +33 -111
- package/lib/Btc.d.ts +11 -13
- package/lib/Btc.d.ts.map +1 -1
- package/lib/Btc.js +31 -191
- package/lib/Btc.js.map +1 -1
- package/lib/BtcNew.d.ts +2 -4
- package/lib/BtcNew.d.ts.map +1 -1
- package/lib/BtcNew.js +54 -13
- package/lib/BtcNew.js.map +1 -1
- package/lib/BtcOld.d.ts +2 -37
- package/lib/BtcOld.d.ts.map +1 -1
- package/lib/BtcOld.js +3 -45
- package/lib/BtcOld.js.map +1 -1
- package/lib-es/Btc.d.ts +11 -13
- package/lib-es/Btc.d.ts.map +1 -1
- package/lib-es/Btc.js +31 -168
- package/lib-es/Btc.js.map +1 -1
- package/lib-es/BtcNew.d.ts +2 -4
- package/lib-es/BtcNew.d.ts.map +1 -1
- package/lib-es/BtcNew.js +54 -8
- package/lib-es/BtcNew.js.map +1 -1
- package/lib-es/BtcOld.d.ts +2 -37
- package/lib-es/BtcOld.d.ts.map +1 -1
- package/lib-es/BtcOld.js +3 -45
- package/lib-es/BtcOld.js.map +1 -1
- package/package.json +4 -4
- package/src/Btc.ts +41 -151
- package/src/BtcNew.ts +60 -15
- package/src/BtcOld.ts +4 -59
- package/tests/Btc.test.ts +16 -132
- package/tests/newops/BtcNew.test.ts +0 -5
- package/tests/newops/integrationtools.ts +4 -4
- package/tests/parseTx.test.ts +1 -1
- package/tests/trustedInputs.test.ts +6 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
# @ledgerhq/hw-app-btc
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 9.0.0-next.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#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)
|
|
4
8
|
|
|
5
9
|
### Patch Changes
|
|
6
10
|
|
|
7
|
-
- Updated dependencies []:
|
|
8
|
-
- @ledgerhq/hw-transport@6.27.7-
|
|
11
|
+
- Updated dependencies [[`d3c91a53e0`](https://github.com/LedgerHQ/ledger-live/commit/d3c91a53e06f9f47817e96c452f69e2d9f71d80f)]:
|
|
12
|
+
- @ledgerhq/hw-transport@6.27.7-next.0
|
|
9
13
|
|
|
10
14
|
## 8.1.1
|
|
11
15
|
|
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
|
+
* [signMessage](#signmessage)
|
|
39
39
|
* [Parameters](#parameters-3)
|
|
40
40
|
* [Examples](#examples-2)
|
|
41
|
-
* [
|
|
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
|
-
* [
|
|
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
|
-
* [
|
|
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-
|
|
75
|
+
* [Parameters](#parameters-15)
|
|
83
76
|
* [setInput](#setinput)
|
|
84
|
-
* [Parameters](#parameters-
|
|
77
|
+
* [Parameters](#parameters-16)
|
|
85
78
|
* [setOwnOutput](#setownoutput)
|
|
86
|
-
* [Parameters](#parameters-
|
|
79
|
+
* [Parameters](#parameters-17)
|
|
87
80
|
* [getDescriptorTemplate](#getdescriptortemplate)
|
|
88
81
|
* [SingleKeyAccount](#singlekeyaccount)
|
|
89
82
|
* [getTaprootOutputKey](#gettaprootoutputkey)
|
|
90
|
-
* [Parameters](#parameters-
|
|
83
|
+
* [Parameters](#parameters-18)
|
|
91
84
|
* [AppClient](#appclient)
|
|
92
|
-
* [Parameters](#parameters-
|
|
85
|
+
* [Parameters](#parameters-19)
|
|
93
86
|
* [ClientCommandInterpreter](#clientcommandinterpreter)
|
|
94
|
-
* [Parameters](#parameters-
|
|
87
|
+
* [Parameters](#parameters-20)
|
|
95
88
|
* [MerkelizedPsbt](#merkelizedpsbt)
|
|
96
|
-
* [Parameters](#parameters-
|
|
89
|
+
* [Parameters](#parameters-21)
|
|
97
90
|
* [Merkle](#merkle)
|
|
98
|
-
* [Parameters](#parameters-
|
|
91
|
+
* [Parameters](#parameters-22)
|
|
99
92
|
* [MerkleMap](#merklemap)
|
|
100
|
-
* [Parameters](#parameters-
|
|
93
|
+
* [Parameters](#parameters-23)
|
|
101
94
|
* [WalletPolicy](#walletpolicy)
|
|
102
|
-
* [Parameters](#parameters-
|
|
95
|
+
* [Parameters](#parameters-24)
|
|
103
96
|
* [extract](#extract)
|
|
104
|
-
* [Parameters](#parameters-
|
|
97
|
+
* [Parameters](#parameters-25)
|
|
105
98
|
* [finalize](#finalize)
|
|
106
|
-
* [Parameters](#parameters-
|
|
99
|
+
* [Parameters](#parameters-26)
|
|
107
100
|
* [clearFinalizedInput](#clearfinalizedinput)
|
|
108
|
-
* [Parameters](#parameters-
|
|
101
|
+
* [Parameters](#parameters-27)
|
|
109
102
|
* [writePush](#writepush)
|
|
110
|
-
* [Parameters](#parameters-
|
|
103
|
+
* [Parameters](#parameters-28)
|
|
111
104
|
* [PsbtV2](#psbtv2)
|
|
112
105
|
* [serializeTransactionOutputs](#serializetransactionoutputs-1)
|
|
113
|
-
* [Parameters](#parameters-
|
|
114
|
-
* [Examples](#examples-
|
|
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
|
|
128
|
-
|
|
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
|
-
####
|
|
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.
|
|
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
|
-
####
|
|
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
|
-
####
|
|
365
|
+
#### createPaymentTransaction
|
|
395
366
|
|
|
396
|
-
Build and sign a transaction. See Btc.
|
|
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
|
-
####
|
|
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
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type Transport from "@ledgerhq/hw-transport";
|
|
3
|
-
import BtcNew from "./BtcNew";
|
|
4
|
-
import BtcOld from "./BtcOld";
|
|
5
3
|
import type { CreateTransactionArg } from "./createTransaction";
|
|
6
4
|
import type { AddressFormat } from "./getWalletPublicKey";
|
|
7
5
|
import type { SignP2SHTransactionArg } from "./signP2SHTransaction";
|
|
@@ -12,11 +10,16 @@ export type { AddressFormat };
|
|
|
12
10
|
*
|
|
13
11
|
* @example
|
|
14
12
|
* import Btc from "@ledgerhq/hw-app-btc";
|
|
15
|
-
* const btc = new Btc(transport)
|
|
13
|
+
* const btc = new Btc({ transport, currency: "bitcoin" });
|
|
16
14
|
*/
|
|
17
15
|
export default class Btc {
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
private _transport;
|
|
17
|
+
private _impl;
|
|
18
|
+
constructor({ transport, scrambleKey, currency, }: {
|
|
19
|
+
transport: Transport;
|
|
20
|
+
scrambleKey?: string;
|
|
21
|
+
currency?: string;
|
|
22
|
+
});
|
|
20
23
|
/**
|
|
21
24
|
* Get an XPUB with a ledger device
|
|
22
25
|
* @param arg derivation parameter
|
|
@@ -61,13 +64,13 @@ export default class Btc {
|
|
|
61
64
|
/**
|
|
62
65
|
* 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
66
|
* @example
|
|
64
|
-
btc.
|
|
67
|
+
btc.signMessage("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
|
|
65
68
|
var v = result['v'] + 27 + 4;
|
|
66
69
|
var signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');
|
|
67
70
|
console.log("Signature : " + signature);
|
|
68
71
|
}).catch(function(ex) {console.log(ex);});
|
|
69
72
|
*/
|
|
70
|
-
|
|
73
|
+
signMessage(path: string, messageHex: string): Promise<{
|
|
71
74
|
v: number;
|
|
72
75
|
r: string;
|
|
73
76
|
s: string;
|
|
@@ -105,7 +108,7 @@ export default class Btc {
|
|
|
105
108
|
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
106
109
|
}).then(res => ...);
|
|
107
110
|
*/
|
|
108
|
-
|
|
111
|
+
createPaymentTransaction(arg: CreateTransactionArg): Promise<string>;
|
|
109
112
|
/**
|
|
110
113
|
* To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters
|
|
111
114
|
* @param inputs is an array of [ transaction, output_index, redeem script, optional sequence ] where
|
|
@@ -140,10 +143,5 @@ export default class Btc {
|
|
|
140
143
|
serializeTransactionOutputs(t: Transaction): Buffer;
|
|
141
144
|
getTrustedInput(indexLookup: number, transaction: Transaction, additionals?: Array<string>): Promise<string>;
|
|
142
145
|
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
146
|
}
|
|
149
147
|
//# 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;A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