@ledgerhq/hw-app-btc 6.25.1-alpha.3 → 6.27.2-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.
Files changed (50) hide show
  1. package/.turbo/turbo-build.log +6 -0
  2. package/CHANGELOG.md +10 -0
  3. package/jest.config.ts +6 -0
  4. package/lib/Btc.js +5 -1
  5. package/lib/Btc.js.map +1 -1
  6. package/lib/bip32.d.ts.map +1 -1
  7. package/lib/bip32.js.map +1 -1
  8. package/lib/getTrustedInput.d.ts.map +1 -1
  9. package/lib/getTrustedInput.js.map +1 -1
  10. package/lib/newops/appClient.d.ts.map +1 -1
  11. package/lib/newops/appClient.js +1 -4
  12. package/lib/newops/appClient.js.map +1 -1
  13. package/lib/newops/psbtv2.d.ts.map +1 -1
  14. package/lib/newops/psbtv2.js.map +1 -1
  15. package/lib-es/bip32.d.ts.map +1 -1
  16. package/lib-es/bip32.js.map +1 -1
  17. package/lib-es/getTrustedInput.d.ts.map +1 -1
  18. package/lib-es/getTrustedInput.js.map +1 -1
  19. package/lib-es/newops/appClient.d.ts.map +1 -1
  20. package/lib-es/newops/appClient.js +1 -4
  21. package/lib-es/newops/appClient.js.map +1 -1
  22. package/lib-es/newops/psbtv2.d.ts.map +1 -1
  23. package/lib-es/newops/psbtv2.js.map +1 -1
  24. package/package.json +16 -7
  25. package/src/bip32.ts +5 -3
  26. package/src/getTrustedInput.ts +2 -8
  27. package/src/newops/appClient.ts +8 -4
  28. package/src/newops/psbtv2.ts +13 -9
  29. package/LICENSE +0 -202
  30. package/lib-es/Btc.js.flow +0 -280
  31. package/lib-es/bip32.js.flow +0 -13
  32. package/lib-es/compressPublicKey.js.flow +0 -8
  33. package/lib-es/constants.js.flow +0 -13
  34. package/lib-es/createTransaction.js.flow +0 -419
  35. package/lib-es/debug.js.flow +0 -41
  36. package/lib-es/finalizeInput.js.flow +0 -38
  37. package/lib-es/getAppAndVersion.js.flow +0 -19
  38. package/lib-es/getTrustedInput.js.flow +0 -163
  39. package/lib-es/getTrustedInputBIP143.js.flow +0 -37
  40. package/lib-es/getWalletPublicKey.js.flow +0 -51
  41. package/lib-es/hashPublicKey.js.flow +0 -8
  42. package/lib-es/serializeTransaction.js.flow +0 -77
  43. package/lib-es/shouldUseTrustedInputForSegwit.js.flow +0 -15
  44. package/lib-es/signMessage.js.flow +0 -67
  45. package/lib-es/signP2SHTransaction.js.flow +0 -170
  46. package/lib-es/signTransaction.js.flow +0 -40
  47. package/lib-es/splitTransaction.js.flow +0 -145
  48. package/lib-es/startUntrustedHashTransactionInput.js.flow +0 -136
  49. package/lib-es/types.js.flow +0 -31
  50. package/lib-es/varint.js.flow +0 -43
@@ -427,9 +427,10 @@ export class PsbtV2 {
427
427
  this.writeBip32Derivation(buf, masterFingerprint, path);
428
428
  return buf.buffer();
429
429
  }
430
- private decodeBip32Derivation(
431
- buffer: Buffer
432
- ): { masterFingerprint: Buffer; path: number[] } {
430
+ private decodeBip32Derivation(buffer: Buffer): {
431
+ masterFingerprint: Buffer;
432
+ path: number[];
433
+ } {
433
434
  const buf = new BufferReader(buffer);
434
435
  return this.readBip32Derivation(buf);
435
436
  }
@@ -443,9 +444,10 @@ export class PsbtV2 {
443
444
  buf.writeUInt32(element);
444
445
  });
445
446
  }
446
- private readBip32Derivation(
447
- buf: BufferReader
448
- ): { masterFingerprint: Buffer; path: number[] } {
447
+ private readBip32Derivation(buf: BufferReader): {
448
+ masterFingerprint: Buffer;
449
+ path: number[];
450
+ } {
449
451
  const masterFingerprint = buf.readSlice(4);
450
452
  const path: number[] = [];
451
453
  while (buf.offset < buf.buffer.length) {
@@ -466,9 +468,11 @@ export class PsbtV2 {
466
468
  this.writeBip32Derivation(buf, masterFingerprint, path);
467
469
  return buf.buffer();
468
470
  }
469
- private decodeTapBip32Derivation(
470
- buffer: Buffer
471
- ): { hashes: Buffer[]; masterFingerprint: Buffer; path: number[] } {
471
+ private decodeTapBip32Derivation(buffer: Buffer): {
472
+ hashes: Buffer[];
473
+ masterFingerprint: Buffer;
474
+ path: number[];
475
+ } {
472
476
  const buf = new BufferReader(buffer);
473
477
  const hashCount = buf.readVarInt();
474
478
  const hashes: Buffer[] = [];
package/LICENSE DELETED
@@ -1,202 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "{}"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright {yyyy} {name of copyright owner}
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
202
-
@@ -1,280 +0,0 @@
1
- //@flow
2
- import type Transport from "@ledgerhq/hw-transport";
3
- import { signMessage } from "./signMessage";
4
- import { getWalletPublicKey } from "./getWalletPublicKey";
5
- import type { AddressFormat } from "./getWalletPublicKey";
6
- import { splitTransaction } from "./splitTransaction";
7
- import { getTrustedInput } from "./getTrustedInput";
8
- import { getTrustedInputBIP143 } from "./getTrustedInputBIP143";
9
- import type { Transaction } from "./types";
10
- import { createTransaction } from "./createTransaction";
11
- import type { CreateTransactionArg } from "./createTransaction";
12
- import { signP2SHTransaction } from "./signP2SHTransaction";
13
- import type { SignP2SHTransactionArg } from "./signP2SHTransaction";
14
- import { serializeTransactionOutputs } from "./serializeTransaction";
15
-
16
- export type { AddressFormat };
17
-
18
- /**
19
- * Bitcoin API.
20
- *
21
- * @example
22
- * import Btc from "@ledgerhq/hw-app-btc";
23
- * const btc = new Btc(transport)
24
- */
25
- export default class Btc {
26
- transport: Transport<*>;
27
-
28
- constructor(transport: Transport<*>, scrambleKey: string = "BTC") {
29
- this.transport = transport;
30
- transport.decorateAppAPIMethods(
31
- this,
32
- [
33
- "getWalletPublicKey",
34
- "signP2SHTransaction",
35
- "signMessageNew",
36
- "createPaymentTransactionNew",
37
- "getTrustedInput",
38
- "getTrustedInputBIP143",
39
- ],
40
- scrambleKey
41
- );
42
- }
43
-
44
- /**
45
- * @param path a BIP 32 path
46
- * @param options an object with optional these fields:
47
- *
48
- * - verify (boolean) will ask user to confirm the address on the device
49
- *
50
- * - format ("legacy" | "p2sh" | "bech32" | "cashaddr") to use different bitcoin address formatter.
51
- *
52
- * NB The normal usage is to use:
53
- *
54
- * - legacy format with 44' paths
55
- *
56
- * - p2sh format with 49' paths
57
- *
58
- * - bech32 format with 173' paths
59
- *
60
- * - cashaddr in case of Bitcoin Cash
61
- *
62
- * @example
63
- * btc.getWalletPublicKey("44'/0'/0'/0/0").then(o => o.bitcoinAddress)
64
- * btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinAddress)
65
- */
66
- getWalletPublicKey(
67
- path: string,
68
- opts?: boolean | { verify?: boolean, format?: AddressFormat }
69
- ): Promise<{
70
- publicKey: string,
71
- bitcoinAddress: string,
72
- chainCode: string,
73
- }> {
74
- let options;
75
- if (arguments.length > 2 || typeof opts === "boolean") {
76
- console.warn(
77
- "btc.getWalletPublicKey deprecated signature used. Please switch to getWalletPublicKey(path, { format, verify })"
78
- );
79
- options = {
80
- verify: !!opts,
81
- format: arguments[2] ? "p2sh" : "legacy",
82
- };
83
- } else {
84
- options = opts || {};
85
- }
86
- return getWalletPublicKey(this.transport, { ...options, path });
87
- }
88
-
89
- /**
90
- * 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.
91
- * @example
92
- btc.signMessageNew_async("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
93
- var v = result['v'] + 27 + 4;
94
- var signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');
95
- console.log("Signature : " + signature);
96
- }).catch(function(ex) {console.log(ex);});
97
- */
98
- signMessageNew(
99
- path: string,
100
- messageHex: string
101
- ): Promise<{ v: number, r: string, s: string }> {
102
- return signMessage(this.transport, { path, messageHex });
103
- }
104
-
105
- /**
106
- * To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
107
- * @param inputs is an array of [ transaction, output_index, optional redeem script, optional sequence ] where
108
- *
109
- * * transaction is the previously computed transaction object for this UTXO
110
- * * output_index is the output in the transaction used as input for this UTXO (counting from 0)
111
- * * redeem script is the optional redeem script to use when consuming a Segregated Witness input
112
- * * sequence is the sequence number to use for this input (when using RBF), or non present
113
- * @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
114
- * @param changePath is an optional BIP 32 path pointing to the path to the public key used to compute the change address
115
- * @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign
116
- * @param lockTime is the optional lockTime of the transaction to sign, or default (0)
117
- * @param sigHashType is the hash type of the transaction to sign, or default (all)
118
- * @param segwit is an optional boolean indicating wether to use segwit or not
119
- * @param initialTimestamp is an optional timestamp of the function call to use for coins that necessitate timestamps only, (not the one that the tx will include)
120
- * @param additionals list of additionnal options
121
- *
122
- * - "bech32" for spending native segwit outputs
123
- * - "abc" for bch
124
- * - "gold" for btg
125
- * - "bipxxx" for using BIPxxx
126
- * - "sapling" to indicate a zec transaction is supporting sapling (to be set over block 419200)
127
- * @param expiryHeight is an optional Buffer for zec overwinter / sapling Txs
128
- * @param useTrustedInputForSegwit trust inputs for segwit transactions
129
- * @return the signed transaction ready to be broadcast
130
- * @example
131
- btc.createTransaction({
132
- inputs: [ [tx1, 1] ],
133
- associatedKeysets: ["0'/0/0"],
134
- outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
135
- }).then(res => ...);
136
- */
137
- createPaymentTransactionNew(arg: CreateTransactionArg) {
138
- if (arguments.length > 1) {
139
- console.warn(
140
- "@ledgerhq/hw-app-btc: createPaymentTransactionNew multi argument signature is deprecated. please switch to named parameters."
141
- );
142
- arg = fromDeprecateArguments(arguments, [
143
- "inputs",
144
- "associatedKeysets",
145
- "changePath",
146
- "outputScriptHex",
147
- "lockTime",
148
- "sigHashType",
149
- "segwit",
150
- "initialTimestamp",
151
- "additionals",
152
- "expiryHeight",
153
- "useTrustedInputForSegwit",
154
- ]);
155
- }
156
- return createTransaction(this.transport, arg);
157
- }
158
-
159
- /**
160
- * To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters
161
- * @param inputs is an array of [ transaction, output_index, redeem script, optional sequence ] where
162
- * * transaction is the previously computed transaction object for this UTXO
163
- * * output_index is the output in the transaction used as input for this UTXO (counting from 0)
164
- * * redeem script is the mandatory redeem script associated to the current P2SH input
165
- * * sequence is the sequence number to use for this input (when using RBF), or non present
166
- * @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
167
- * @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign
168
- * @param lockTime is the optional lockTime of the transaction to sign, or default (0)
169
- * @param sigHashType is the hash type of the transaction to sign, or default (all)
170
- * @return the signed transaction ready to be broadcast
171
- * @example
172
- btc.signP2SHTransaction({
173
- inputs: [ [tx, 1, "52210289b4a3ad52a919abd2bdd6920d8a6879b1e788c38aa76f0440a6f32a9f1996d02103a3393b1439d1693b063482c04bd40142db97bdf139eedd1b51ffb7070a37eac321030b9a409a1e476b0d5d17b804fcdb81cf30f9b99c6f3ae1178206e08bc500639853ae"] ],
174
- associatedKeysets: ["0'/0/0"],
175
- outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
176
- }).then(result => ...);
177
- */
178
- signP2SHTransaction(arg: SignP2SHTransactionArg) {
179
- if (arguments.length > 1) {
180
- console.warn(
181
- "@ledgerhq/hw-app-btc: signP2SHTransaction multi argument signature is deprecated. please switch to named parameters."
182
- );
183
- const [
184
- inputs,
185
- associatedKeysets,
186
- outputScriptHex,
187
- lockTime,
188
- sigHashType,
189
- segwit,
190
- transactionVersion,
191
- ] = arguments;
192
- arg = {
193
- inputs,
194
- associatedKeysets,
195
- outputScriptHex,
196
- lockTime,
197
- sigHashType,
198
- segwit,
199
- transactionVersion,
200
- };
201
- arg = fromDeprecateArguments(arguments, [
202
- "inputs",
203
- "associatedKeysets",
204
- "outputScriptHex",
205
- "lockTime",
206
- "sigHashType",
207
- "segwit",
208
- "transactionVersion",
209
- ]);
210
- }
211
- return signP2SHTransaction(this.transport, arg);
212
- }
213
-
214
- /**
215
- * For each UTXO included in your transaction, create a transaction object from the raw serialized version of the transaction used in this UTXO.
216
- * @example
217
- const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
218
- */
219
- splitTransaction(
220
- transactionHex: string,
221
- isSegwitSupported: ?boolean = false,
222
- hasTimestamp?: boolean = false,
223
- hasExtraData?: boolean = false,
224
- additionals: Array<string> = []
225
- ): Transaction {
226
- return splitTransaction(
227
- transactionHex,
228
- isSegwitSupported,
229
- hasTimestamp,
230
- hasExtraData,
231
- additionals
232
- );
233
- }
234
-
235
- /**
236
- @example
237
- const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
238
- const outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');
239
- */
240
- serializeTransactionOutputs(t: Transaction): Buffer {
241
- return serializeTransactionOutputs(t);
242
- }
243
-
244
- getTrustedInput(
245
- indexLookup: number,
246
- transaction: Transaction,
247
- additionals: Array<string> = []
248
- ): Promise<string> {
249
- return getTrustedInput(
250
- this.transport,
251
- indexLookup,
252
- transaction,
253
- additionals
254
- );
255
- }
256
-
257
- getTrustedInputBIP143(
258
- indexLookup: number,
259
- transaction: Transaction,
260
- additionals: Array<string> = []
261
- ): string {
262
- return getTrustedInputBIP143(
263
- this.transport,
264
- indexLookup,
265
- transaction,
266
- additionals
267
- );
268
- }
269
- }
270
-
271
- function fromDeprecateArguments(args, keys) {
272
- const obj = {};
273
- keys.forEach((key, i) => {
274
- const value = args[i];
275
- if (value !== undefined) {
276
- obj[key] = value;
277
- }
278
- });
279
- return obj;
280
- }
@@ -1,13 +0,0 @@
1
- // @flow
2
-
3
- import bippath from "bip32-path";
4
-
5
- export function bip32asBuffer(path: string): Buffer {
6
- const paths = !path ? [] : bippath.fromString(path).toPathArray();
7
- let buffer = Buffer.alloc(1 + paths.length * 4);
8
- buffer[0] = paths.length;
9
- paths.forEach((element, index) => {
10
- buffer.writeUInt32BE(element, 1 + 4 * index);
11
- });
12
- return buffer;
13
- }
@@ -1,8 +0,0 @@
1
- // @flow
2
-
3
- export function compressPublicKey(publicKey: Buffer): Buffer {
4
- const prefix = (publicKey[64] & 1) !== 0 ? 0x03 : 0x02;
5
- const prefixBuffer = Buffer.alloc(1);
6
- prefixBuffer[0] = prefix;
7
- return Buffer.concat([prefixBuffer, publicKey.slice(1, 1 + 32)]);
8
- }
@@ -1,13 +0,0 @@
1
- // flow
2
-
3
- export const MAX_SCRIPT_BLOCK = 50;
4
- export const DEFAULT_VERSION = 1;
5
- export const DEFAULT_LOCKTIME = 0;
6
- export const DEFAULT_SEQUENCE = 0xffffffff;
7
- export const SIGHASH_ALL = 1;
8
- export const OP_DUP = 0x76;
9
- export const OP_HASH160 = 0xa9;
10
- export const HASH_SIZE = 0x14;
11
- export const OP_EQUALVERIFY = 0x88;
12
- export const OP_CHECKSIG = 0xac;
13
- export const OP_RETURN = 0x6a;