@ledgerhq/hw-app-btc 6.24.1 → 6.24.2-monorepo.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 (289) hide show
  1. package/.turbo/turbo-build.log +1 -0
  2. package/CHANGELOG.md +10 -0
  3. package/jest.config.ts +6 -0
  4. package/package.json +15 -6
  5. package/src/bip32.ts +5 -3
  6. package/src/getTrustedInput.ts +2 -8
  7. package/src/newops/appClient.ts +8 -4
  8. package/src/newops/psbtv2.ts +13 -9
  9. package/LICENSE +0 -202
  10. package/lib/Btc.d.ts +0 -149
  11. package/lib/Btc.d.ts.map +0 -1
  12. package/lib/Btc.js +0 -353
  13. package/lib/Btc.js.map +0 -1
  14. package/lib/BtcNew.d.ts +0 -122
  15. package/lib/BtcNew.d.ts.map +0 -1
  16. package/lib/BtcNew.js +0 -451
  17. package/lib/BtcNew.js.map +0 -1
  18. package/lib/BtcOld.d.ts +0 -120
  19. package/lib/BtcOld.d.ts.map +0 -1
  20. package/lib/BtcOld.js +0 -263
  21. package/lib/BtcOld.js.map +0 -1
  22. package/lib/bip32.d.ts +0 -13
  23. package/lib/bip32.d.ts.map +0 -1
  24. package/lib/bip32.js +0 -57
  25. package/lib/bip32.js.map +0 -1
  26. package/lib/buffertools.d.ts +0 -30
  27. package/lib/buffertools.d.ts.map +0 -1
  28. package/lib/buffertools.js +0 -132
  29. package/lib/buffertools.js.map +0 -1
  30. package/lib/compressPublicKey.d.ts +0 -3
  31. package/lib/compressPublicKey.d.ts.map +0 -1
  32. package/lib/compressPublicKey.js +0 -11
  33. package/lib/compressPublicKey.js.map +0 -1
  34. package/lib/constants.d.ts +0 -13
  35. package/lib/constants.d.ts.map +0 -1
  36. package/lib/constants.js +0 -17
  37. package/lib/constants.js.map +0 -1
  38. package/lib/createTransaction.d.ts +0 -35
  39. package/lib/createTransaction.d.ts.map +0 -1
  40. package/lib/createTransaction.js +0 -411
  41. package/lib/createTransaction.js.map +0 -1
  42. package/lib/debug.d.ts +0 -4
  43. package/lib/debug.d.ts.map +0 -1
  44. package/lib/debug.js +0 -45
  45. package/lib/debug.js.map +0 -1
  46. package/lib/finalizeInput.d.ts +0 -5
  47. package/lib/finalizeInput.d.ts.map +0 -1
  48. package/lib/finalizeInput.js +0 -81
  49. package/lib/finalizeInput.js.map +0 -1
  50. package/lib/getAppAndVersion.d.ts +0 -9
  51. package/lib/getAppAndVersion.d.ts.map +0 -1
  52. package/lib/getAppAndVersion.js +0 -69
  53. package/lib/getAppAndVersion.js.map +0 -1
  54. package/lib/getTrustedInput.d.ts +0 -6
  55. package/lib/getTrustedInput.d.ts.map +0 -1
  56. package/lib/getTrustedInput.js +0 -275
  57. package/lib/getTrustedInput.js.map +0 -1
  58. package/lib/getTrustedInputBIP143.d.ts +0 -4
  59. package/lib/getTrustedInputBIP143.d.ts.map +0 -1
  60. package/lib/getTrustedInputBIP143.js +0 -34
  61. package/lib/getTrustedInputBIP143.js.map +0 -1
  62. package/lib/getWalletPublicKey.d.ts +0 -15
  63. package/lib/getWalletPublicKey.d.ts.map +0 -1
  64. package/lib/getWalletPublicKey.js +0 -93
  65. package/lib/getWalletPublicKey.js.map +0 -1
  66. package/lib/hashPublicKey.d.ts +0 -3
  67. package/lib/hashPublicKey.d.ts.map +0 -1
  68. package/lib/hashPublicKey.js +0 -13
  69. package/lib/hashPublicKey.js.map +0 -1
  70. package/lib/index.d.ts +0 -3
  71. package/lib/index.d.ts.map +0 -1
  72. package/lib/index.js +0 -8
  73. package/lib/index.js.map +0 -1
  74. package/lib/newops/accounttype.d.ts +0 -110
  75. package/lib/newops/accounttype.d.ts.map +0 -1
  76. package/lib/newops/accounttype.js +0 -236
  77. package/lib/newops/accounttype.js.map +0 -1
  78. package/lib/newops/appClient.d.ts +0 -18
  79. package/lib/newops/appClient.d.ts.map +0 -1
  80. package/lib/newops/appClient.js +0 -246
  81. package/lib/newops/appClient.js.map +0 -1
  82. package/lib/newops/clientCommands.d.ts +0 -77
  83. package/lib/newops/clientCommands.d.ts.map +0 -1
  84. package/lib/newops/clientCommands.js +0 -353
  85. package/lib/newops/clientCommands.js.map +0 -1
  86. package/lib/newops/merkelizedPsbt.d.ts +0 -26
  87. package/lib/newops/merkelizedPsbt.d.ts.map +0 -1
  88. package/lib/newops/merkelizedPsbt.js +0 -102
  89. package/lib/newops/merkelizedPsbt.js.map +0 -1
  90. package/lib/newops/merkle.d.ts +0 -34
  91. package/lib/newops/merkle.d.ts.map +0 -1
  92. package/lib/newops/merkle.js +0 -138
  93. package/lib/newops/merkle.js.map +0 -1
  94. package/lib/newops/merkleMap.d.ts +0 -25
  95. package/lib/newops/merkleMap.d.ts.map +0 -1
  96. package/lib/newops/merkleMap.js +0 -47
  97. package/lib/newops/merkleMap.js.map +0 -1
  98. package/lib/newops/policy.d.ts +0 -22
  99. package/lib/newops/policy.d.ts.map +0 -1
  100. package/lib/newops/policy.js +0 -48
  101. package/lib/newops/policy.js.map +0 -1
  102. package/lib/newops/psbtExtractor.d.ts +0 -10
  103. package/lib/newops/psbtExtractor.d.ts.map +0 -1
  104. package/lib/newops/psbtExtractor.js +0 -42
  105. package/lib/newops/psbtExtractor.js.map +0 -1
  106. package/lib/newops/psbtFinalizer.d.ts +0 -17
  107. package/lib/newops/psbtFinalizer.d.ts.map +0 -1
  108. package/lib/newops/psbtFinalizer.js +0 -135
  109. package/lib/newops/psbtFinalizer.js.map +0 -1
  110. package/lib/newops/psbtv2.d.ts +0 -149
  111. package/lib/newops/psbtv2.d.ts.map +0 -1
  112. package/lib/newops/psbtv2.js +0 -506
  113. package/lib/newops/psbtv2.js.map +0 -1
  114. package/lib/serializeTransaction.d.ts +0 -10
  115. package/lib/serializeTransaction.d.ts.map +0 -1
  116. package/lib/serializeTransaction.js +0 -72
  117. package/lib/serializeTransaction.js.map +0 -1
  118. package/lib/shouldUseTrustedInputForSegwit.d.ts +0 -5
  119. package/lib/shouldUseTrustedInputForSegwit.d.ts.map +0 -1
  120. package/lib/shouldUseTrustedInputForSegwit.js +0 -17
  121. package/lib/shouldUseTrustedInputForSegwit.js.map +0 -1
  122. package/lib/signMessage.d.ts +0 -10
  123. package/lib/signMessage.d.ts.map +0 -1
  124. package/lib/signMessage.js +0 -118
  125. package/lib/signMessage.js.map +0 -1
  126. package/lib/signP2SHTransaction.d.ts +0 -21
  127. package/lib/signP2SHTransaction.d.ts.map +0 -1
  128. package/lib/signP2SHTransaction.js +0 -208
  129. package/lib/signP2SHTransaction.js.map +0 -1
  130. package/lib/signTransaction.d.ts +0 -4
  131. package/lib/signTransaction.d.ts.map +0 -1
  132. package/lib/signTransaction.js +0 -36
  133. package/lib/signTransaction.js.map +0 -1
  134. package/lib/splitTransaction.d.ts +0 -3
  135. package/lib/splitTransaction.d.ts.map +0 -1
  136. package/lib/splitTransaction.js +0 -142
  137. package/lib/splitTransaction.js.map +0 -1
  138. package/lib/startUntrustedHashTransactionInput.d.ts +0 -9
  139. package/lib/startUntrustedHashTransactionInput.d.ts.map +0 -1
  140. package/lib/startUntrustedHashTransactionInput.js +0 -197
  141. package/lib/startUntrustedHashTransactionInput.js.map +0 -1
  142. package/lib/types.d.ts +0 -34
  143. package/lib/types.d.ts.map +0 -1
  144. package/lib/types.js +0 -3
  145. package/lib/types.js.map +0 -1
  146. package/lib/varint.d.ts +0 -4
  147. package/lib/varint.d.ts.map +0 -1
  148. package/lib/varint.js +0 -45
  149. package/lib/varint.js.map +0 -1
  150. package/lib-es/Btc.d.ts +0 -149
  151. package/lib-es/Btc.d.ts.map +0 -1
  152. package/lib-es/Btc.js +0 -329
  153. package/lib-es/Btc.js.map +0 -1
  154. package/lib-es/BtcNew.d.ts +0 -122
  155. package/lib-es/BtcNew.d.ts.map +0 -1
  156. package/lib-es/BtcNew.js +0 -444
  157. package/lib-es/BtcNew.js.map +0 -1
  158. package/lib-es/BtcOld.d.ts +0 -120
  159. package/lib-es/BtcOld.d.ts.map +0 -1
  160. package/lib-es/BtcOld.js +0 -258
  161. package/lib-es/BtcOld.js.map +0 -1
  162. package/lib-es/bip32.d.ts +0 -13
  163. package/lib-es/bip32.d.ts.map +0 -1
  164. package/lib-es/bip32.js +0 -44
  165. package/lib-es/bip32.js.map +0 -1
  166. package/lib-es/buffertools.d.ts +0 -30
  167. package/lib-es/buffertools.d.ts.map +0 -1
  168. package/lib-es/buffertools.js +0 -124
  169. package/lib-es/buffertools.js.map +0 -1
  170. package/lib-es/compressPublicKey.d.ts +0 -3
  171. package/lib-es/compressPublicKey.d.ts.map +0 -1
  172. package/lib-es/compressPublicKey.js +0 -7
  173. package/lib-es/compressPublicKey.js.map +0 -1
  174. package/lib-es/constants.d.ts +0 -13
  175. package/lib-es/constants.d.ts.map +0 -1
  176. package/lib-es/constants.js +0 -14
  177. package/lib-es/constants.js.map +0 -1
  178. package/lib-es/createTransaction.d.ts +0 -35
  179. package/lib-es/createTransaction.d.ts.map +0 -1
  180. package/lib-es/createTransaction.js +0 -407
  181. package/lib-es/createTransaction.js.map +0 -1
  182. package/lib-es/debug.d.ts +0 -4
  183. package/lib-es/debug.d.ts.map +0 -1
  184. package/lib-es/debug.js +0 -40
  185. package/lib-es/debug.js.map +0 -1
  186. package/lib-es/finalizeInput.d.ts +0 -5
  187. package/lib-es/finalizeInput.d.ts.map +0 -1
  188. package/lib-es/finalizeInput.js +0 -76
  189. package/lib-es/finalizeInput.js.map +0 -1
  190. package/lib-es/getAppAndVersion.d.ts +0 -9
  191. package/lib-es/getAppAndVersion.d.ts.map +0 -1
  192. package/lib-es/getAppAndVersion.js +0 -62
  193. package/lib-es/getAppAndVersion.js.map +0 -1
  194. package/lib-es/getTrustedInput.d.ts +0 -6
  195. package/lib-es/getTrustedInput.d.ts.map +0 -1
  196. package/lib-es/getTrustedInput.js +0 -267
  197. package/lib-es/getTrustedInput.js.map +0 -1
  198. package/lib-es/getTrustedInputBIP143.d.ts +0 -4
  199. package/lib-es/getTrustedInputBIP143.d.ts.map +0 -1
  200. package/lib-es/getTrustedInputBIP143.js +0 -27
  201. package/lib-es/getTrustedInputBIP143.js.map +0 -1
  202. package/lib-es/getWalletPublicKey.d.ts +0 -15
  203. package/lib-es/getWalletPublicKey.d.ts.map +0 -1
  204. package/lib-es/getWalletPublicKey.js +0 -89
  205. package/lib-es/getWalletPublicKey.js.map +0 -1
  206. package/lib-es/hashPublicKey.d.ts +0 -3
  207. package/lib-es/hashPublicKey.d.ts.map +0 -1
  208. package/lib-es/hashPublicKey.js +0 -6
  209. package/lib-es/hashPublicKey.js.map +0 -1
  210. package/lib-es/index.d.ts +0 -3
  211. package/lib-es/index.d.ts.map +0 -1
  212. package/lib-es/index.js +0 -3
  213. package/lib-es/index.js.map +0 -1
  214. package/lib-es/newops/accounttype.d.ts +0 -110
  215. package/lib-es/newops/accounttype.d.ts.map +0 -1
  216. package/lib-es/newops/accounttype.js +0 -233
  217. package/lib-es/newops/accounttype.js.map +0 -1
  218. package/lib-es/newops/appClient.d.ts +0 -18
  219. package/lib-es/newops/appClient.d.ts.map +0 -1
  220. package/lib-es/newops/appClient.js +0 -243
  221. package/lib-es/newops/appClient.js.map +0 -1
  222. package/lib-es/newops/clientCommands.d.ts +0 -77
  223. package/lib-es/newops/clientCommands.d.ts.map +0 -1
  224. package/lib-es/newops/clientCommands.js +0 -350
  225. package/lib-es/newops/clientCommands.js.map +0 -1
  226. package/lib-es/newops/merkelizedPsbt.d.ts +0 -26
  227. package/lib-es/newops/merkelizedPsbt.d.ts.map +0 -1
  228. package/lib-es/newops/merkelizedPsbt.js +0 -99
  229. package/lib-es/newops/merkelizedPsbt.js.map +0 -1
  230. package/lib-es/newops/merkle.d.ts +0 -34
  231. package/lib-es/newops/merkle.d.ts.map +0 -1
  232. package/lib-es/newops/merkle.js +0 -134
  233. package/lib-es/newops/merkle.js.map +0 -1
  234. package/lib-es/newops/merkleMap.d.ts +0 -25
  235. package/lib-es/newops/merkleMap.d.ts.map +0 -1
  236. package/lib-es/newops/merkleMap.js +0 -44
  237. package/lib-es/newops/merkleMap.js.map +0 -1
  238. package/lib-es/newops/policy.d.ts +0 -22
  239. package/lib-es/newops/policy.d.ts.map +0 -1
  240. package/lib-es/newops/policy.js +0 -44
  241. package/lib-es/newops/policy.js.map +0 -1
  242. package/lib-es/newops/psbtExtractor.d.ts +0 -10
  243. package/lib-es/newops/psbtExtractor.d.ts.map +0 -1
  244. package/lib-es/newops/psbtExtractor.js +0 -38
  245. package/lib-es/newops/psbtExtractor.js.map +0 -1
  246. package/lib-es/newops/psbtFinalizer.d.ts +0 -17
  247. package/lib-es/newops/psbtFinalizer.d.ts.map +0 -1
  248. package/lib-es/newops/psbtFinalizer.js +0 -131
  249. package/lib-es/newops/psbtFinalizer.js.map +0 -1
  250. package/lib-es/newops/psbtv2.d.ts +0 -149
  251. package/lib-es/newops/psbtv2.d.ts.map +0 -1
  252. package/lib-es/newops/psbtv2.js +0 -503
  253. package/lib-es/newops/psbtv2.js.map +0 -1
  254. package/lib-es/serializeTransaction.d.ts +0 -10
  255. package/lib-es/serializeTransaction.d.ts.map +0 -1
  256. package/lib-es/serializeTransaction.js +0 -67
  257. package/lib-es/serializeTransaction.js.map +0 -1
  258. package/lib-es/shouldUseTrustedInputForSegwit.d.ts +0 -5
  259. package/lib-es/shouldUseTrustedInputForSegwit.d.ts.map +0 -1
  260. package/lib-es/shouldUseTrustedInputForSegwit.js +0 -10
  261. package/lib-es/shouldUseTrustedInputForSegwit.js.map +0 -1
  262. package/lib-es/signMessage.d.ts +0 -10
  263. package/lib-es/signMessage.d.ts.map +0 -1
  264. package/lib-es/signMessage.js +0 -111
  265. package/lib-es/signMessage.js.map +0 -1
  266. package/lib-es/signP2SHTransaction.d.ts +0 -21
  267. package/lib-es/signP2SHTransaction.d.ts.map +0 -1
  268. package/lib-es/signP2SHTransaction.js +0 -204
  269. package/lib-es/signP2SHTransaction.js.map +0 -1
  270. package/lib-es/signTransaction.d.ts +0 -4
  271. package/lib-es/signTransaction.d.ts.map +0 -1
  272. package/lib-es/signTransaction.js +0 -32
  273. package/lib-es/signTransaction.js.map +0 -1
  274. package/lib-es/splitTransaction.d.ts +0 -3
  275. package/lib-es/splitTransaction.d.ts.map +0 -1
  276. package/lib-es/splitTransaction.js +0 -138
  277. package/lib-es/splitTransaction.js.map +0 -1
  278. package/lib-es/startUntrustedHashTransactionInput.d.ts +0 -9
  279. package/lib-es/startUntrustedHashTransactionInput.d.ts.map +0 -1
  280. package/lib-es/startUntrustedHashTransactionInput.js +0 -192
  281. package/lib-es/startUntrustedHashTransactionInput.js.map +0 -1
  282. package/lib-es/types.d.ts +0 -34
  283. package/lib-es/types.d.ts.map +0 -1
  284. package/lib-es/types.js +0 -2
  285. package/lib-es/types.js.map +0 -1
  286. package/lib-es/varint.d.ts +0 -4
  287. package/lib-es/varint.d.ts.map +0 -1
  288. package/lib-es/varint.js +0 -40
  289. package/lib-es/varint.js.map +0 -1
@@ -1,110 +0,0 @@
1
- /// <reference types="node" />
2
- import { DefaultDescriptorTemplate } from "./policy";
3
- import { PsbtV2 } from "./psbtv2";
4
- export declare type SpendingCondition = {
5
- scriptPubKey: Buffer;
6
- redeemScript?: Buffer;
7
- };
8
- export declare type SpentOutput = {
9
- cond: SpendingCondition;
10
- amount: Buffer;
11
- };
12
- /**
13
- * Encapsulates differences between account types, for example p2wpkh,
14
- * p2wpkhWrapped, p2tr.
15
- */
16
- export interface AccountType {
17
- /**
18
- * Generates a scriptPubKey (output script) from a list of public keys. If a
19
- * p2sh redeemScript or a p2wsh witnessScript is needed it will also be set on
20
- * the returned SpendingCondition.
21
- *
22
- * The pubkeys are expected to be 33 byte ecdsa compressed pubkeys.
23
- */
24
- spendingCondition(pubkeys: Buffer[]): SpendingCondition;
25
- /**
26
- * Populates the psbt with account type-specific data for an input.
27
- * @param i The index of the input map to populate
28
- * @param inputTx The full transaction containing the spent output. This may
29
- * be omitted for taproot.
30
- * @param spentOutput The amount and spending condition of the spent output
31
- * @param pubkeys The 33 byte ecdsa compressed public keys involved in the input
32
- * @param pathElems The paths corresponding to the pubkeys, in same order.
33
- */
34
- setInput(i: number, inputTx: Buffer | undefined, spentOutput: SpentOutput, pubkeys: Buffer[], pathElems: number[][]): void;
35
- /**
36
- * Populates the psbt with account type-specific data for an output. This is typically
37
- * done for change outputs and other outputs that goes to the same account as
38
- * being spent from.
39
- * @param i The index of the output map to populate
40
- * @param cond The spending condition for this output
41
- * @param pubkeys The 33 byte ecdsa compressed public keys involved in this output
42
- * @param paths The paths corresponding to the pubkeys, in same order.
43
- */
44
- setOwnOutput(i: number, cond: SpendingCondition, pubkeys: Buffer[], paths: number[][]): void;
45
- /**
46
- * Returns the descriptor template for this account type. Currently only
47
- * DefaultDescriptorTemplates are allowed, but that might be changed in the
48
- * future. See class WalletPolicy for more information on descriptor
49
- * templates.
50
- */
51
- getDescriptorTemplate(): DefaultDescriptorTemplate;
52
- }
53
- interface BaseAccount extends AccountType {
54
- }
55
- declare abstract class BaseAccount implements AccountType {
56
- protected psbt: PsbtV2;
57
- protected masterFp: Buffer;
58
- constructor(psbt: PsbtV2, masterFp: Buffer);
59
- }
60
- /**
61
- * Superclass for single signature accounts. This will make sure that the pubkey
62
- * arrays and path arrays in the method arguments contains exactly one element
63
- * and calls an abstract method to do the actual work.
64
- */
65
- declare abstract class SingleKeyAccount extends BaseAccount {
66
- spendingCondition(pubkeys: Buffer[]): SpendingCondition;
67
- protected abstract singleKeyCondition(pubkey: Buffer): SpendingCondition;
68
- setInput(i: number, inputTx: Buffer | undefined, spentOutput: SpentOutput, pubkeys: Buffer[], pathElems: number[][]): void;
69
- protected abstract setSingleKeyInput(i: number, inputTx: Buffer | undefined, spentOutput: SpentOutput, pubkey: Buffer, path: number[]): any;
70
- setOwnOutput(i: number, cond: SpendingCondition, pubkeys: Buffer[], paths: number[][]): void;
71
- protected abstract setSingleKeyOutput(i: number, cond: SpendingCondition, pubkey: Buffer, path: number[]): any;
72
- }
73
- export declare class p2pkh extends SingleKeyAccount {
74
- singleKeyCondition(pubkey: Buffer): SpendingCondition;
75
- setSingleKeyInput(i: number, inputTx: Buffer | undefined, _spentOutput: SpentOutput, pubkey: Buffer, path: number[]): void;
76
- setSingleKeyOutput(i: number, cond: SpendingCondition, pubkey: Buffer, path: number[]): void;
77
- getDescriptorTemplate(): DefaultDescriptorTemplate;
78
- }
79
- export declare class p2tr extends SingleKeyAccount {
80
- singleKeyCondition(pubkey: Buffer): SpendingCondition;
81
- setSingleKeyInput(i: number, _inputTx: Buffer | undefined, spentOutput: SpentOutput, pubkey: Buffer, path: number[]): void;
82
- setSingleKeyOutput(i: number, cond: SpendingCondition, pubkey: Buffer, path: number[]): void;
83
- getDescriptorTemplate(): DefaultDescriptorTemplate;
84
- private hashTapTweak;
85
- /**
86
- * Calculates a taproot output key from an internal key. This output key will be
87
- * used as witness program in a taproot output. The internal key is tweaked
88
- * according to recommendation in BIP341:
89
- * https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_ref-22-0
90
- *
91
- * @param internalPubkey A 32 byte x-only taproot internal key
92
- * @returns The output key
93
- */
94
- getTaprootOutputKey(internalPubkey: Buffer): Buffer;
95
- }
96
- export declare class p2wpkhWrapped extends SingleKeyAccount {
97
- singleKeyCondition(pubkey: Buffer): SpendingCondition;
98
- setSingleKeyInput(i: number, inputTx: Buffer | undefined, spentOutput: SpentOutput, pubkey: Buffer, path: number[]): void;
99
- setSingleKeyOutput(i: number, cond: SpendingCondition, pubkey: Buffer, path: number[]): void;
100
- getDescriptorTemplate(): DefaultDescriptorTemplate;
101
- private createRedeemScript;
102
- }
103
- export declare class p2wpkh extends SingleKeyAccount {
104
- singleKeyCondition(pubkey: Buffer): SpendingCondition;
105
- setSingleKeyInput(i: number, inputTx: Buffer | undefined, spentOutput: SpentOutput, pubkey: Buffer, path: number[]): void;
106
- setSingleKeyOutput(i: number, cond: SpendingCondition, pubkey: Buffer, path: number[]): void;
107
- getDescriptorTemplate(): DefaultDescriptorTemplate;
108
- }
109
- export {};
110
- //# sourceMappingURL=accounttype.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acc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AC5B,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE;IAWhB,kBAAkB,CAChB,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE;IAMhB,qBAAqB,IAAI,yBAAyB;IAQlD,OAAO,CAAC,YAAY;IAOpB;;;;;;;;OAQG;IACH,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;CAqBpD;AAED,qBAAa,aAAc,SAAQ,gBAAgB;IACjD,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB;IAUrD,iBAAiB,CACf,CAAC,EAAE,MAAM,EACT,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE;IA4BhB,kBAAkB,CAChB,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE;IAMhB,qBAAqB,IAAI,yBAAyB;IAIlD,OAAO,CAAC,kBAAkB;CAI3B;AAED,qBAAa,MAAO,SAAQ,gBAAgB;IAC1C,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB;IAQrD,iBAAiB,CACf,CAAC,EAAE,MAAM,EACT,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE;IAchB,kBAAkB,CAChB,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE;IAKhB,qBAAqB,IAAI,yBAAyB;CAGnD"}
@@ -1,236 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- exports.__esModule = true;
18
- exports.p2wpkh = exports.p2wpkhWrapped = exports.p2tr = exports.p2pkh = void 0;
19
- var bitcoinjs_lib_1 = require("bitcoinjs-lib");
20
- var tiny_secp256k1_1 = require("tiny-secp256k1");
21
- var buffertools_1 = require("../buffertools");
22
- var constants_1 = require("../constants");
23
- var hashPublicKey_1 = require("../hashPublicKey");
24
- var BaseAccount = /** @class */ (function () {
25
- function BaseAccount(psbt, masterFp) {
26
- this.psbt = psbt;
27
- this.masterFp = masterFp;
28
- }
29
- return BaseAccount;
30
- }());
31
- /**
32
- * Superclass for single signature accounts. This will make sure that the pubkey
33
- * arrays and path arrays in the method arguments contains exactly one element
34
- * and calls an abstract method to do the actual work.
35
- */
36
- var SingleKeyAccount = /** @class */ (function (_super) {
37
- __extends(SingleKeyAccount, _super);
38
- function SingleKeyAccount() {
39
- return _super !== null && _super.apply(this, arguments) || this;
40
- }
41
- SingleKeyAccount.prototype.spendingCondition = function (pubkeys) {
42
- if (pubkeys.length != 1) {
43
- throw new Error("Expected single key, got " + pubkeys.length);
44
- }
45
- return this.singleKeyCondition(pubkeys[0]);
46
- };
47
- SingleKeyAccount.prototype.setInput = function (i, inputTx, spentOutput, pubkeys, pathElems) {
48
- if (pubkeys.length != 1) {
49
- throw new Error("Expected single key, got " + pubkeys.length);
50
- }
51
- if (pathElems.length != 1) {
52
- throw new Error("Expected single path, got " + pathElems.length);
53
- }
54
- this.setSingleKeyInput(i, inputTx, spentOutput, pubkeys[0], pathElems[0]);
55
- };
56
- SingleKeyAccount.prototype.setOwnOutput = function (i, cond, pubkeys, paths) {
57
- if (pubkeys.length != 1) {
58
- throw new Error("Expected single key, got " + pubkeys.length);
59
- }
60
- if (paths.length != 1) {
61
- throw new Error("Expected single path, got " + paths.length);
62
- }
63
- this.setSingleKeyOutput(i, cond, pubkeys[0], paths[0]);
64
- };
65
- return SingleKeyAccount;
66
- }(BaseAccount));
67
- var p2pkh = /** @class */ (function (_super) {
68
- __extends(p2pkh, _super);
69
- function p2pkh() {
70
- return _super !== null && _super.apply(this, arguments) || this;
71
- }
72
- p2pkh.prototype.singleKeyCondition = function (pubkey) {
73
- var buf = new buffertools_1.BufferWriter();
74
- var pubkeyHash = (0, hashPublicKey_1.hashPublicKey)(pubkey);
75
- buf.writeSlice(Buffer.from([constants_1.OP_DUP, constants_1.OP_HASH160, constants_1.HASH_SIZE]));
76
- buf.writeSlice(pubkeyHash);
77
- buf.writeSlice(Buffer.from([constants_1.OP_EQUALVERIFY, constants_1.OP_CHECKSIG]));
78
- return { scriptPubKey: buf.buffer() };
79
- };
80
- p2pkh.prototype.setSingleKeyInput = function (i, inputTx, _spentOutput, pubkey, path) {
81
- if (!inputTx) {
82
- throw new Error("Full input base transaction required");
83
- }
84
- this.psbt.setInputNonWitnessUtxo(i, inputTx);
85
- this.psbt.setInputBip32Derivation(i, pubkey, this.masterFp, path);
86
- };
87
- p2pkh.prototype.setSingleKeyOutput = function (i, cond, pubkey, path) {
88
- this.psbt.setOutputBip32Derivation(i, pubkey, this.masterFp, path);
89
- };
90
- p2pkh.prototype.getDescriptorTemplate = function () {
91
- return "pkh(@0)";
92
- };
93
- return p2pkh;
94
- }(SingleKeyAccount));
95
- exports.p2pkh = p2pkh;
96
- var p2tr = /** @class */ (function (_super) {
97
- __extends(p2tr, _super);
98
- function p2tr() {
99
- return _super !== null && _super.apply(this, arguments) || this;
100
- }
101
- p2tr.prototype.singleKeyCondition = function (pubkey) {
102
- var xonlyPubkey = pubkey.slice(1); // x-only pubkey
103
- var buf = new buffertools_1.BufferWriter();
104
- var outputKey = this.getTaprootOutputKey(xonlyPubkey);
105
- buf.writeSlice(Buffer.from([0x51, 32])); // push1, pubkeylen
106
- buf.writeSlice(outputKey);
107
- return { scriptPubKey: buf.buffer() };
108
- };
109
- p2tr.prototype.setSingleKeyInput = function (i, _inputTx, spentOutput, pubkey, path) {
110
- var xonly = pubkey.slice(1);
111
- this.psbt.setInputTapBip32Derivation(i, xonly, [], this.masterFp, path);
112
- this.psbt.setInputWitnessUtxo(i, spentOutput.amount, spentOutput.cond.scriptPubKey);
113
- };
114
- p2tr.prototype.setSingleKeyOutput = function (i, cond, pubkey, path) {
115
- var xonly = pubkey.slice(1);
116
- this.psbt.setOutputTapBip32Derivation(i, xonly, [], this.masterFp, path);
117
- };
118
- p2tr.prototype.getDescriptorTemplate = function () {
119
- return "tr(@0)";
120
- };
121
- /*
122
- The following two functions are copied from wallet-btc and adapted.
123
- They should be moved to a library to avoid code reuse.
124
- */
125
- p2tr.prototype.hashTapTweak = function (x) {
126
- // hash_tag(x) = SHA256(SHA256(tag) || SHA256(tag) || x), see BIP340
127
- // See https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki#specification
128
- var h = bitcoinjs_lib_1.crypto.sha256(Buffer.from("TapTweak", "utf-8"));
129
- return bitcoinjs_lib_1.crypto.sha256(Buffer.concat([h, h, x]));
130
- };
131
- /**
132
- * Calculates a taproot output key from an internal key. This output key will be
133
- * used as witness program in a taproot output. The internal key is tweaked
134
- * according to recommendation in BIP341:
135
- * https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_ref-22-0
136
- *
137
- * @param internalPubkey A 32 byte x-only taproot internal key
138
- * @returns The output key
139
- */
140
- p2tr.prototype.getTaprootOutputKey = function (internalPubkey) {
141
- if (internalPubkey.length != 32) {
142
- throw new Error("Expected 32 byte pubkey. Got " + internalPubkey.length);
143
- }
144
- // A BIP32 derived key can be converted to a schnorr pubkey by dropping
145
- // the first byte, which represent the oddness/evenness. In schnorr all
146
- // pubkeys are even.
147
- // https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki#public-key-conversion
148
- var evenEcdsaPubkey = Buffer.concat([
149
- Buffer.from([0x02]),
150
- internalPubkey,
151
- ]);
152
- var tweak = this.hashTapTweak(internalPubkey);
153
- // Q = P + int(hash_TapTweak(bytes(P)))G
154
- var outputEcdsaKey = Buffer.from((0, tiny_secp256k1_1.pointAddScalar)(evenEcdsaPubkey, tweak));
155
- // Convert to schnorr.
156
- var outputSchnorrKey = outputEcdsaKey.slice(1);
157
- // Create address
158
- return outputSchnorrKey;
159
- };
160
- return p2tr;
161
- }(SingleKeyAccount));
162
- exports.p2tr = p2tr;
163
- var p2wpkhWrapped = /** @class */ (function (_super) {
164
- __extends(p2wpkhWrapped, _super);
165
- function p2wpkhWrapped() {
166
- return _super !== null && _super.apply(this, arguments) || this;
167
- }
168
- p2wpkhWrapped.prototype.singleKeyCondition = function (pubkey) {
169
- var buf = new buffertools_1.BufferWriter();
170
- var redeemScript = this.createRedeemScript(pubkey);
171
- var scriptHash = (0, hashPublicKey_1.hashPublicKey)(redeemScript);
172
- buf.writeSlice(Buffer.from([constants_1.OP_HASH160, constants_1.HASH_SIZE]));
173
- buf.writeSlice(scriptHash);
174
- buf.writeUInt8(constants_1.OP_EQUAL);
175
- return { scriptPubKey: buf.buffer(), redeemScript: redeemScript };
176
- };
177
- p2wpkhWrapped.prototype.setSingleKeyInput = function (i, inputTx, spentOutput, pubkey, path) {
178
- if (!inputTx) {
179
- throw new Error("Full input base transaction required");
180
- }
181
- this.psbt.setInputNonWitnessUtxo(i, inputTx);
182
- this.psbt.setInputBip32Derivation(i, pubkey, this.masterFp, path);
183
- var userSuppliedRedeemScript = spentOutput.cond.redeemScript;
184
- var expectedRedeemScript = this.createRedeemScript(pubkey);
185
- if (userSuppliedRedeemScript &&
186
- !expectedRedeemScript.equals(userSuppliedRedeemScript)) {
187
- // At what point might a user set the redeemScript on its own?
188
- throw new Error("User-supplied redeemScript ".concat(userSuppliedRedeemScript.toString("hex"), " doesn't\n match expected ").concat(expectedRedeemScript.toString("hex"), " for input ").concat(i));
189
- }
190
- this.psbt.setInputRedeemScript(i, expectedRedeemScript);
191
- this.psbt.setInputWitnessUtxo(i, spentOutput.amount, spentOutput.cond.scriptPubKey);
192
- };
193
- p2wpkhWrapped.prototype.setSingleKeyOutput = function (i, cond, pubkey, path) {
194
- this.psbt.setOutputRedeemScript(i, cond.redeemScript);
195
- this.psbt.setOutputBip32Derivation(i, pubkey, this.masterFp, path);
196
- };
197
- p2wpkhWrapped.prototype.getDescriptorTemplate = function () {
198
- return "sh(wpkh(@0))";
199
- };
200
- p2wpkhWrapped.prototype.createRedeemScript = function (pubkey) {
201
- var pubkeyHash = (0, hashPublicKey_1.hashPublicKey)(pubkey);
202
- return Buffer.concat([Buffer.from("0014", "hex"), pubkeyHash]);
203
- };
204
- return p2wpkhWrapped;
205
- }(SingleKeyAccount));
206
- exports.p2wpkhWrapped = p2wpkhWrapped;
207
- var p2wpkh = /** @class */ (function (_super) {
208
- __extends(p2wpkh, _super);
209
- function p2wpkh() {
210
- return _super !== null && _super.apply(this, arguments) || this;
211
- }
212
- p2wpkh.prototype.singleKeyCondition = function (pubkey) {
213
- var buf = new buffertools_1.BufferWriter();
214
- var pubkeyHash = (0, hashPublicKey_1.hashPublicKey)(pubkey);
215
- buf.writeSlice(Buffer.from([0, constants_1.HASH_SIZE]));
216
- buf.writeSlice(pubkeyHash);
217
- return { scriptPubKey: buf.buffer() };
218
- };
219
- p2wpkh.prototype.setSingleKeyInput = function (i, inputTx, spentOutput, pubkey, path) {
220
- if (!inputTx) {
221
- throw new Error("Full input base transaction required");
222
- }
223
- this.psbt.setInputNonWitnessUtxo(i, inputTx);
224
- this.psbt.setInputBip32Derivation(i, pubkey, this.masterFp, path);
225
- this.psbt.setInputWitnessUtxo(i, spentOutput.amount, spentOutput.cond.scriptPubKey);
226
- };
227
- p2wpkh.prototype.setSingleKeyOutput = function (i, cond, pubkey, path) {
228
- this.psbt.setOutputBip32Derivation(i, pubkey, this.masterFp, path);
229
- };
230
- p2wpkh.prototype.getDescriptorTemplate = function () {
231
- return "wpkh(@0)";
232
- };
233
- return p2wpkh;
234
- }(SingleKeyAccount));
235
- exports.p2wpkh = p2wpkh;
236
- //# sourceMappingURL=accounttype.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"accounttype.js","sourceRoot":"","sources":["../../src/newops/accounttype.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+CAAuC;AACvC,iDAAgD;AAChD,8CAA8C;AAC9C,0CAOsB;AACtB,kDAAiD;AAyEjD;IACE,qBAAsB,IAAY,EAAY,QAAgB;QAAxC,SAAI,GAAJ,IAAI,CAAQ;QAAY,aAAQ,GAAR,QAAQ,CAAQ;IAAG,CAAC;IACpE,kBAAC;AAAD,CAAC,AAFD,IAEC;AAED;;;;GAIG;AACH;IAAwC,oCAAW;IAAnD;;IAoDA,CAAC;IAnDC,4CAAiB,GAAjB,UAAkB,OAAiB;QACjC,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;SAC/D;QACD,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;IAGD,mCAAQ,GAAR,UACE,CAAS,EACT,OAA2B,EAC3B,WAAwB,EACxB,OAAiB,EACjB,SAAqB;QAErB,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;SAC/D;QACD,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,SAAS,CAAC,MAAM,CAAC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CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACrE,CAAC;IAED,sCAAqB,GAArB;QACE,OAAO,UAAU,CAAC;IACpB,CAAC;IACH,aAAC;AAAD,CAAC,AAxCD,CAA4B,gBAAgB,GAwC3C;AAxCY,wBAAM"}
@@ -1,18 +0,0 @@
1
- /// <reference types="node" />
2
- import Transport from "@ledgerhq/hw-transport";
3
- import { PsbtV2 } from "./psbtv2";
4
- import { WalletPolicy } from "./policy";
5
- /**
6
- * This class encapsulates the APDU protocol documented at
7
- * https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md
8
- */
9
- export declare class AppClient {
10
- transport: Transport;
11
- constructor(transport: Transport);
12
- private makeRequest;
13
- getExtendedPubkey(display: boolean, pathElements: number[]): Promise<string>;
14
- getWalletAddress(walletPolicy: WalletPolicy, walletHMAC: Buffer | null, change: number, addressIndex: number, display: boolean): Promise<string>;
15
- signPsbt(psbt: PsbtV2, walletPolicy: WalletPolicy, walletHMAC: Buffer | null, progressCallback: () => void): Promise<Map<number, Buffer>>;
16
- getMasterFingerprint(): Promise<Buffer>;
17
- }
18
- //# sourceMappingURL=appClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"appClient.d.ts","sourceRoot":"","sources":["../../src/newops/appClient.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAoBxC;;;GAGG;AACH,qBAAa,SAAS;IACpB,SAAS,EAAE,SAAS,CAAC;gBAET,SAAS,EAAE,SAAS;YAIlB,WAAW;IA6BnB,iBAAiB,CACrB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,MAAM,CAAC;IAcZ,gBAAgB,CACpB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,CAAC;IAkCZ,QAAQ,CACZ,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,gBAAgB,EAAE,MAAM,IAAI,GAC3B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAuDzB,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;CAG9C"}
@@ -1,246 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- 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;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __values = (this && this.__values) || function(o) {
39
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
40
- if (m) return m.call(o);
41
- if (o && typeof o.length === "number") return {
42
- next: function () {
43
- if (o && i >= o.length) o = void 0;
44
- return { value: o && o[i++], done: !o };
45
- }
46
- };
47
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
48
- };
49
- exports.__esModule = true;
50
- exports.AppClient = void 0;
51
- var bip32_1 = require("../bip32");
52
- var merkelizedPsbt_1 = require("./merkelizedPsbt");
53
- var clientCommands_1 = require("./clientCommands");
54
- var varint_1 = require("../varint");
55
- var merkle_1 = require("./merkle");
56
- var CLA_BTC = 0xe1;
57
- var CLA_FRAMEWORK = 0xf8;
58
- var BitcoinIns;
59
- (function (BitcoinIns) {
60
- BitcoinIns[BitcoinIns["GET_PUBKEY"] = 0] = "GET_PUBKEY";
61
- // GET_ADDRESS = 0x01, // Removed from app
62
- BitcoinIns[BitcoinIns["REGISTER_WALLET"] = 2] = "REGISTER_WALLET";
63
- BitcoinIns[BitcoinIns["GET_WALLET_ADDRESS"] = 3] = "GET_WALLET_ADDRESS";
64
- BitcoinIns[BitcoinIns["SIGN_PSBT"] = 4] = "SIGN_PSBT";
65
- BitcoinIns[BitcoinIns["GET_MASTER_FINGERPRINT"] = 5] = "GET_MASTER_FINGERPRINT";
66
- })(BitcoinIns || (BitcoinIns = {}));
67
- var FrameworkIns;
68
- (function (FrameworkIns) {
69
- FrameworkIns[FrameworkIns["CONTINUE_INTERRUPTED"] = 1] = "CONTINUE_INTERRUPTED";
70
- })(FrameworkIns || (FrameworkIns = {}));
71
- /**
72
- * This class encapsulates the APDU protocol documented at
73
- * https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md
74
- */
75
- var AppClient = /** @class */ (function () {
76
- function AppClient(transport) {
77
- this.transport = transport;
78
- }
79
- AppClient.prototype.makeRequest = function (ins, data, cci) {
80
- return __awaiter(this, void 0, void 0, function () {
81
- var response, hwRequest, commandResponse;
82
- return __generator(this, function (_a) {
83
- switch (_a.label) {
84
- case 0: return [4 /*yield*/, this.transport.send(CLA_BTC, ins, 0, 0, data, [
85
- 0x9000,
86
- 0xe000,
87
- ])];
88
- case 1:
89
- response = _a.sent();
90
- _a.label = 2;
91
- case 2:
92
- if (!(response.readUInt16BE(response.length - 2) === 0xe000)) return [3 /*break*/, 4];
93
- if (!cci) {
94
- throw new Error("Unexpected SW_INTERRUPTED_EXECUTION");
95
- }
96
- hwRequest = response.slice(0, -2);
97
- commandResponse = cci.execute(hwRequest);
98
- return [4 /*yield*/, this.transport.send(CLA_FRAMEWORK, FrameworkIns.CONTINUE_INTERRUPTED, 0, 0, commandResponse, [0x9000, 0xe000])];
99
- case 3:
100
- response = _a.sent();
101
- return [3 /*break*/, 2];
102
- case 4: return [2 /*return*/, response.slice(0, -2)]; // drop the status word (can only be 0x9000 at this point)
103
- }
104
- });
105
- });
106
- };
107
- AppClient.prototype.getExtendedPubkey = function (display, pathElements) {
108
- return __awaiter(this, void 0, void 0, function () {
109
- var response;
110
- return __generator(this, function (_a) {
111
- switch (_a.label) {
112
- case 0:
113
- if (pathElements.length > 6) {
114
- throw new Error("Path too long. At most 6 levels allowed.");
115
- }
116
- return [4 /*yield*/, this.makeRequest(BitcoinIns.GET_PUBKEY, Buffer.concat([
117
- Buffer.from(display ? [1] : [0]),
118
- (0, bip32_1.pathElementsToBuffer)(pathElements),
119
- ]))];
120
- case 1:
121
- response = _a.sent();
122
- return [2 /*return*/, response.toString("ascii")];
123
- }
124
- });
125
- });
126
- };
127
- AppClient.prototype.getWalletAddress = function (walletPolicy, walletHMAC, change, addressIndex, display) {
128
- return __awaiter(this, void 0, void 0, function () {
129
- var clientInterpreter, addressIndexBuffer, response;
130
- return __generator(this, function (_a) {
131
- switch (_a.label) {
132
- case 0:
133
- if (change !== 0 && change !== 1)
134
- throw new Error("Change can only be 0 or 1");
135
- if (addressIndex < 0 || !Number.isInteger(addressIndex))
136
- throw new Error("Invalid address index");
137
- if (walletHMAC != null && walletHMAC.length != 32) {
138
- throw new Error("Invalid HMAC length");
139
- }
140
- clientInterpreter = new clientCommands_1.ClientCommandInterpreter(function () { });
141
- clientInterpreter.addKnownList(walletPolicy.keys.map(function (k) { return Buffer.from(k, "ascii"); }));
142
- clientInterpreter.addKnownPreimage(walletPolicy.serialize());
143
- addressIndexBuffer = Buffer.alloc(4);
144
- addressIndexBuffer.writeUInt32BE(addressIndex, 0);
145
- return [4 /*yield*/, this.makeRequest(BitcoinIns.GET_WALLET_ADDRESS, Buffer.concat([
146
- Buffer.from(display ? [1] : [0]),
147
- walletPolicy.getWalletId(),
148
- walletHMAC || Buffer.alloc(32, 0),
149
- Buffer.from([change]),
150
- addressIndexBuffer,
151
- ]), clientInterpreter)];
152
- case 1:
153
- response = _a.sent();
154
- return [2 /*return*/, response.toString("ascii")];
155
- }
156
- });
157
- });
158
- };
159
- AppClient.prototype.signPsbt = function (psbt, walletPolicy, walletHMAC, progressCallback) {
160
- return __awaiter(this, void 0, void 0, function () {
161
- var merkelizedPsbt, clientInterpreter, _a, _b, map, _c, _d, map, inputMapsRoot, outputMapsRoot, yielded, ret, yielded_1, yielded_1_1, inputAndSig;
162
- var e_1, _e, e_2, _f, e_3, _g;
163
- return __generator(this, function (_h) {
164
- switch (_h.label) {
165
- case 0:
166
- merkelizedPsbt = new merkelizedPsbt_1.MerkelizedPsbt(psbt);
167
- if (walletHMAC != null && walletHMAC.length != 32) {
168
- throw new Error("Invalid HMAC length");
169
- }
170
- clientInterpreter = new clientCommands_1.ClientCommandInterpreter(progressCallback);
171
- // prepare ClientCommandInterpreter
172
- clientInterpreter.addKnownList(walletPolicy.keys.map(function (k) { return Buffer.from(k, "ascii"); }));
173
- clientInterpreter.addKnownPreimage(walletPolicy.serialize());
174
- clientInterpreter.addKnownMapping(merkelizedPsbt.globalMerkleMap);
175
- try {
176
- for (_a = __values(merkelizedPsbt.inputMerkleMaps), _b = _a.next(); !_b.done; _b = _a.next()) {
177
- map = _b.value;
178
- clientInterpreter.addKnownMapping(map);
179
- }
180
- }
181
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
182
- finally {
183
- try {
184
- if (_b && !_b.done && (_e = _a["return"])) _e.call(_a);
185
- }
186
- finally { if (e_1) throw e_1.error; }
187
- }
188
- try {
189
- for (_c = __values(merkelizedPsbt.outputMerkleMaps), _d = _c.next(); !_d.done; _d = _c.next()) {
190
- map = _d.value;
191
- clientInterpreter.addKnownMapping(map);
192
- }
193
- }
194
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
195
- finally {
196
- try {
197
- if (_d && !_d.done && (_f = _c["return"])) _f.call(_c);
198
- }
199
- finally { if (e_2) throw e_2.error; }
200
- }
201
- clientInterpreter.addKnownList(merkelizedPsbt.inputMapCommitments);
202
- inputMapsRoot = new merkle_1.Merkle(merkelizedPsbt.inputMapCommitments.map(function (m) { return (0, merkle_1.hashLeaf)(m); })).getRoot();
203
- clientInterpreter.addKnownList(merkelizedPsbt.outputMapCommitments);
204
- outputMapsRoot = new merkle_1.Merkle(merkelizedPsbt.outputMapCommitments.map(function (m) { return (0, merkle_1.hashLeaf)(m); })).getRoot();
205
- return [4 /*yield*/, this.makeRequest(BitcoinIns.SIGN_PSBT, Buffer.concat([
206
- merkelizedPsbt.getGlobalKeysValuesRoot(),
207
- (0, varint_1.createVarint)(merkelizedPsbt.getGlobalInputCount()),
208
- inputMapsRoot,
209
- (0, varint_1.createVarint)(merkelizedPsbt.getGlobalOutputCount()),
210
- outputMapsRoot,
211
- walletPolicy.getWalletId(),
212
- walletHMAC || Buffer.alloc(32, 0),
213
- ]), clientInterpreter)];
214
- case 1:
215
- _h.sent();
216
- yielded = clientInterpreter.getYielded();
217
- ret = new Map();
218
- try {
219
- for (yielded_1 = __values(yielded), yielded_1_1 = yielded_1.next(); !yielded_1_1.done; yielded_1_1 = yielded_1.next()) {
220
- inputAndSig = yielded_1_1.value;
221
- ret.set(inputAndSig[0], inputAndSig.slice(1));
222
- }
223
- }
224
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
225
- finally {
226
- try {
227
- if (yielded_1_1 && !yielded_1_1.done && (_g = yielded_1["return"])) _g.call(yielded_1);
228
- }
229
- finally { if (e_3) throw e_3.error; }
230
- }
231
- return [2 /*return*/, ret];
232
- }
233
- });
234
- });
235
- };
236
- AppClient.prototype.getMasterFingerprint = function () {
237
- return __awaiter(this, void 0, void 0, function () {
238
- return __generator(this, function (_a) {
239
- return [2 /*return*/, this.makeRequest(BitcoinIns.GET_MASTER_FINGERPRINT, Buffer.from([]))];
240
- });
241
- });
242
- };
243
- return AppClient;
244
- }());
245
- exports.AppClient = AppClient;
246
- //# sourceMappingURL=appClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"appClient.js","sourceRoot":"","sources":["../../src/newops/appClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kCAAgD;AAEhD,mDAAkD;AAClD,mDAA4D;AAE5D,oCAAyC;AACzC,mCAA4C;AAE5C,IAAM,OAAO,GAAG,IAAI,CAA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