@ledgerhq/hw-app-btc 6.24.2-monorepo.0 → 6.24.2-monorepo.4

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 (283) hide show
  1. package/.turbo/turbo-build.log +5 -1
  2. package/CHANGELOG.md +36 -0
  3. package/lib/Btc.d.ts +149 -0
  4. package/lib/Btc.d.ts.map +1 -0
  5. package/lib/Btc.js +357 -0
  6. package/lib/Btc.js.map +1 -0
  7. package/lib/BtcNew.d.ts +122 -0
  8. package/lib/BtcNew.d.ts.map +1 -0
  9. package/lib/BtcNew.js +451 -0
  10. package/lib/BtcNew.js.map +1 -0
  11. package/lib/BtcOld.d.ts +120 -0
  12. package/lib/BtcOld.d.ts.map +1 -0
  13. package/lib/BtcOld.js +263 -0
  14. package/lib/BtcOld.js.map +1 -0
  15. package/lib/bip32.d.ts +13 -0
  16. package/lib/bip32.d.ts.map +1 -0
  17. package/lib/bip32.js +57 -0
  18. package/lib/bip32.js.map +1 -0
  19. package/lib/buffertools.d.ts +30 -0
  20. package/lib/buffertools.d.ts.map +1 -0
  21. package/lib/buffertools.js +132 -0
  22. package/lib/buffertools.js.map +1 -0
  23. package/lib/compressPublicKey.d.ts +3 -0
  24. package/lib/compressPublicKey.d.ts.map +1 -0
  25. package/lib/compressPublicKey.js +11 -0
  26. package/lib/compressPublicKey.js.map +1 -0
  27. package/lib/constants.d.ts +13 -0
  28. package/lib/constants.d.ts.map +1 -0
  29. package/lib/constants.js +17 -0
  30. package/lib/constants.js.map +1 -0
  31. package/lib/createTransaction.d.ts +35 -0
  32. package/lib/createTransaction.d.ts.map +1 -0
  33. package/lib/createTransaction.js +411 -0
  34. package/lib/createTransaction.js.map +1 -0
  35. package/lib/debug.d.ts +4 -0
  36. package/lib/debug.d.ts.map +1 -0
  37. package/lib/debug.js +45 -0
  38. package/lib/debug.js.map +1 -0
  39. package/lib/finalizeInput.d.ts +5 -0
  40. package/lib/finalizeInput.d.ts.map +1 -0
  41. package/lib/finalizeInput.js +81 -0
  42. package/lib/finalizeInput.js.map +1 -0
  43. package/lib/getAppAndVersion.d.ts +9 -0
  44. package/lib/getAppAndVersion.d.ts.map +1 -0
  45. package/lib/getAppAndVersion.js +69 -0
  46. package/lib/getAppAndVersion.js.map +1 -0
  47. package/lib/getTrustedInput.d.ts +6 -0
  48. package/lib/getTrustedInput.d.ts.map +1 -0
  49. package/lib/getTrustedInput.js +275 -0
  50. package/lib/getTrustedInput.js.map +1 -0
  51. package/lib/getTrustedInputBIP143.d.ts +4 -0
  52. package/lib/getTrustedInputBIP143.d.ts.map +1 -0
  53. package/lib/getTrustedInputBIP143.js +34 -0
  54. package/lib/getTrustedInputBIP143.js.map +1 -0
  55. package/lib/getWalletPublicKey.d.ts +15 -0
  56. package/lib/getWalletPublicKey.d.ts.map +1 -0
  57. package/lib/getWalletPublicKey.js +93 -0
  58. package/lib/getWalletPublicKey.js.map +1 -0
  59. package/lib/hashPublicKey.d.ts +3 -0
  60. package/lib/hashPublicKey.d.ts.map +1 -0
  61. package/lib/hashPublicKey.js +13 -0
  62. package/lib/hashPublicKey.js.map +1 -0
  63. package/lib/index.d.ts +3 -0
  64. package/lib/index.d.ts.map +1 -0
  65. package/lib/index.js +8 -0
  66. package/lib/index.js.map +1 -0
  67. package/lib/newops/accounttype.d.ts +110 -0
  68. package/lib/newops/accounttype.d.ts.map +1 -0
  69. package/lib/newops/accounttype.js +236 -0
  70. package/lib/newops/accounttype.js.map +1 -0
  71. package/lib/newops/appClient.d.ts +18 -0
  72. package/lib/newops/appClient.d.ts.map +1 -0
  73. package/lib/newops/appClient.js +243 -0
  74. package/lib/newops/appClient.js.map +1 -0
  75. package/lib/newops/clientCommands.d.ts +77 -0
  76. package/lib/newops/clientCommands.d.ts.map +1 -0
  77. package/lib/newops/clientCommands.js +353 -0
  78. package/lib/newops/clientCommands.js.map +1 -0
  79. package/lib/newops/merkelizedPsbt.d.ts +26 -0
  80. package/lib/newops/merkelizedPsbt.d.ts.map +1 -0
  81. package/lib/newops/merkelizedPsbt.js +102 -0
  82. package/lib/newops/merkelizedPsbt.js.map +1 -0
  83. package/lib/newops/merkle.d.ts +34 -0
  84. package/lib/newops/merkle.d.ts.map +1 -0
  85. package/lib/newops/merkle.js +138 -0
  86. package/lib/newops/merkle.js.map +1 -0
  87. package/lib/newops/merkleMap.d.ts +25 -0
  88. package/lib/newops/merkleMap.d.ts.map +1 -0
  89. package/lib/newops/merkleMap.js +47 -0
  90. package/lib/newops/merkleMap.js.map +1 -0
  91. package/lib/newops/policy.d.ts +22 -0
  92. package/lib/newops/policy.d.ts.map +1 -0
  93. package/lib/newops/policy.js +48 -0
  94. package/lib/newops/policy.js.map +1 -0
  95. package/lib/newops/psbtExtractor.d.ts +10 -0
  96. package/lib/newops/psbtExtractor.d.ts.map +1 -0
  97. package/lib/newops/psbtExtractor.js +42 -0
  98. package/lib/newops/psbtExtractor.js.map +1 -0
  99. package/lib/newops/psbtFinalizer.d.ts +17 -0
  100. package/lib/newops/psbtFinalizer.d.ts.map +1 -0
  101. package/lib/newops/psbtFinalizer.js +135 -0
  102. package/lib/newops/psbtFinalizer.js.map +1 -0
  103. package/lib/newops/psbtv2.d.ts +149 -0
  104. package/lib/newops/psbtv2.d.ts.map +1 -0
  105. package/lib/newops/psbtv2.js +506 -0
  106. package/lib/newops/psbtv2.js.map +1 -0
  107. package/lib/serializeTransaction.d.ts +10 -0
  108. package/lib/serializeTransaction.d.ts.map +1 -0
  109. package/lib/serializeTransaction.js +72 -0
  110. package/lib/serializeTransaction.js.map +1 -0
  111. package/lib/shouldUseTrustedInputForSegwit.d.ts +5 -0
  112. package/lib/shouldUseTrustedInputForSegwit.d.ts.map +1 -0
  113. package/lib/shouldUseTrustedInputForSegwit.js +17 -0
  114. package/lib/shouldUseTrustedInputForSegwit.js.map +1 -0
  115. package/lib/signMessage.d.ts +10 -0
  116. package/lib/signMessage.d.ts.map +1 -0
  117. package/lib/signMessage.js +118 -0
  118. package/lib/signMessage.js.map +1 -0
  119. package/lib/signP2SHTransaction.d.ts +21 -0
  120. package/lib/signP2SHTransaction.d.ts.map +1 -0
  121. package/lib/signP2SHTransaction.js +208 -0
  122. package/lib/signP2SHTransaction.js.map +1 -0
  123. package/lib/signTransaction.d.ts +4 -0
  124. package/lib/signTransaction.d.ts.map +1 -0
  125. package/lib/signTransaction.js +36 -0
  126. package/lib/signTransaction.js.map +1 -0
  127. package/lib/splitTransaction.d.ts +3 -0
  128. package/lib/splitTransaction.d.ts.map +1 -0
  129. package/lib/splitTransaction.js +142 -0
  130. package/lib/splitTransaction.js.map +1 -0
  131. package/lib/startUntrustedHashTransactionInput.d.ts +9 -0
  132. package/lib/startUntrustedHashTransactionInput.d.ts.map +1 -0
  133. package/lib/startUntrustedHashTransactionInput.js +197 -0
  134. package/lib/startUntrustedHashTransactionInput.js.map +1 -0
  135. package/lib/types.d.ts +34 -0
  136. package/lib/types.d.ts.map +1 -0
  137. package/lib/types.js +3 -0
  138. package/lib/types.js.map +1 -0
  139. package/lib/varint.d.ts +4 -0
  140. package/lib/varint.d.ts.map +1 -0
  141. package/lib/varint.js +45 -0
  142. package/lib/varint.js.map +1 -0
  143. package/lib-es/Btc.d.ts +149 -0
  144. package/lib-es/Btc.d.ts.map +1 -0
  145. package/lib-es/Btc.js +329 -0
  146. package/lib-es/Btc.js.map +1 -0
  147. package/lib-es/BtcNew.d.ts +122 -0
  148. package/lib-es/BtcNew.d.ts.map +1 -0
  149. package/lib-es/BtcNew.js +444 -0
  150. package/lib-es/BtcNew.js.map +1 -0
  151. package/lib-es/BtcOld.d.ts +120 -0
  152. package/lib-es/BtcOld.d.ts.map +1 -0
  153. package/lib-es/BtcOld.js +258 -0
  154. package/lib-es/BtcOld.js.map +1 -0
  155. package/lib-es/bip32.d.ts +13 -0
  156. package/lib-es/bip32.d.ts.map +1 -0
  157. package/lib-es/bip32.js +44 -0
  158. package/lib-es/bip32.js.map +1 -0
  159. package/lib-es/buffertools.d.ts +30 -0
  160. package/lib-es/buffertools.d.ts.map +1 -0
  161. package/lib-es/buffertools.js +124 -0
  162. package/lib-es/buffertools.js.map +1 -0
  163. package/lib-es/compressPublicKey.d.ts +3 -0
  164. package/lib-es/compressPublicKey.d.ts.map +1 -0
  165. package/lib-es/compressPublicKey.js +7 -0
  166. package/lib-es/compressPublicKey.js.map +1 -0
  167. package/lib-es/constants.d.ts +13 -0
  168. package/lib-es/constants.d.ts.map +1 -0
  169. package/lib-es/constants.js +14 -0
  170. package/lib-es/constants.js.map +1 -0
  171. package/lib-es/createTransaction.d.ts +35 -0
  172. package/lib-es/createTransaction.d.ts.map +1 -0
  173. package/lib-es/createTransaction.js +407 -0
  174. package/lib-es/createTransaction.js.map +1 -0
  175. package/lib-es/debug.d.ts +4 -0
  176. package/lib-es/debug.d.ts.map +1 -0
  177. package/lib-es/debug.js +40 -0
  178. package/lib-es/debug.js.map +1 -0
  179. package/lib-es/finalizeInput.d.ts +5 -0
  180. package/lib-es/finalizeInput.d.ts.map +1 -0
  181. package/lib-es/finalizeInput.js +76 -0
  182. package/lib-es/finalizeInput.js.map +1 -0
  183. package/lib-es/getAppAndVersion.d.ts +9 -0
  184. package/lib-es/getAppAndVersion.d.ts.map +1 -0
  185. package/lib-es/getAppAndVersion.js +62 -0
  186. package/lib-es/getAppAndVersion.js.map +1 -0
  187. package/lib-es/getTrustedInput.d.ts +6 -0
  188. package/lib-es/getTrustedInput.d.ts.map +1 -0
  189. package/lib-es/getTrustedInput.js +267 -0
  190. package/lib-es/getTrustedInput.js.map +1 -0
  191. package/lib-es/getTrustedInputBIP143.d.ts +4 -0
  192. package/lib-es/getTrustedInputBIP143.d.ts.map +1 -0
  193. package/lib-es/getTrustedInputBIP143.js +27 -0
  194. package/lib-es/getTrustedInputBIP143.js.map +1 -0
  195. package/lib-es/getWalletPublicKey.d.ts +15 -0
  196. package/lib-es/getWalletPublicKey.d.ts.map +1 -0
  197. package/lib-es/getWalletPublicKey.js +89 -0
  198. package/lib-es/getWalletPublicKey.js.map +1 -0
  199. package/lib-es/hashPublicKey.d.ts +3 -0
  200. package/lib-es/hashPublicKey.d.ts.map +1 -0
  201. package/lib-es/hashPublicKey.js +6 -0
  202. package/lib-es/hashPublicKey.js.map +1 -0
  203. package/lib-es/index.d.ts +3 -0
  204. package/lib-es/index.d.ts.map +1 -0
  205. package/lib-es/index.js +3 -0
  206. package/lib-es/index.js.map +1 -0
  207. package/lib-es/newops/accounttype.d.ts +110 -0
  208. package/lib-es/newops/accounttype.d.ts.map +1 -0
  209. package/lib-es/newops/accounttype.js +233 -0
  210. package/lib-es/newops/accounttype.js.map +1 -0
  211. package/lib-es/newops/appClient.d.ts +18 -0
  212. package/lib-es/newops/appClient.d.ts.map +1 -0
  213. package/lib-es/newops/appClient.js +240 -0
  214. package/lib-es/newops/appClient.js.map +1 -0
  215. package/lib-es/newops/clientCommands.d.ts +77 -0
  216. package/lib-es/newops/clientCommands.d.ts.map +1 -0
  217. package/lib-es/newops/clientCommands.js +350 -0
  218. package/lib-es/newops/clientCommands.js.map +1 -0
  219. package/lib-es/newops/merkelizedPsbt.d.ts +26 -0
  220. package/lib-es/newops/merkelizedPsbt.d.ts.map +1 -0
  221. package/lib-es/newops/merkelizedPsbt.js +99 -0
  222. package/lib-es/newops/merkelizedPsbt.js.map +1 -0
  223. package/lib-es/newops/merkle.d.ts +34 -0
  224. package/lib-es/newops/merkle.d.ts.map +1 -0
  225. package/lib-es/newops/merkle.js +134 -0
  226. package/lib-es/newops/merkle.js.map +1 -0
  227. package/lib-es/newops/merkleMap.d.ts +25 -0
  228. package/lib-es/newops/merkleMap.d.ts.map +1 -0
  229. package/lib-es/newops/merkleMap.js +44 -0
  230. package/lib-es/newops/merkleMap.js.map +1 -0
  231. package/lib-es/newops/policy.d.ts +22 -0
  232. package/lib-es/newops/policy.d.ts.map +1 -0
  233. package/lib-es/newops/policy.js +44 -0
  234. package/lib-es/newops/policy.js.map +1 -0
  235. package/lib-es/newops/psbtExtractor.d.ts +10 -0
  236. package/lib-es/newops/psbtExtractor.d.ts.map +1 -0
  237. package/lib-es/newops/psbtExtractor.js +38 -0
  238. package/lib-es/newops/psbtExtractor.js.map +1 -0
  239. package/lib-es/newops/psbtFinalizer.d.ts +17 -0
  240. package/lib-es/newops/psbtFinalizer.d.ts.map +1 -0
  241. package/lib-es/newops/psbtFinalizer.js +131 -0
  242. package/lib-es/newops/psbtFinalizer.js.map +1 -0
  243. package/lib-es/newops/psbtv2.d.ts +149 -0
  244. package/lib-es/newops/psbtv2.d.ts.map +1 -0
  245. package/lib-es/newops/psbtv2.js +503 -0
  246. package/lib-es/newops/psbtv2.js.map +1 -0
  247. package/lib-es/serializeTransaction.d.ts +10 -0
  248. package/lib-es/serializeTransaction.d.ts.map +1 -0
  249. package/lib-es/serializeTransaction.js +67 -0
  250. package/lib-es/serializeTransaction.js.map +1 -0
  251. package/lib-es/shouldUseTrustedInputForSegwit.d.ts +5 -0
  252. package/lib-es/shouldUseTrustedInputForSegwit.d.ts.map +1 -0
  253. package/lib-es/shouldUseTrustedInputForSegwit.js +10 -0
  254. package/lib-es/shouldUseTrustedInputForSegwit.js.map +1 -0
  255. package/lib-es/signMessage.d.ts +10 -0
  256. package/lib-es/signMessage.d.ts.map +1 -0
  257. package/lib-es/signMessage.js +111 -0
  258. package/lib-es/signMessage.js.map +1 -0
  259. package/lib-es/signP2SHTransaction.d.ts +21 -0
  260. package/lib-es/signP2SHTransaction.d.ts.map +1 -0
  261. package/lib-es/signP2SHTransaction.js +204 -0
  262. package/lib-es/signP2SHTransaction.js.map +1 -0
  263. package/lib-es/signTransaction.d.ts +4 -0
  264. package/lib-es/signTransaction.d.ts.map +1 -0
  265. package/lib-es/signTransaction.js +32 -0
  266. package/lib-es/signTransaction.js.map +1 -0
  267. package/lib-es/splitTransaction.d.ts +3 -0
  268. package/lib-es/splitTransaction.d.ts.map +1 -0
  269. package/lib-es/splitTransaction.js +138 -0
  270. package/lib-es/splitTransaction.js.map +1 -0
  271. package/lib-es/startUntrustedHashTransactionInput.d.ts +9 -0
  272. package/lib-es/startUntrustedHashTransactionInput.d.ts.map +1 -0
  273. package/lib-es/startUntrustedHashTransactionInput.js +192 -0
  274. package/lib-es/startUntrustedHashTransactionInput.js.map +1 -0
  275. package/lib-es/types.d.ts +34 -0
  276. package/lib-es/types.d.ts.map +1 -0
  277. package/lib-es/types.js +2 -0
  278. package/lib-es/types.js.map +1 -0
  279. package/lib-es/varint.d.ts +4 -0
  280. package/lib-es/varint.d.ts.map +1 -0
  281. package/lib-es/varint.js +40 -0
  282. package/lib-es/varint.js.map +1 -0
  283. package/package.json +5 -5
@@ -0,0 +1,120 @@
1
+ import type Transport from "@ledgerhq/hw-transport";
2
+ import type { CreateTransactionArg } from "./createTransaction";
3
+ import type { AddressFormat } from "./getWalletPublicKey";
4
+ import type { SignP2SHTransactionArg } from "./signP2SHTransaction";
5
+ export type { AddressFormat };
6
+ /**
7
+ * Bitcoin API.
8
+ *
9
+ * @example
10
+ * import Btc from "@ledgerhq/hw-app-btc";
11
+ * const btc = new Btc(transport)
12
+ */
13
+ export default class BtcOld {
14
+ private transport;
15
+ constructor(transport: Transport);
16
+ private derivationsCache;
17
+ private derivatePath;
18
+ getWalletXpub({ path, xpubVersion, }: {
19
+ path: string;
20
+ xpubVersion: number;
21
+ }): Promise<string>;
22
+ /**
23
+ * @param path a BIP 32 path
24
+ * @param options an object with optional these fields:
25
+ *
26
+ * - verify (boolean) will ask user to confirm the address on the device
27
+ *
28
+ * - format ("legacy" | "p2sh" | "bech32" | "cashaddr") to use different bitcoin address formatter.
29
+ *
30
+ * NB The normal usage is to use:
31
+ *
32
+ * - legacy format with 44' paths
33
+ *
34
+ * - p2sh format with 49' paths
35
+ *
36
+ * - bech32 format with 173' paths
37
+ *
38
+ * - cashaddr in case of Bitcoin Cash
39
+ *
40
+ * @example
41
+ * btc.getWalletPublicKey("44'/0'/0'/0/0").then(o => o.bitcoinAddress)
42
+ * btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinAddress)
43
+ */
44
+ getWalletPublicKey(path: string, opts?: {
45
+ verify?: boolean;
46
+ format?: AddressFormat;
47
+ }): Promise<{
48
+ publicKey: string;
49
+ bitcoinAddress: string;
50
+ chainCode: string;
51
+ }>;
52
+ /**
53
+ * 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.
54
+ * @example
55
+ btc.signMessageNew_async("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
56
+ var v = result['v'] + 27 + 4;
57
+ var signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');
58
+ console.log("Signature : " + signature);
59
+ }).catch(function(ex) {console.log(ex);});
60
+ */
61
+ signMessageNew(path: string, messageHex: string): Promise<{
62
+ v: number;
63
+ r: string;
64
+ s: string;
65
+ }>;
66
+ /**
67
+ * To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
68
+ * @param inputs is an array of [ transaction, output_index, optional redeem script, optional sequence ] where
69
+ *
70
+ * * transaction is the previously computed transaction object for this UTXO
71
+ * * output_index is the output in the transaction used as input for this UTXO (counting from 0)
72
+ * * redeem script is the optional redeem script to use when consuming a Segregated Witness input
73
+ * * sequence is the sequence number to use for this input (when using RBF), or non present
74
+ * @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
75
+ * @param changePath is an optional BIP 32 path pointing to the path to the public key used to compute the change address
76
+ * @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign
77
+ * @param lockTime is the optional lockTime of the transaction to sign, or default (0)
78
+ * @param sigHashType is the hash type of the transaction to sign, or default (all)
79
+ * @param segwit is an optional boolean indicating wether to use segwit or not
80
+ * @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)
81
+ * @param additionals list of additionnal options
82
+ *
83
+ * - "bech32" for spending native segwit outputs
84
+ * - "abc" for bch
85
+ * - "gold" for btg
86
+ * - "bipxxx" for using BIPxxx
87
+ * - "sapling" to indicate a zec transaction is supporting sapling (to be set over block 419200)
88
+ * @param expiryHeight is an optional Buffer for zec overwinter / sapling Txs
89
+ * @param useTrustedInputForSegwit trust inputs for segwit transactions
90
+ * @return the signed transaction ready to be broadcast
91
+ * @example
92
+ btc.createTransaction({
93
+ inputs: [ [tx1, 1] ],
94
+ associatedKeysets: ["0'/0/0"],
95
+ outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
96
+ }).then(res => ...);
97
+ */
98
+ createPaymentTransactionNew(arg: CreateTransactionArg): Promise<string>;
99
+ /**
100
+ * To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters
101
+ * @param inputs is an array of [ transaction, output_index, redeem script, optional sequence ] where
102
+ * * transaction is the previously computed transaction object for this UTXO
103
+ * * output_index is the output in the transaction used as input for this UTXO (counting from 0)
104
+ * * redeem script is the mandatory redeem script associated to the current P2SH input
105
+ * * sequence is the sequence number to use for this input (when using RBF), or non present
106
+ * @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
107
+ * @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign
108
+ * @param lockTime is the optional lockTime of the transaction to sign, or default (0)
109
+ * @param sigHashType is the hash type of the transaction to sign, or default (all)
110
+ * @return the signed transaction ready to be broadcast
111
+ * @example
112
+ btc.signP2SHTransaction({
113
+ inputs: [ [tx, 1, "52210289b4a3ad52a919abd2bdd6920d8a6879b1e788c38aa76f0440a6f32a9f1996d02103a3393b1439d1693b063482c04bd40142db97bdf139eedd1b51ffb7070a37eac321030b9a409a1e476b0d5d17b804fcdb81cf30f9b99c6f3ae1178206e08bc500639853ae"] ],
114
+ associatedKeysets: ["0'/0/0"],
115
+ outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
116
+ }).then(result => ...);
117
+ */
118
+ signP2SHTransaction(arg: SignP2SHTransactionArg): Promise<string[]>;
119
+ }
120
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AAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC;IASvE;;;;;;;;;;;;;;;;;;OAkBG;IACH,mBAAmB,CAAC,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CASpE"}
package/lib/BtcOld.js ADDED
@@ -0,0 +1,263 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ exports.__esModule = true;
53
+ var bs58_1 = __importDefault(require("bs58"));
54
+ var ripemd160_1 = __importDefault(require("ripemd160"));
55
+ var sha_js_1 = __importDefault(require("sha.js"));
56
+ var createTransaction_1 = require("./createTransaction");
57
+ var getWalletPublicKey_1 = require("./getWalletPublicKey");
58
+ var signMessage_1 = require("./signMessage");
59
+ var signP2SHTransaction_1 = require("./signP2SHTransaction");
60
+ var bip32_1 = require("./bip32");
61
+ /**
62
+ * Bitcoin API.
63
+ *
64
+ * @example
65
+ * import Btc from "@ledgerhq/hw-app-btc";
66
+ * const btc = new Btc(transport)
67
+ */
68
+ var BtcOld = /** @class */ (function () {
69
+ function BtcOld(transport) {
70
+ this.transport = transport;
71
+ this.derivationsCache = {};
72
+ }
73
+ BtcOld.prototype.derivatePath = function (path) {
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ var res;
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0:
79
+ if (this.derivationsCache[path])
80
+ return [2 /*return*/, this.derivationsCache[path]];
81
+ return [4 /*yield*/, (0, getWalletPublicKey_1.getWalletPublicKey)(this.transport, {
82
+ path: path
83
+ })];
84
+ case 1:
85
+ res = _a.sent();
86
+ this.derivationsCache[path] = res;
87
+ return [2 /*return*/, res];
88
+ }
89
+ });
90
+ });
91
+ };
92
+ BtcOld.prototype.getWalletXpub = function (_a) {
93
+ var path = _a.path, xpubVersion = _a.xpubVersion;
94
+ return __awaiter(this, void 0, void 0, function () {
95
+ var pathElements, parentPath, parentDerivation, accountDerivation, fingerprint, xpub;
96
+ return __generator(this, function (_b) {
97
+ switch (_b.label) {
98
+ case 0:
99
+ pathElements = (0, bip32_1.pathStringToArray)(path);
100
+ parentPath = pathElements.slice(0, -1);
101
+ return [4 /*yield*/, this.derivatePath((0, bip32_1.pathArrayToString)(parentPath))];
102
+ case 1:
103
+ parentDerivation = _b.sent();
104
+ return [4 /*yield*/, this.derivatePath(path)];
105
+ case 2:
106
+ accountDerivation = _b.sent();
107
+ fingerprint = makeFingerprint(compressPublicKeySECP256(Buffer.from(parentDerivation.publicKey, "hex")));
108
+ xpub = makeXpub(xpubVersion, pathElements.length, fingerprint, pathElements[pathElements.length - 1], Buffer.from(accountDerivation.chainCode, "hex"), compressPublicKeySECP256(Buffer.from(accountDerivation.publicKey, "hex")));
109
+ return [2 /*return*/, xpub];
110
+ }
111
+ });
112
+ });
113
+ };
114
+ /**
115
+ * @param path a BIP 32 path
116
+ * @param options an object with optional these fields:
117
+ *
118
+ * - verify (boolean) will ask user to confirm the address on the device
119
+ *
120
+ * - format ("legacy" | "p2sh" | "bech32" | "cashaddr") to use different bitcoin address formatter.
121
+ *
122
+ * NB The normal usage is to use:
123
+ *
124
+ * - legacy format with 44' paths
125
+ *
126
+ * - p2sh format with 49' paths
127
+ *
128
+ * - bech32 format with 173' paths
129
+ *
130
+ * - cashaddr in case of Bitcoin Cash
131
+ *
132
+ * @example
133
+ * btc.getWalletPublicKey("44'/0'/0'/0/0").then(o => o.bitcoinAddress)
134
+ * btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinAddress)
135
+ */
136
+ BtcOld.prototype.getWalletPublicKey = function (path, opts) {
137
+ if ((opts === null || opts === void 0 ? void 0 : opts.format) === "bech32m") {
138
+ throw new Error("Unsupported address format bech32m");
139
+ }
140
+ return (0, getWalletPublicKey_1.getWalletPublicKey)(this.transport, __assign(__assign({}, opts), { path: path }));
141
+ };
142
+ /**
143
+ * 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.
144
+ * @example
145
+ btc.signMessageNew_async("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
146
+ var v = result['v'] + 27 + 4;
147
+ var signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');
148
+ console.log("Signature : " + signature);
149
+ }).catch(function(ex) {console.log(ex);});
150
+ */
151
+ BtcOld.prototype.signMessageNew = function (path, messageHex) {
152
+ return (0, signMessage_1.signMessage)(this.transport, {
153
+ path: path,
154
+ messageHex: messageHex
155
+ });
156
+ };
157
+ /**
158
+ * To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
159
+ * @param inputs is an array of [ transaction, output_index, optional redeem script, optional sequence ] where
160
+ *
161
+ * * transaction is the previously computed transaction object for this UTXO
162
+ * * output_index is the output in the transaction used as input for this UTXO (counting from 0)
163
+ * * redeem script is the optional redeem script to use when consuming a Segregated Witness input
164
+ * * sequence is the sequence number to use for this input (when using RBF), or non present
165
+ * @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
166
+ * @param changePath is an optional BIP 32 path pointing to the path to the public key used to compute the change address
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
+ * @param segwit is an optional boolean indicating wether to use segwit or not
171
+ * @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)
172
+ * @param additionals list of additionnal options
173
+ *
174
+ * - "bech32" for spending native segwit outputs
175
+ * - "abc" for bch
176
+ * - "gold" for btg
177
+ * - "bipxxx" for using BIPxxx
178
+ * - "sapling" to indicate a zec transaction is supporting sapling (to be set over block 419200)
179
+ * @param expiryHeight is an optional Buffer for zec overwinter / sapling Txs
180
+ * @param useTrustedInputForSegwit trust inputs for segwit transactions
181
+ * @return the signed transaction ready to be broadcast
182
+ * @example
183
+ btc.createTransaction({
184
+ inputs: [ [tx1, 1] ],
185
+ associatedKeysets: ["0'/0/0"],
186
+ outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
187
+ }).then(res => ...);
188
+ */
189
+ BtcOld.prototype.createPaymentTransactionNew = function (arg) {
190
+ if (arguments.length > 1) {
191
+ console.warn("@ledgerhq/hw-app-btc: createPaymentTransactionNew multi argument signature is deprecated. please switch to named parameters.");
192
+ }
193
+ return (0, createTransaction_1.createTransaction)(this.transport, arg);
194
+ };
195
+ /**
196
+ * To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters
197
+ * @param inputs is an array of [ transaction, output_index, redeem script, optional sequence ] where
198
+ * * transaction is the previously computed transaction object for this UTXO
199
+ * * output_index is the output in the transaction used as input for this UTXO (counting from 0)
200
+ * * redeem script is the mandatory redeem script associated to the current P2SH input
201
+ * * sequence is the sequence number to use for this input (when using RBF), or non present
202
+ * @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
203
+ * @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign
204
+ * @param lockTime is the optional lockTime of the transaction to sign, or default (0)
205
+ * @param sigHashType is the hash type of the transaction to sign, or default (all)
206
+ * @return the signed transaction ready to be broadcast
207
+ * @example
208
+ btc.signP2SHTransaction({
209
+ inputs: [ [tx, 1, "52210289b4a3ad52a919abd2bdd6920d8a6879b1e788c38aa76f0440a6f32a9f1996d02103a3393b1439d1693b063482c04bd40142db97bdf139eedd1b51ffb7070a37eac321030b9a409a1e476b0d5d17b804fcdb81cf30f9b99c6f3ae1178206e08bc500639853ae"] ],
210
+ associatedKeysets: ["0'/0/0"],
211
+ outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
212
+ }).then(result => ...);
213
+ */
214
+ BtcOld.prototype.signP2SHTransaction = function (arg) {
215
+ if (arguments.length > 1) {
216
+ console.warn("@ledgerhq/hw-app-btc: signP2SHTransaction multi argument signature is deprecated. please switch to named parameters.");
217
+ }
218
+ return (0, signP2SHTransaction_1.signP2SHTransaction)(this.transport, arg);
219
+ };
220
+ return BtcOld;
221
+ }());
222
+ exports["default"] = BtcOld;
223
+ function makeFingerprint(compressedPubKey) {
224
+ return hash160(compressedPubKey).slice(0, 4);
225
+ }
226
+ function asBufferUInt32BE(n) {
227
+ var buf = Buffer.allocUnsafe(4);
228
+ buf.writeUInt32BE(n, 0);
229
+ return buf;
230
+ }
231
+ var compressPublicKeySECP256 = function (publicKey) {
232
+ return Buffer.concat([
233
+ Buffer.from([0x02 + (publicKey[64] & 0x01)]),
234
+ publicKey.slice(1, 33),
235
+ ]);
236
+ };
237
+ function makeXpub(version, depth, parentFingerprint, index, chainCode, pubKey) {
238
+ var indexBuffer = asBufferUInt32BE(index);
239
+ indexBuffer[0] |= 0x80;
240
+ var extendedKeyBytes = Buffer.concat([
241
+ asBufferUInt32BE(version),
242
+ Buffer.from([depth]),
243
+ parentFingerprint,
244
+ indexBuffer,
245
+ chainCode,
246
+ pubKey,
247
+ ]);
248
+ var checksum = hash256(extendedKeyBytes).slice(0, 4);
249
+ return bs58_1["default"].encode(Buffer.concat([extendedKeyBytes, checksum]));
250
+ }
251
+ function sha256(buffer) {
252
+ return (0, sha_js_1["default"])("sha256").update(buffer).digest();
253
+ }
254
+ function hash256(buffer) {
255
+ return sha256(sha256(buffer));
256
+ }
257
+ function ripemd160(buffer) {
258
+ return new ripemd160_1["default"]().update(buffer).digest();
259
+ }
260
+ function hash160(buffer) {
261
+ return ripemd160(sha256(buffer));
262
+ }
263
+ //# sourceMappingURL=BtcOld.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BtcOld.js","sourceRoot":"","sources":["../src/BtcOld.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAwB;AACxB,wDAAkC;AAClC,kDAAyB;AAGzB,yDAAwD;AAExD,2DAA0D;AAC1D,6CAA4C;AAE5C,6DAA4D;AAC5D,iCAA+D;AAG/D;;;;;;GAMG;AAEH;IACE,gBAAoB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;QAEhC,qBAAgB,GAAG,EAAE,CAAC;IAFa,CAAC;IAG9B,6BAAY,GAA1B,UAA2B,IAAY;;;;;;wBACrC,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;4BAAE,sBAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAC;wBACxD,qBAAM,IAAA,uCAAkB,EAAC,IAAI,CAAC,SAAS,EAAE;gCACnD,IAAI,MAAA;6BACL,CAAC,EAAA;;wBAFI,GAAG,GAAG,SAEV;wBACF,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;wBAClC,sBAAO,GAAG,EAAC;;;;KACZ;IAEK,8BAAa,GAAnB,UAAoB,EAMnB;YALC,IAAI,UAAA,EACJ,WAAW,iBAAA;;;;;;wBAKL,YAAY,GAAG,IAAA,yBAAiB,EAAC,IAAI,CAAC,CAAC;wBACvC,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;wBACpB,qBAAM,IAAI,CAAC,YAAY,CAC9C,IAAA,yBAAiB,EAAC,UAAU,CAAC,CAC9B,EAAA;;wBAFK,gB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AAM,CAAC;QACrC,gBAAgB,CAAC,OAAO,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;QACpB,iBAAiB;QACjB,WAAW;QACX,SAAS;QACT,MAAM;KACP,CAAC,CAAC;IACH,IAAM,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACvD,OAAO,iBAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,MAAM,CAAC,MAAuB;IACrC,OAAO,IAAA,mBAAG,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;AAC/C,CAAC;AACD,SAAS,OAAO,CAAC,MAAuB;IACtC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAChC,CAAC;AACD,SAAS,SAAS,CAAC,MAAuB;IACxC,OAAO,IAAI,sBAAS,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;AACjD,CAAC;AACD,SAAS,OAAO,CAAC,MAAuB;IACtC,OAAO,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AACnC,CAAC"}
package/lib/bip32.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ /// <reference types="node" />
2
+ export declare function pathElementsToBuffer(paths: number[]): Buffer;
3
+ export declare function bip32asBuffer(path: string): Buffer;
4
+ export declare function pathArrayToString(pathElements: number[]): string;
5
+ export declare function pathStringToArray(path: string): number[];
6
+ export declare function pubkeyFromXpub(xpub: string): Buffer;
7
+ export declare function getXpubComponents(xpub: string): {
8
+ chaincode: Buffer;
9
+ pubkey: Buffer;
10
+ version: number;
11
+ };
12
+ export declare function hardenedPathOf(pathElements: number[]): number[];
13
+ //# sourceMappingURL=bip32.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bip32.d.ts","sourceRoot":"","sources":["../src/bip32.ts"],"names":[],"mappings":";AAGA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAO5D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGlD;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,CAKhE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAExD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAOA;AAED,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAO/D"}
package/lib/bip32.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ exports.__esModule = true;
6
+ exports.hardenedPathOf = exports.getXpubComponents = exports.pubkeyFromXpub = exports.pathStringToArray = exports.pathArrayToString = exports.bip32asBuffer = exports.pathElementsToBuffer = void 0;
7
+ var bip32_path_1 = __importDefault(require("bip32-path"));
8
+ var bs58check_1 = __importDefault(require("bs58check"));
9
+ function pathElementsToBuffer(paths) {
10
+ var buffer = Buffer.alloc(1 + paths.length * 4);
11
+ buffer[0] = paths.length;
12
+ paths.forEach(function (element, index) {
13
+ buffer.writeUInt32BE(element, 1 + 4 * index);
14
+ });
15
+ return buffer;
16
+ }
17
+ exports.pathElementsToBuffer = pathElementsToBuffer;
18
+ function bip32asBuffer(path) {
19
+ var pathElements = !path ? [] : pathStringToArray(path);
20
+ return pathElementsToBuffer(pathElements);
21
+ }
22
+ exports.bip32asBuffer = bip32asBuffer;
23
+ function pathArrayToString(pathElements) {
24
+ // Limitation: bippath can't handle and empty path. It shouldn't affect us
25
+ // right now, but might in the future.
26
+ // TODO: Fix support for empty path.
27
+ return bip32_path_1["default"].fromPathArray(pathElements).toString();
28
+ }
29
+ exports.pathArrayToString = pathArrayToString;
30
+ function pathStringToArray(path) {
31
+ return bip32_path_1["default"].fromString(path).toPathArray();
32
+ }
33
+ exports.pathStringToArray = pathStringToArray;
34
+ function pubkeyFromXpub(xpub) {
35
+ var xpubBuf = bs58check_1["default"].decode(xpub);
36
+ return xpubBuf.slice(xpubBuf.length - 33);
37
+ }
38
+ exports.pubkeyFromXpub = pubkeyFromXpub;
39
+ function getXpubComponents(xpub) {
40
+ var xpubBuf = bs58check_1["default"].decode(xpub);
41
+ return {
42
+ chaincode: xpubBuf.slice(13, 13 + 32),
43
+ pubkey: xpubBuf.slice(xpubBuf.length - 33),
44
+ version: xpubBuf.readUInt32BE(0)
45
+ };
46
+ }
47
+ exports.getXpubComponents = getXpubComponents;
48
+ function hardenedPathOf(pathElements) {
49
+ for (var i = pathElements.length - 1; i >= 0; i--) {
50
+ if (pathElements[i] >= 0x80000000) {
51
+ return pathElements.slice(0, i + 1);
52
+ }
53
+ }
54
+ return [];
55
+ }
56
+ exports.hardenedPathOf = hardenedPathOf;
57
+ //# sourceMappingURL=bip32.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bip32.js","sourceRoot":"","sources":["../src/bip32.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAiC;AACjC,wDAAkC;AAElC,SAAgB,oBAAoB,CAAC,KAAe;IAClD,IAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAClD,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;IAC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AC,YAAY,CAAC,CAAC,CAAC;KACjC,CAAC;AACJ,CAAC;AAXD,8CAWC;AAED,SAAgB,cAAc,CAAC,YAAsB;IACnD,KAAK,IAAI,CAAC,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACjD,IAAI,YAAY,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE;YACjC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;SACrC;KACF;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAPD,wCAOC"}
@@ -0,0 +1,30 @@
1
+ /// <reference types="node" />
2
+ export declare function unsafeTo64bitLE(n: number): Buffer;
3
+ export declare function unsafeFrom64bitLE(byteArray: Buffer): number;
4
+ export declare class BufferWriter {
5
+ private bufs;
6
+ write(alloc: number, fn: (b: Buffer) => void): void;
7
+ writeUInt8(i: number): void;
8
+ writeInt32(i: number): void;
9
+ writeUInt32(i: number): void;
10
+ writeUInt64(i: number): void;
11
+ writeVarInt(i: number): void;
12
+ writeSlice(slice: Buffer): void;
13
+ writeVarSlice(slice: Buffer): void;
14
+ buffer(): Buffer;
15
+ }
16
+ export declare class BufferReader {
17
+ buffer: Buffer;
18
+ offset: number;
19
+ constructor(buffer: Buffer, offset?: number);
20
+ available(): number;
21
+ readUInt8(): number;
22
+ readInt32(): number;
23
+ readUInt32(): number;
24
+ readUInt64(): number;
25
+ readVarInt(): number;
26
+ readSlice(n: number): Buffer;
27
+ readVarSlice(): Buffer;
28
+ readVector(): Buffer[];
29
+ }
30
+ //# sourceMappingURL=buffertools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffertools.d.ts","sourceRoot":"","sources":["../src/buffertools.ts"],"names":[],"mappings":";AAEA,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAYjD;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAe3D;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,IAAI,CAAgB;IAE5B,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAMnD,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAI3B,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAI3B,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAI5B,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAK5B,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAI5B,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI/B,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKlC,MAAM,IAAI,MAAM;CAGjB;AAED,qBAAa,YAAY;IACJ,MAAM,EAAE,MAAM;IAAS,MAAM,EAAE,MAAM;gBAArC,MAAM,EAAE,MAAM,EAAS,MAAM,GAAE,MAAU;IAE5D,SAAS,IAAI,MAAM;IAInB,SAAS,IAAI,MAAM;IAMnB,SAAS,IAAI,MAAM;IAMnB,UAAU,IAAI,MAAM;IAMpB,UAAU,IAAI,MAAM;IAMpB,UAAU,IAAI,MAAM;IAMpB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAS5B,YAAY,IAAI,MAAM;IAItB,UAAU,IAAI,MAAM,EAAE;CAMvB"}
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ exports.__esModule = true;
6
+ exports.BufferReader = exports.BufferWriter = exports.unsafeFrom64bitLE = exports.unsafeTo64bitLE = void 0;
7
+ var varuint_bitcoin_1 = __importDefault(require("varuint-bitcoin"));
8
+ function unsafeTo64bitLE(n) {
9
+ // we want to represent the input as a 8-bytes array
10
+ if (n > Number.MAX_SAFE_INTEGER) {
11
+ throw new Error("Can't convert numbers > MAX_SAFE_INT");
12
+ }
13
+ var byteArray = Buffer.alloc(8, 0);
14
+ for (var index = 0; index < byteArray.length; index++) {
15
+ var byte = n & 0xff;
16
+ byteArray[index] = byte;
17
+ n = (n - byte) / 256;
18
+ }
19
+ return byteArray;
20
+ }
21
+ exports.unsafeTo64bitLE = unsafeTo64bitLE;
22
+ function unsafeFrom64bitLE(byteArray) {
23
+ var value = 0;
24
+ if (byteArray.length != 8) {
25
+ throw new Error("Expected Bufffer of lenght 8");
26
+ }
27
+ if (byteArray[7] != 0) {
28
+ throw new Error("Can't encode numbers > MAX_SAFE_INT");
29
+ }
30
+ if (byteArray[6] > 0x1f) {
31
+ throw new Error("Can't encode numbers > MAX_SAFE_INT");
32
+ }
33
+ for (var i = byteArray.length - 1; i >= 0; i--) {
34
+ value = value * 256 + byteArray[i];
35
+ }
36
+ return value;
37
+ }
38
+ exports.unsafeFrom64bitLE = unsafeFrom64bitLE;
39
+ var BufferWriter = /** @class */ (function () {
40
+ function BufferWriter() {
41
+ this.bufs = [];
42
+ }
43
+ BufferWriter.prototype.write = function (alloc, fn) {
44
+ var b = Buffer.alloc(alloc);
45
+ fn(b);
46
+ this.bufs.push(b);
47
+ };
48
+ BufferWriter.prototype.writeUInt8 = function (i) {
49
+ this.write(1, function (b) { return b.writeUInt8(i, 0); });
50
+ };
51
+ BufferWriter.prototype.writeInt32 = function (i) {
52
+ this.write(4, function (b) { return b.writeInt32LE(i, 0); });
53
+ };
54
+ BufferWriter.prototype.writeUInt32 = function (i) {
55
+ this.write(4, function (b) { return b.writeUInt32LE(i, 0); });
56
+ };
57
+ BufferWriter.prototype.writeUInt64 = function (i) {
58
+ var bytes = unsafeTo64bitLE(i);
59
+ this.writeSlice(bytes);
60
+ };
61
+ BufferWriter.prototype.writeVarInt = function (i) {
62
+ this.bufs.push(varuint_bitcoin_1["default"].encode(i));
63
+ };
64
+ BufferWriter.prototype.writeSlice = function (slice) {
65
+ this.bufs.push(Buffer.from(slice));
66
+ };
67
+ BufferWriter.prototype.writeVarSlice = function (slice) {
68
+ this.writeVarInt(slice.length);
69
+ this.writeSlice(slice);
70
+ };
71
+ BufferWriter.prototype.buffer = function () {
72
+ return Buffer.concat(this.bufs);
73
+ };
74
+ return BufferWriter;
75
+ }());
76
+ exports.BufferWriter = BufferWriter;
77
+ var BufferReader = /** @class */ (function () {
78
+ function BufferReader(buffer, offset) {
79
+ if (offset === void 0) { offset = 0; }
80
+ this.buffer = buffer;
81
+ this.offset = offset;
82
+ }
83
+ BufferReader.prototype.available = function () {
84
+ return this.buffer.length - this.offset;
85
+ };
86
+ BufferReader.prototype.readUInt8 = function () {
87
+ var result = this.buffer.readUInt8(this.offset);
88
+ this.offset++;
89
+ return result;
90
+ };
91
+ BufferReader.prototype.readInt32 = function () {
92
+ var result = this.buffer.readInt32LE(this.offset);
93
+ this.offset += 4;
94
+ return result;
95
+ };
96
+ BufferReader.prototype.readUInt32 = function () {
97
+ var result = this.buffer.readUInt32LE(this.offset);
98
+ this.offset += 4;
99
+ return result;
100
+ };
101
+ BufferReader.prototype.readUInt64 = function () {
102
+ var buf = this.readSlice(8);
103
+ var n = unsafeFrom64bitLE(buf);
104
+ return n;
105
+ };
106
+ BufferReader.prototype.readVarInt = function () {
107
+ var vi = varuint_bitcoin_1["default"].decode(this.buffer, this.offset);
108
+ this.offset += varuint_bitcoin_1["default"].decode.bytes;
109
+ return vi;
110
+ };
111
+ BufferReader.prototype.readSlice = function (n) {
112
+ if (this.buffer.length < this.offset + n) {
113
+ throw new Error("Cannot read slice out of bounds");
114
+ }
115
+ var result = this.buffer.slice(this.offset, this.offset + n);
116
+ this.offset += n;
117
+ return result;
118
+ };
119
+ BufferReader.prototype.readVarSlice = function () {
120
+ return this.readSlice(this.readVarInt());
121
+ };
122
+ BufferReader.prototype.readVector = function () {
123
+ var count = this.readVarInt();
124
+ var vector = [];
125
+ for (var i = 0; i < count; i++)
126
+ vector.push(this.readVarSlice());
127
+ return vector;
128
+ };
129
+ return BufferReader;
130
+ }());
131
+ exports.BufferReader = BufferReader;
132
+ //# sourceMappingURL=buffertools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffertools.js","sourceRoot":"","sources":["../src/buffertools.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAsC;AAEtC,SAAgB,eAAe,CAAC,CAAS;IACvC,oDAAoD;IACpD,IAAI,CAAC,GAAG,MAAM,CAAC,gBAAgB,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;KACzD;IACD,IAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACrD,IAAM,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC;QACtB,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;QACxB,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;KACtB;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAZD,0CAYC;AAED,SAAgB,iBAAiB,CAAC,SAAiB;IACjD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE;QACzB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;KACjD;IACD,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACxD;IACD,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACxD;IACD,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IA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;AAxDY,oCAAY"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="node" />
2
+ export declare function compressPublicKey(publicKey: Buffer): Buffer;
3
+ //# sourceMappingURL=compressPublicKey.d.ts.map