@ledgerhq/hw-app-btc 6.21.0 → 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 (290) hide show
  1. package/.turbo/turbo-build.log +1 -0
  2. package/CHANGELOG.md +10 -0
  3. package/README.md +4 -4
  4. package/jest.config.ts +6 -0
  5. package/package.json +15 -6
  6. package/src/bip32.ts +5 -3
  7. package/src/getTrustedInput.ts +2 -8
  8. package/src/newops/appClient.ts +8 -4
  9. package/src/newops/psbtv2.ts +13 -9
  10. package/LICENSE +0 -202
  11. package/lib/Btc.d.ts +0 -149
  12. package/lib/Btc.d.ts.map +0 -1
  13. package/lib/Btc.js +0 -353
  14. package/lib/Btc.js.map +0 -1
  15. package/lib/BtcNew.d.ts +0 -122
  16. package/lib/BtcNew.d.ts.map +0 -1
  17. package/lib/BtcNew.js +0 -451
  18. package/lib/BtcNew.js.map +0 -1
  19. package/lib/BtcOld.d.ts +0 -120
  20. package/lib/BtcOld.d.ts.map +0 -1
  21. package/lib/BtcOld.js +0 -263
  22. package/lib/BtcOld.js.map +0 -1
  23. package/lib/bip32.d.ts +0 -13
  24. package/lib/bip32.d.ts.map +0 -1
  25. package/lib/bip32.js +0 -57
  26. package/lib/bip32.js.map +0 -1
  27. package/lib/buffertools.d.ts +0 -30
  28. package/lib/buffertools.d.ts.map +0 -1
  29. package/lib/buffertools.js +0 -132
  30. package/lib/buffertools.js.map +0 -1
  31. package/lib/compressPublicKey.d.ts +0 -3
  32. package/lib/compressPublicKey.d.ts.map +0 -1
  33. package/lib/compressPublicKey.js +0 -11
  34. package/lib/compressPublicKey.js.map +0 -1
  35. package/lib/constants.d.ts +0 -13
  36. package/lib/constants.d.ts.map +0 -1
  37. package/lib/constants.js +0 -17
  38. package/lib/constants.js.map +0 -1
  39. package/lib/createTransaction.d.ts +0 -35
  40. package/lib/createTransaction.d.ts.map +0 -1
  41. package/lib/createTransaction.js +0 -411
  42. package/lib/createTransaction.js.map +0 -1
  43. package/lib/debug.d.ts +0 -4
  44. package/lib/debug.d.ts.map +0 -1
  45. package/lib/debug.js +0 -45
  46. package/lib/debug.js.map +0 -1
  47. package/lib/finalizeInput.d.ts +0 -5
  48. package/lib/finalizeInput.d.ts.map +0 -1
  49. package/lib/finalizeInput.js +0 -81
  50. package/lib/finalizeInput.js.map +0 -1
  51. package/lib/getAppAndVersion.d.ts +0 -9
  52. package/lib/getAppAndVersion.d.ts.map +0 -1
  53. package/lib/getAppAndVersion.js +0 -69
  54. package/lib/getAppAndVersion.js.map +0 -1
  55. package/lib/getTrustedInput.d.ts +0 -6
  56. package/lib/getTrustedInput.d.ts.map +0 -1
  57. package/lib/getTrustedInput.js +0 -275
  58. package/lib/getTrustedInput.js.map +0 -1
  59. package/lib/getTrustedInputBIP143.d.ts +0 -4
  60. package/lib/getTrustedInputBIP143.d.ts.map +0 -1
  61. package/lib/getTrustedInputBIP143.js +0 -34
  62. package/lib/getTrustedInputBIP143.js.map +0 -1
  63. package/lib/getWalletPublicKey.d.ts +0 -15
  64. package/lib/getWalletPublicKey.d.ts.map +0 -1
  65. package/lib/getWalletPublicKey.js +0 -93
  66. package/lib/getWalletPublicKey.js.map +0 -1
  67. package/lib/hashPublicKey.d.ts +0 -3
  68. package/lib/hashPublicKey.d.ts.map +0 -1
  69. package/lib/hashPublicKey.js +0 -13
  70. package/lib/hashPublicKey.js.map +0 -1
  71. package/lib/index.d.ts +0 -3
  72. package/lib/index.d.ts.map +0 -1
  73. package/lib/index.js +0 -8
  74. package/lib/index.js.map +0 -1
  75. package/lib/newops/accounttype.d.ts +0 -110
  76. package/lib/newops/accounttype.d.ts.map +0 -1
  77. package/lib/newops/accounttype.js +0 -236
  78. package/lib/newops/accounttype.js.map +0 -1
  79. package/lib/newops/appClient.d.ts +0 -18
  80. package/lib/newops/appClient.d.ts.map +0 -1
  81. package/lib/newops/appClient.js +0 -246
  82. package/lib/newops/appClient.js.map +0 -1
  83. package/lib/newops/clientCommands.d.ts +0 -77
  84. package/lib/newops/clientCommands.d.ts.map +0 -1
  85. package/lib/newops/clientCommands.js +0 -353
  86. package/lib/newops/clientCommands.js.map +0 -1
  87. package/lib/newops/merkelizedPsbt.d.ts +0 -26
  88. package/lib/newops/merkelizedPsbt.d.ts.map +0 -1
  89. package/lib/newops/merkelizedPsbt.js +0 -102
  90. package/lib/newops/merkelizedPsbt.js.map +0 -1
  91. package/lib/newops/merkle.d.ts +0 -34
  92. package/lib/newops/merkle.d.ts.map +0 -1
  93. package/lib/newops/merkle.js +0 -138
  94. package/lib/newops/merkle.js.map +0 -1
  95. package/lib/newops/merkleMap.d.ts +0 -25
  96. package/lib/newops/merkleMap.d.ts.map +0 -1
  97. package/lib/newops/merkleMap.js +0 -47
  98. package/lib/newops/merkleMap.js.map +0 -1
  99. package/lib/newops/policy.d.ts +0 -22
  100. package/lib/newops/policy.d.ts.map +0 -1
  101. package/lib/newops/policy.js +0 -48
  102. package/lib/newops/policy.js.map +0 -1
  103. package/lib/newops/psbtExtractor.d.ts +0 -10
  104. package/lib/newops/psbtExtractor.d.ts.map +0 -1
  105. package/lib/newops/psbtExtractor.js +0 -42
  106. package/lib/newops/psbtExtractor.js.map +0 -1
  107. package/lib/newops/psbtFinalizer.d.ts +0 -17
  108. package/lib/newops/psbtFinalizer.d.ts.map +0 -1
  109. package/lib/newops/psbtFinalizer.js +0 -135
  110. package/lib/newops/psbtFinalizer.js.map +0 -1
  111. package/lib/newops/psbtv2.d.ts +0 -149
  112. package/lib/newops/psbtv2.d.ts.map +0 -1
  113. package/lib/newops/psbtv2.js +0 -506
  114. package/lib/newops/psbtv2.js.map +0 -1
  115. package/lib/serializeTransaction.d.ts +0 -10
  116. package/lib/serializeTransaction.d.ts.map +0 -1
  117. package/lib/serializeTransaction.js +0 -72
  118. package/lib/serializeTransaction.js.map +0 -1
  119. package/lib/shouldUseTrustedInputForSegwit.d.ts +0 -5
  120. package/lib/shouldUseTrustedInputForSegwit.d.ts.map +0 -1
  121. package/lib/shouldUseTrustedInputForSegwit.js +0 -17
  122. package/lib/shouldUseTrustedInputForSegwit.js.map +0 -1
  123. package/lib/signMessage.d.ts +0 -10
  124. package/lib/signMessage.d.ts.map +0 -1
  125. package/lib/signMessage.js +0 -118
  126. package/lib/signMessage.js.map +0 -1
  127. package/lib/signP2SHTransaction.d.ts +0 -21
  128. package/lib/signP2SHTransaction.d.ts.map +0 -1
  129. package/lib/signP2SHTransaction.js +0 -208
  130. package/lib/signP2SHTransaction.js.map +0 -1
  131. package/lib/signTransaction.d.ts +0 -4
  132. package/lib/signTransaction.d.ts.map +0 -1
  133. package/lib/signTransaction.js +0 -36
  134. package/lib/signTransaction.js.map +0 -1
  135. package/lib/splitTransaction.d.ts +0 -3
  136. package/lib/splitTransaction.d.ts.map +0 -1
  137. package/lib/splitTransaction.js +0 -142
  138. package/lib/splitTransaction.js.map +0 -1
  139. package/lib/startUntrustedHashTransactionInput.d.ts +0 -9
  140. package/lib/startUntrustedHashTransactionInput.d.ts.map +0 -1
  141. package/lib/startUntrustedHashTransactionInput.js +0 -197
  142. package/lib/startUntrustedHashTransactionInput.js.map +0 -1
  143. package/lib/types.d.ts +0 -34
  144. package/lib/types.d.ts.map +0 -1
  145. package/lib/types.js +0 -3
  146. package/lib/types.js.map +0 -1
  147. package/lib/varint.d.ts +0 -4
  148. package/lib/varint.d.ts.map +0 -1
  149. package/lib/varint.js +0 -45
  150. package/lib/varint.js.map +0 -1
  151. package/lib-es/Btc.d.ts +0 -149
  152. package/lib-es/Btc.d.ts.map +0 -1
  153. package/lib-es/Btc.js +0 -329
  154. package/lib-es/Btc.js.map +0 -1
  155. package/lib-es/BtcNew.d.ts +0 -122
  156. package/lib-es/BtcNew.d.ts.map +0 -1
  157. package/lib-es/BtcNew.js +0 -444
  158. package/lib-es/BtcNew.js.map +0 -1
  159. package/lib-es/BtcOld.d.ts +0 -120
  160. package/lib-es/BtcOld.d.ts.map +0 -1
  161. package/lib-es/BtcOld.js +0 -258
  162. package/lib-es/BtcOld.js.map +0 -1
  163. package/lib-es/bip32.d.ts +0 -13
  164. package/lib-es/bip32.d.ts.map +0 -1
  165. package/lib-es/bip32.js +0 -44
  166. package/lib-es/bip32.js.map +0 -1
  167. package/lib-es/buffertools.d.ts +0 -30
  168. package/lib-es/buffertools.d.ts.map +0 -1
  169. package/lib-es/buffertools.js +0 -124
  170. package/lib-es/buffertools.js.map +0 -1
  171. package/lib-es/compressPublicKey.d.ts +0 -3
  172. package/lib-es/compressPublicKey.d.ts.map +0 -1
  173. package/lib-es/compressPublicKey.js +0 -7
  174. package/lib-es/compressPublicKey.js.map +0 -1
  175. package/lib-es/constants.d.ts +0 -13
  176. package/lib-es/constants.d.ts.map +0 -1
  177. package/lib-es/constants.js +0 -14
  178. package/lib-es/constants.js.map +0 -1
  179. package/lib-es/createTransaction.d.ts +0 -35
  180. package/lib-es/createTransaction.d.ts.map +0 -1
  181. package/lib-es/createTransaction.js +0 -407
  182. package/lib-es/createTransaction.js.map +0 -1
  183. package/lib-es/debug.d.ts +0 -4
  184. package/lib-es/debug.d.ts.map +0 -1
  185. package/lib-es/debug.js +0 -40
  186. package/lib-es/debug.js.map +0 -1
  187. package/lib-es/finalizeInput.d.ts +0 -5
  188. package/lib-es/finalizeInput.d.ts.map +0 -1
  189. package/lib-es/finalizeInput.js +0 -76
  190. package/lib-es/finalizeInput.js.map +0 -1
  191. package/lib-es/getAppAndVersion.d.ts +0 -9
  192. package/lib-es/getAppAndVersion.d.ts.map +0 -1
  193. package/lib-es/getAppAndVersion.js +0 -62
  194. package/lib-es/getAppAndVersion.js.map +0 -1
  195. package/lib-es/getTrustedInput.d.ts +0 -6
  196. package/lib-es/getTrustedInput.d.ts.map +0 -1
  197. package/lib-es/getTrustedInput.js +0 -267
  198. package/lib-es/getTrustedInput.js.map +0 -1
  199. package/lib-es/getTrustedInputBIP143.d.ts +0 -4
  200. package/lib-es/getTrustedInputBIP143.d.ts.map +0 -1
  201. package/lib-es/getTrustedInputBIP143.js +0 -27
  202. package/lib-es/getTrustedInputBIP143.js.map +0 -1
  203. package/lib-es/getWalletPublicKey.d.ts +0 -15
  204. package/lib-es/getWalletPublicKey.d.ts.map +0 -1
  205. package/lib-es/getWalletPublicKey.js +0 -89
  206. package/lib-es/getWalletPublicKey.js.map +0 -1
  207. package/lib-es/hashPublicKey.d.ts +0 -3
  208. package/lib-es/hashPublicKey.d.ts.map +0 -1
  209. package/lib-es/hashPublicKey.js +0 -6
  210. package/lib-es/hashPublicKey.js.map +0 -1
  211. package/lib-es/index.d.ts +0 -3
  212. package/lib-es/index.d.ts.map +0 -1
  213. package/lib-es/index.js +0 -3
  214. package/lib-es/index.js.map +0 -1
  215. package/lib-es/newops/accounttype.d.ts +0 -110
  216. package/lib-es/newops/accounttype.d.ts.map +0 -1
  217. package/lib-es/newops/accounttype.js +0 -233
  218. package/lib-es/newops/accounttype.js.map +0 -1
  219. package/lib-es/newops/appClient.d.ts +0 -18
  220. package/lib-es/newops/appClient.d.ts.map +0 -1
  221. package/lib-es/newops/appClient.js +0 -243
  222. package/lib-es/newops/appClient.js.map +0 -1
  223. package/lib-es/newops/clientCommands.d.ts +0 -77
  224. package/lib-es/newops/clientCommands.d.ts.map +0 -1
  225. package/lib-es/newops/clientCommands.js +0 -350
  226. package/lib-es/newops/clientCommands.js.map +0 -1
  227. package/lib-es/newops/merkelizedPsbt.d.ts +0 -26
  228. package/lib-es/newops/merkelizedPsbt.d.ts.map +0 -1
  229. package/lib-es/newops/merkelizedPsbt.js +0 -99
  230. package/lib-es/newops/merkelizedPsbt.js.map +0 -1
  231. package/lib-es/newops/merkle.d.ts +0 -34
  232. package/lib-es/newops/merkle.d.ts.map +0 -1
  233. package/lib-es/newops/merkle.js +0 -134
  234. package/lib-es/newops/merkle.js.map +0 -1
  235. package/lib-es/newops/merkleMap.d.ts +0 -25
  236. package/lib-es/newops/merkleMap.d.ts.map +0 -1
  237. package/lib-es/newops/merkleMap.js +0 -44
  238. package/lib-es/newops/merkleMap.js.map +0 -1
  239. package/lib-es/newops/policy.d.ts +0 -22
  240. package/lib-es/newops/policy.d.ts.map +0 -1
  241. package/lib-es/newops/policy.js +0 -44
  242. package/lib-es/newops/policy.js.map +0 -1
  243. package/lib-es/newops/psbtExtractor.d.ts +0 -10
  244. package/lib-es/newops/psbtExtractor.d.ts.map +0 -1
  245. package/lib-es/newops/psbtExtractor.js +0 -38
  246. package/lib-es/newops/psbtExtractor.js.map +0 -1
  247. package/lib-es/newops/psbtFinalizer.d.ts +0 -17
  248. package/lib-es/newops/psbtFinalizer.d.ts.map +0 -1
  249. package/lib-es/newops/psbtFinalizer.js +0 -131
  250. package/lib-es/newops/psbtFinalizer.js.map +0 -1
  251. package/lib-es/newops/psbtv2.d.ts +0 -149
  252. package/lib-es/newops/psbtv2.d.ts.map +0 -1
  253. package/lib-es/newops/psbtv2.js +0 -503
  254. package/lib-es/newops/psbtv2.js.map +0 -1
  255. package/lib-es/serializeTransaction.d.ts +0 -10
  256. package/lib-es/serializeTransaction.d.ts.map +0 -1
  257. package/lib-es/serializeTransaction.js +0 -67
  258. package/lib-es/serializeTransaction.js.map +0 -1
  259. package/lib-es/shouldUseTrustedInputForSegwit.d.ts +0 -5
  260. package/lib-es/shouldUseTrustedInputForSegwit.d.ts.map +0 -1
  261. package/lib-es/shouldUseTrustedInputForSegwit.js +0 -10
  262. package/lib-es/shouldUseTrustedInputForSegwit.js.map +0 -1
  263. package/lib-es/signMessage.d.ts +0 -10
  264. package/lib-es/signMessage.d.ts.map +0 -1
  265. package/lib-es/signMessage.js +0 -111
  266. package/lib-es/signMessage.js.map +0 -1
  267. package/lib-es/signP2SHTransaction.d.ts +0 -21
  268. package/lib-es/signP2SHTransaction.d.ts.map +0 -1
  269. package/lib-es/signP2SHTransaction.js +0 -204
  270. package/lib-es/signP2SHTransaction.js.map +0 -1
  271. package/lib-es/signTransaction.d.ts +0 -4
  272. package/lib-es/signTransaction.d.ts.map +0 -1
  273. package/lib-es/signTransaction.js +0 -32
  274. package/lib-es/signTransaction.js.map +0 -1
  275. package/lib-es/splitTransaction.d.ts +0 -3
  276. package/lib-es/splitTransaction.d.ts.map +0 -1
  277. package/lib-es/splitTransaction.js +0 -138
  278. package/lib-es/splitTransaction.js.map +0 -1
  279. package/lib-es/startUntrustedHashTransactionInput.d.ts +0 -9
  280. package/lib-es/startUntrustedHashTransactionInput.d.ts.map +0 -1
  281. package/lib-es/startUntrustedHashTransactionInput.js +0 -192
  282. package/lib-es/startUntrustedHashTransactionInput.js.map +0 -1
  283. package/lib-es/types.d.ts +0 -34
  284. package/lib-es/types.d.ts.map +0 -1
  285. package/lib-es/types.js +0 -2
  286. package/lib-es/types.js.map +0 -1
  287. package/lib-es/varint.d.ts +0 -4
  288. package/lib-es/varint.d.ts.map +0 -1
  289. package/lib-es/varint.js +0 -40
  290. 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 @@
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
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- import { crypto } from "bitcoinjs-lib";
17
- import { pointAddScalar } from "tiny-secp256k1";
18
- import { BufferWriter } from "../buffertools";
19
- import { HASH_SIZE, OP_CHECKSIG, OP_DUP, OP_EQUAL, OP_EQUALVERIFY, OP_HASH160, } from "../constants";
20
- import { hashPublicKey } from "../hashPublicKey";
21
- var BaseAccount = /** @class */ (function () {
22
- function BaseAccount(psbt, masterFp) {
23
- this.psbt = psbt;
24
- this.masterFp = masterFp;
25
- }
26
- return BaseAccount;
27
- }());
28
- /**
29
- * Superclass for single signature accounts. This will make sure that the pubkey
30
- * arrays and path arrays in the method arguments contains exactly one element
31
- * and calls an abstract method to do the actual work.
32
- */
33
- var SingleKeyAccount = /** @class */ (function (_super) {
34
- __extends(SingleKeyAccount, _super);
35
- function SingleKeyAccount() {
36
- return _super !== null && _super.apply(this, arguments) || this;
37
- }
38
- SingleKeyAccount.prototype.spendingCondition = function (pubkeys) {
39
- if (pubkeys.length != 1) {
40
- throw new Error("Expected single key, got " + pubkeys.length);
41
- }
42
- return this.singleKeyCondition(pubkeys[0]);
43
- };
44
- SingleKeyAccount.prototype.setInput = function (i, inputTx, spentOutput, pubkeys, pathElems) {
45
- if (pubkeys.length != 1) {
46
- throw new Error("Expected single key, got " + pubkeys.length);
47
- }
48
- if (pathElems.length != 1) {
49
- throw new Error("Expected single path, got " + pathElems.length);
50
- }
51
- this.setSingleKeyInput(i, inputTx, spentOutput, pubkeys[0], pathElems[0]);
52
- };
53
- SingleKeyAccount.prototype.setOwnOutput = function (i, cond, pubkeys, paths) {
54
- if (pubkeys.length != 1) {
55
- throw new Error("Expected single key, got " + pubkeys.length);
56
- }
57
- if (paths.length != 1) {
58
- throw new Error("Expected single path, got " + paths.length);
59
- }
60
- this.setSingleKeyOutput(i, cond, pubkeys[0], paths[0]);
61
- };
62
- return SingleKeyAccount;
63
- }(BaseAccount));
64
- var p2pkh = /** @class */ (function (_super) {
65
- __extends(p2pkh, _super);
66
- function p2pkh() {
67
- return _super !== null && _super.apply(this, arguments) || this;
68
- }
69
- p2pkh.prototype.singleKeyCondition = function (pubkey) {
70
- var buf = new BufferWriter();
71
- var pubkeyHash = hashPublicKey(pubkey);
72
- buf.writeSlice(Buffer.from([OP_DUP, OP_HASH160, HASH_SIZE]));
73
- buf.writeSlice(pubkeyHash);
74
- buf.writeSlice(Buffer.from([OP_EQUALVERIFY, OP_CHECKSIG]));
75
- return { scriptPubKey: buf.buffer() };
76
- };
77
- p2pkh.prototype.setSingleKeyInput = function (i, inputTx, _spentOutput, pubkey, path) {
78
- if (!inputTx) {
79
- throw new Error("Full input base transaction required");
80
- }
81
- this.psbt.setInputNonWitnessUtxo(i, inputTx);
82
- this.psbt.setInputBip32Derivation(i, pubkey, this.masterFp, path);
83
- };
84
- p2pkh.prototype.setSingleKeyOutput = function (i, cond, pubkey, path) {
85
- this.psbt.setOutputBip32Derivation(i, pubkey, this.masterFp, path);
86
- };
87
- p2pkh.prototype.getDescriptorTemplate = function () {
88
- return "pkh(@0)";
89
- };
90
- return p2pkh;
91
- }(SingleKeyAccount));
92
- export { p2pkh };
93
- var p2tr = /** @class */ (function (_super) {
94
- __extends(p2tr, _super);
95
- function p2tr() {
96
- return _super !== null && _super.apply(this, arguments) || this;
97
- }
98
- p2tr.prototype.singleKeyCondition = function (pubkey) {
99
- var xonlyPubkey = pubkey.slice(1); // x-only pubkey
100
- var buf = new BufferWriter();
101
- var outputKey = this.getTaprootOutputKey(xonlyPubkey);
102
- buf.writeSlice(Buffer.from([0x51, 32])); // push1, pubkeylen
103
- buf.writeSlice(outputKey);
104
- return { scriptPubKey: buf.buffer() };
105
- };
106
- p2tr.prototype.setSingleKeyInput = function (i, _inputTx, spentOutput, pubkey, path) {
107
- var xonly = pubkey.slice(1);
108
- this.psbt.setInputTapBip32Derivation(i, xonly, [], this.masterFp, path);
109
- this.psbt.setInputWitnessUtxo(i, spentOutput.amount, spentOutput.cond.scriptPubKey);
110
- };
111
- p2tr.prototype.setSingleKeyOutput = function (i, cond, pubkey, path) {
112
- var xonly = pubkey.slice(1);
113
- this.psbt.setOutputTapBip32Derivation(i, xonly, [], this.masterFp, path);
114
- };
115
- p2tr.prototype.getDescriptorTemplate = function () {
116
- return "tr(@0)";
117
- };
118
- /*
119
- The following two functions are copied from wallet-btc and adapted.
120
- They should be moved to a library to avoid code reuse.
121
- */
122
- p2tr.prototype.hashTapTweak = function (x) {
123
- // hash_tag(x) = SHA256(SHA256(tag) || SHA256(tag) || x), see BIP340
124
- // See https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki#specification
125
- var h = crypto.sha256(Buffer.from("TapTweak", "utf-8"));
126
- return crypto.sha256(Buffer.concat([h, h, x]));
127
- };
128
- /**
129
- * Calculates a taproot output key from an internal key. This output key will be
130
- * used as witness program in a taproot output. The internal key is tweaked
131
- * according to recommendation in BIP341:
132
- * https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_ref-22-0
133
- *
134
- * @param internalPubkey A 32 byte x-only taproot internal key
135
- * @returns The output key
136
- */
137
- p2tr.prototype.getTaprootOutputKey = function (internalPubkey) {
138
- if (internalPubkey.length != 32) {
139
- throw new Error("Expected 32 byte pubkey. Got " + internalPubkey.length);
140
- }
141
- // A BIP32 derived key can be converted to a schnorr pubkey by dropping
142
- // the first byte, which represent the oddness/evenness. In schnorr all
143
- // pubkeys are even.
144
- // https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki#public-key-conversion
145
- var evenEcdsaPubkey = Buffer.concat([
146
- Buffer.from([0x02]),
147
- internalPubkey,
148
- ]);
149
- var tweak = this.hashTapTweak(internalPubkey);
150
- // Q = P + int(hash_TapTweak(bytes(P)))G
151
- var outputEcdsaKey = Buffer.from(pointAddScalar(evenEcdsaPubkey, tweak));
152
- // Convert to schnorr.
153
- var outputSchnorrKey = outputEcdsaKey.slice(1);
154
- // Create address
155
- return outputSchnorrKey;
156
- };
157
- return p2tr;
158
- }(SingleKeyAccount));
159
- export { p2tr };
160
- var p2wpkhWrapped = /** @class */ (function (_super) {
161
- __extends(p2wpkhWrapped, _super);
162
- function p2wpkhWrapped() {
163
- return _super !== null && _super.apply(this, arguments) || this;
164
- }
165
- p2wpkhWrapped.prototype.singleKeyCondition = function (pubkey) {
166
- var buf = new BufferWriter();
167
- var redeemScript = this.createRedeemScript(pubkey);
168
- var scriptHash = hashPublicKey(redeemScript);
169
- buf.writeSlice(Buffer.from([OP_HASH160, HASH_SIZE]));
170
- buf.writeSlice(scriptHash);
171
- buf.writeUInt8(OP_EQUAL);
172
- return { scriptPubKey: buf.buffer(), redeemScript: redeemScript };
173
- };
174
- p2wpkhWrapped.prototype.setSingleKeyInput = function (i, inputTx, spentOutput, pubkey, path) {
175
- if (!inputTx) {
176
- throw new Error("Full input base transaction required");
177
- }
178
- this.psbt.setInputNonWitnessUtxo(i, inputTx);
179
- this.psbt.setInputBip32Derivation(i, pubkey, this.masterFp, path);
180
- var userSuppliedRedeemScript = spentOutput.cond.redeemScript;
181
- var expectedRedeemScript = this.createRedeemScript(pubkey);
182
- if (userSuppliedRedeemScript &&
183
- !expectedRedeemScript.equals(userSuppliedRedeemScript)) {
184
- // At what point might a user set the redeemScript on its own?
185
- throw new Error("User-supplied redeemScript ".concat(userSuppliedRedeemScript.toString("hex"), " doesn't\n match expected ").concat(expectedRedeemScript.toString("hex"), " for input ").concat(i));
186
- }
187
- this.psbt.setInputRedeemScript(i, expectedRedeemScript);
188
- this.psbt.setInputWitnessUtxo(i, spentOutput.amount, spentOutput.cond.scriptPubKey);
189
- };
190
- p2wpkhWrapped.prototype.setSingleKeyOutput = function (i, cond, pubkey, path) {
191
- this.psbt.setOutputRedeemScript(i, cond.redeemScript);
192
- this.psbt.setOutputBip32Derivation(i, pubkey, this.masterFp, path);
193
- };
194
- p2wpkhWrapped.prototype.getDescriptorTemplate = function () {
195
- return "sh(wpkh(@0))";
196
- };
197
- p2wpkhWrapped.prototype.createRedeemScript = function (pubkey) {
198
- var pubkeyHash = hashPublicKey(pubkey);
199
- return Buffer.concat([Buffer.from("0014", "hex"), pubkeyHash]);
200
- };
201
- return p2wpkhWrapped;
202
- }(SingleKeyAccount));
203
- export { p2wpkhWrapped };
204
- var p2wpkh = /** @class */ (function (_super) {
205
- __extends(p2wpkh, _super);
206
- function p2wpkh() {
207
- return _super !== null && _super.apply(this, arguments) || this;
208
- }
209
- p2wpkh.prototype.singleKeyCondition = function (pubkey) {
210
- var buf = new BufferWriter();
211
- var pubkeyHash = hashPublicKey(pubkey);
212
- buf.writeSlice(Buffer.from([0, HASH_SIZE]));
213
- buf.writeSlice(pubkeyHash);
214
- return { scriptPubKey: buf.buffer() };
215
- };
216
- p2wpkh.prototype.setSingleKeyInput = function (i, inputTx, spentOutput, pubkey, path) {
217
- if (!inputTx) {
218
- throw new Error("Full input base transaction required");
219
- }
220
- this.psbt.setInputNonWitnessUtxo(i, inputTx);
221
- this.psbt.setInputBip32Derivation(i, pubkey, this.masterFp, path);
222
- this.psbt.setInputWitnessUtxo(i, spentOutput.amount, spentOutput.cond.scriptPubKey);
223
- };
224
- p2wpkh.prototype.setSingleKeyOutput = function (i, cond, pubkey, path) {
225
- this.psbt.setOutputBip32Derivation(i, pubkey, this.masterFp, path);
226
- };
227
- p2wpkh.prototype.getDescriptorTemplate = function () {
228
- return "wpkh(@0)";
229
- };
230
- return p2wpkh;
231
- }(SingleKeyAccount));
232
- export { p2wpkh };
233
- //# sourceMappingURL=accounttype.js.map
@@ -1 +0,0 @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U,CAAC;IACpB,CAAC;IACH,aAAC;AAAD,CAAC,AAxCD,CAA4B,gBAAgB,GAwC3C"}
@@ -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,243 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- 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;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- var __values = (this && this.__values) || function(o) {
38
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
39
- if (m) return m.call(o);
40
- if (o && typeof o.length === "number") return {
41
- next: function () {
42
- if (o && i >= o.length) o = void 0;
43
- return { value: o && o[i++], done: !o };
44
- }
45
- };
46
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
47
- };
48
- import { pathElementsToBuffer } from "../bip32";
49
- import { MerkelizedPsbt } from "./merkelizedPsbt";
50
- import { ClientCommandInterpreter } from "./clientCommands";
51
- import { createVarint } from "../varint";
52
- import { hashLeaf, Merkle } from "./merkle";
53
- var CLA_BTC = 0xe1;
54
- var CLA_FRAMEWORK = 0xf8;
55
- var BitcoinIns;
56
- (function (BitcoinIns) {
57
- BitcoinIns[BitcoinIns["GET_PUBKEY"] = 0] = "GET_PUBKEY";
58
- // GET_ADDRESS = 0x01, // Removed from app
59
- BitcoinIns[BitcoinIns["REGISTER_WALLET"] = 2] = "REGISTER_WALLET";
60
- BitcoinIns[BitcoinIns["GET_WALLET_ADDRESS"] = 3] = "GET_WALLET_ADDRESS";
61
- BitcoinIns[BitcoinIns["SIGN_PSBT"] = 4] = "SIGN_PSBT";
62
- BitcoinIns[BitcoinIns["GET_MASTER_FINGERPRINT"] = 5] = "GET_MASTER_FINGERPRINT";
63
- })(BitcoinIns || (BitcoinIns = {}));
64
- var FrameworkIns;
65
- (function (FrameworkIns) {
66
- FrameworkIns[FrameworkIns["CONTINUE_INTERRUPTED"] = 1] = "CONTINUE_INTERRUPTED";
67
- })(FrameworkIns || (FrameworkIns = {}));
68
- /**
69
- * This class encapsulates the APDU protocol documented at
70
- * https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md
71
- */
72
- var AppClient = /** @class */ (function () {
73
- function AppClient(transport) {
74
- this.transport = transport;
75
- }
76
- AppClient.prototype.makeRequest = function (ins, data, cci) {
77
- return __awaiter(this, void 0, void 0, function () {
78
- var response, hwRequest, commandResponse;
79
- return __generator(this, function (_a) {
80
- switch (_a.label) {
81
- case 0: return [4 /*yield*/, this.transport.send(CLA_BTC, ins, 0, 0, data, [
82
- 0x9000,
83
- 0xe000,
84
- ])];
85
- case 1:
86
- response = _a.sent();
87
- _a.label = 2;
88
- case 2:
89
- if (!(response.readUInt16BE(response.length - 2) === 0xe000)) return [3 /*break*/, 4];
90
- if (!cci) {
91
- throw new Error("Unexpected SW_INTERRUPTED_EXECUTION");
92
- }
93
- hwRequest = response.slice(0, -2);
94
- commandResponse = cci.execute(hwRequest);
95
- return [4 /*yield*/, this.transport.send(CLA_FRAMEWORK, FrameworkIns.CONTINUE_INTERRUPTED, 0, 0, commandResponse, [0x9000, 0xe000])];
96
- case 3:
97
- response = _a.sent();
98
- return [3 /*break*/, 2];
99
- case 4: return [2 /*return*/, response.slice(0, -2)]; // drop the status word (can only be 0x9000 at this point)
100
- }
101
- });
102
- });
103
- };
104
- AppClient.prototype.getExtendedPubkey = function (display, pathElements) {
105
- return __awaiter(this, void 0, void 0, function () {
106
- var response;
107
- return __generator(this, function (_a) {
108
- switch (_a.label) {
109
- case 0:
110
- if (pathElements.length > 6) {
111
- throw new Error("Path too long. At most 6 levels allowed.");
112
- }
113
- return [4 /*yield*/, this.makeRequest(BitcoinIns.GET_PUBKEY, Buffer.concat([
114
- Buffer.from(display ? [1] : [0]),
115
- pathElementsToBuffer(pathElements),
116
- ]))];
117
- case 1:
118
- response = _a.sent();
119
- return [2 /*return*/, response.toString("ascii")];
120
- }
121
- });
122
- });
123
- };
124
- AppClient.prototype.getWalletAddress = function (walletPolicy, walletHMAC, change, addressIndex, display) {
125
- return __awaiter(this, void 0, void 0, function () {
126
- var clientInterpreter, addressIndexBuffer, response;
127
- return __generator(this, function (_a) {
128
- switch (_a.label) {
129
- case 0:
130
- if (change !== 0 && change !== 1)
131
- throw new Error("Change can only be 0 or 1");
132
- if (addressIndex < 0 || !Number.isInteger(addressIndex))
133
- throw new Error("Invalid address index");
134
- if (walletHMAC != null && walletHMAC.length != 32) {
135
- throw new Error("Invalid HMAC length");
136
- }
137
- clientInterpreter = new ClientCommandInterpreter(function () { });
138
- clientInterpreter.addKnownList(walletPolicy.keys.map(function (k) { return Buffer.from(k, "ascii"); }));
139
- clientInterpreter.addKnownPreimage(walletPolicy.serialize());
140
- addressIndexBuffer = Buffer.alloc(4);
141
- addressIndexBuffer.writeUInt32BE(addressIndex, 0);
142
- return [4 /*yield*/, this.makeRequest(BitcoinIns.GET_WALLET_ADDRESS, Buffer.concat([
143
- Buffer.from(display ? [1] : [0]),
144
- walletPolicy.getWalletId(),
145
- walletHMAC || Buffer.alloc(32, 0),
146
- Buffer.from([change]),
147
- addressIndexBuffer,
148
- ]), clientInterpreter)];
149
- case 1:
150
- response = _a.sent();
151
- return [2 /*return*/, response.toString("ascii")];
152
- }
153
- });
154
- });
155
- };
156
- AppClient.prototype.signPsbt = function (psbt, walletPolicy, walletHMAC, progressCallback) {
157
- return __awaiter(this, void 0, void 0, function () {
158
- var merkelizedPsbt, clientInterpreter, _a, _b, map, _c, _d, map, inputMapsRoot, outputMapsRoot, yielded, ret, yielded_1, yielded_1_1, inputAndSig;
159
- var e_1, _e, e_2, _f, e_3, _g;
160
- return __generator(this, function (_h) {
161
- switch (_h.label) {
162
- case 0:
163
- merkelizedPsbt = new MerkelizedPsbt(psbt);
164
- if (walletHMAC != null && walletHMAC.length != 32) {
165
- throw new Error("Invalid HMAC length");
166
- }
167
- clientInterpreter = new ClientCommandInterpreter(progressCallback);
168
- // prepare ClientCommandInterpreter
169
- clientInterpreter.addKnownList(walletPolicy.keys.map(function (k) { return Buffer.from(k, "ascii"); }));
170
- clientInterpreter.addKnownPreimage(walletPolicy.serialize());
171
- clientInterpreter.addKnownMapping(merkelizedPsbt.globalMerkleMap);
172
- try {
173
- for (_a = __values(merkelizedPsbt.inputMerkleMaps), _b = _a.next(); !_b.done; _b = _a.next()) {
174
- map = _b.value;
175
- clientInterpreter.addKnownMapping(map);
176
- }
177
- }
178
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
179
- finally {
180
- try {
181
- if (_b && !_b.done && (_e = _a["return"])) _e.call(_a);
182
- }
183
- finally { if (e_1) throw e_1.error; }
184
- }
185
- try {
186
- for (_c = __values(merkelizedPsbt.outputMerkleMaps), _d = _c.next(); !_d.done; _d = _c.next()) {
187
- map = _d.value;
188
- clientInterpreter.addKnownMapping(map);
189
- }
190
- }
191
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
192
- finally {
193
- try {
194
- if (_d && !_d.done && (_f = _c["return"])) _f.call(_c);
195
- }
196
- finally { if (e_2) throw e_2.error; }
197
- }
198
- clientInterpreter.addKnownList(merkelizedPsbt.inputMapCommitments);
199
- inputMapsRoot = new Merkle(merkelizedPsbt.inputMapCommitments.map(function (m) { return hashLeaf(m); })).getRoot();
200
- clientInterpreter.addKnownList(merkelizedPsbt.outputMapCommitments);
201
- outputMapsRoot = new Merkle(merkelizedPsbt.outputMapCommitments.map(function (m) { return hashLeaf(m); })).getRoot();
202
- return [4 /*yield*/, this.makeRequest(BitcoinIns.SIGN_PSBT, Buffer.concat([
203
- merkelizedPsbt.getGlobalKeysValuesRoot(),
204
- createVarint(merkelizedPsbt.getGlobalInputCount()),
205
- inputMapsRoot,
206
- createVarint(merkelizedPsbt.getGlobalOutputCount()),
207
- outputMapsRoot,
208
- walletPolicy.getWalletId(),
209
- walletHMAC || Buffer.alloc(32, 0),
210
- ]), clientInterpreter)];
211
- case 1:
212
- _h.sent();
213
- yielded = clientInterpreter.getYielded();
214
- ret = new Map();
215
- try {
216
- for (yielded_1 = __values(yielded), yielded_1_1 = yielded_1.next(); !yielded_1_1.done; yielded_1_1 = yielded_1.next()) {
217
- inputAndSig = yielded_1_1.value;
218
- ret.set(inputAndSig[0], inputAndSig.slice(1));
219
- }
220
- }
221
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
222
- finally {
223
- try {
224
- if (yielded_1_1 && !yielded_1_1.done && (_g = yielded_1["return"])) _g.call(yielded_1);
225
- }
226
- finally { if (e_3) throw e_3.error; }
227
- }
228
- return [2 /*return*/, ret];
229
- }
230
- });
231
- });
232
- };
233
- AppClient.prototype.getMasterFingerprint = function () {
234
- return __awaiter(this, void 0, void 0, function () {
235
- return __generator(this, function (_a) {
236
- return [2 /*return*/, this.makeRequest(BitcoinIns.GET_MASTER_FINGERPRINT, Buffer.from([]))];
237
- });
238
- });
239
- };
240
- return AppClient;
241
- }());
242
- export { AppClient };
243
- //# sourceMappingURL=appClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"appClient.js","sourceRoot":"","sources":["../../src/newops/appClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAE5C,IAAM,OAAO,GAAG,IAAI,CAAC;AACrB,IAAM,aAAa,GAAG,IAAI,CAAC;AAE3B,IAAK,UAOJ;AAPD,WAAK,UAAU;IACb,uDAAiB,CAAA;IACjB,0CAA0C;IAC1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