@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,3 @@
1
+ /// <reference types="node" />
2
+ export declare function hashPublicKey(buffer: Buffer): Buffer;
3
+ //# sourceMappingURL=hashPublicKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashPublicKey.d.ts","sourceRoot":"","sources":["../src/hashPublicKey.ts"],"names":[],"mappings":";AAEA,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD"}
@@ -0,0 +1,13 @@
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.hashPublicKey = void 0;
7
+ var ripemd160_1 = __importDefault(require("ripemd160"));
8
+ var sha_js_1 = __importDefault(require("sha.js"));
9
+ function hashPublicKey(buffer) {
10
+ return new ripemd160_1["default"]().update((0, sha_js_1["default"])("sha256").update(buffer).digest()).digest();
11
+ }
12
+ exports.hashPublicKey = hashPublicKey;
13
+ //# sourceMappingURL=hashPublicKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashPublicKey.js","sourceRoot":"","sources":["../src/hashPublicKey.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAkC;AAClC,kDAAyB;AACzB,SAAgB,aAAa,CAAC,MAAc;IAC1C,OAAO,IAAI,sBAAS,EAAE,CAAC,MAAM,CAAC,IAAA,mBAAG,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AAChF,CAAC;AAFD,sCAEC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import Btc from "./Btc";
2
+ export default Btc;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,eAAe,GAAG,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,8 @@
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
+ var Btc_1 = __importDefault(require("./Btc"));
7
+ exports["default"] = Btc_1["default"];
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,8CAAwB;AACxB,qBAAe,gBAAG,CAAC"}
@@ -0,0 +1,110 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounttype.d.ts","sourceRoot":"","sources":["../../src/newops/accounttype.ts"],"names":[],"mappings":";AAYA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,oBAAY,iBAAiB,GAAG;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CAIvB,CAAC;AAEF,oBAAY,WAAW,GAAG;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtE;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,iBAAiB,CAAC;IAExD;;;;;;;;OAQG;IACH,QAAQ,CACN,CAAC,EAAE,MAAM,EACT,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,MAAM,EAAE,EAAE,GACpB,IAAI,CAAC;IAER;;;;;;;;OAQG;IACH,YAAY,CACV,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,MAAM,EAAE,EACjB,KAAK,EAAE,MAAM,EAAE,EAAE,GAChB,IAAI,CAAC;IAER;;;;;OAKG;IACH,qBAA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AM,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"}
@@ -0,0 +1,236 @@
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
@@ -0,0 +1 @@
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,I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B,OAAO,EAAE,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC;IACxC,CAAC;IAED,kCAAiB,GAAjB,UACE,CAAS,EACT,OAA2B,EAC3B,WAAwB,EACxB,MAAc,EACd,IAAc;QAEd,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;SACzD;QACD,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAC3B,CAAC,EACD,WAAW,CAAC,MAAM,EAClB,WAAW,CAAC,IAAI,CAAC,YAAY,CAC9B,CAAC;IACJ,CAAC;IAED,mCAAkB,GAAlB,UACE,CAAS,EACT,IAAuB,EACvB,MAAc,EACd,IAAc;QAEd,IAAI,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"}
@@ -0,0 +1,18 @@
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
@@ -0,0 +1 @@
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;IAiCnB,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"}