@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
package/lib-es/Btc.js DELETED
@@ -1,329 +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
- import { pathStringToArray } from "./bip32";
38
- import BtcNew, { canSupportApp } from "./BtcNew";
39
- import BtcOld from "./BtcOld";
40
- import { getAppAndVersion } from "./getAppAndVersion";
41
- import { getTrustedInput } from "./getTrustedInput";
42
- import { getTrustedInputBIP143 } from "./getTrustedInputBIP143";
43
- import { AppClient } from "./newops/appClient";
44
- import { serializeTransactionOutputs } from "./serializeTransaction";
45
- import { splitTransaction } from "./splitTransaction";
46
- /**
47
- * Bitcoin API.
48
- *
49
- * @example
50
- * import Btc from "@ledgerhq/hw-app-btc";
51
- * const btc = new Btc(transport)
52
- */
53
- var Btc = /** @class */ (function () {
54
- function Btc(transport, scrambleKey) {
55
- if (scrambleKey === void 0) { scrambleKey = "BTC"; }
56
- // cache the underlying implementation (only once)
57
- this._lazyImpl = null;
58
- this.transport = transport;
59
- transport.decorateAppAPIMethods(this, [
60
- "getWalletXpub",
61
- "getWalletPublicKey",
62
- "signP2SHTransaction",
63
- "signMessageNew",
64
- "createPaymentTransactionNew",
65
- "getTrustedInput",
66
- "getTrustedInputBIP143",
67
- ], scrambleKey);
68
- }
69
- /**
70
- * Get an XPUB with a ledger device
71
- * @param arg derivation parameter
72
- * - path: a BIP 32 path of the account level. e.g. `84'/0'/0'`
73
- * - xpubVersion: the XPUBVersion of the coin used. (use @ledgerhq/currencies if needed)
74
- * @returns XPUB of the account
75
- */
76
- Btc.prototype.getWalletXpub = function (arg) {
77
- return this.getCorrectImpl().then(function (impl) { return impl.getWalletXpub(arg); });
78
- };
79
- /**
80
- * @param path a BIP 32 path
81
- * @param options an object with optional these fields:
82
- *
83
- * - verify (boolean) will ask user to confirm the address on the device
84
- *
85
- * - format ("legacy" | "p2sh" | "bech32" | "bech32m" | "cashaddr") to use different bitcoin address formatter.
86
- *
87
- * NB The normal usage is to use:
88
- *
89
- * - legacy format with 44' paths
90
- *
91
- * - p2sh format with 49' paths
92
- *
93
- * - bech32 format with 84' paths
94
- *
95
- * - cashaddr in case of Bitcoin Cash
96
- *
97
- * @example
98
- * btc.getWalletPublicKey("44'/0'/0'/0/0").then(o => o.bitcoinAddress)
99
- * btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinAddress)
100
- */
101
- Btc.prototype.getWalletPublicKey = function (path, opts) {
102
- var _this = this;
103
- var options;
104
- if (arguments.length > 2 || typeof opts === "boolean") {
105
- console.warn("btc.getWalletPublicKey deprecated signature used. Please switch to getWalletPublicKey(path, { format, verify })");
106
- options = {
107
- verify: !!opts,
108
- // eslint-disable-next-line prefer-rest-params
109
- format: arguments[2] ? "p2sh" : "legacy"
110
- };
111
- }
112
- else {
113
- options = opts || {};
114
- }
115
- return this.getCorrectImpl().then(function (impl) {
116
- /**
117
- * Definition: A "normal path" is a prefix of a standard path where all
118
- * the hardened steps of the standard path are included. For example, the
119
- * paths m/44'/1'/17' and m/44'/1'/17'/1 are normal paths, but m/44'/1'
120
- * is not. m/'199/1'/17'/0/1 is not a normal path either.
121
- *
122
- * There's a compatiblity issue between old and new app: When exporting
123
- * the key of a non-normal path with verify=false, the new app would
124
- * return an error, whereas the old app would return the key.
125
- *
126
- * See
127
- * https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#get_extended_pubkey
128
- *
129
- * If format bech32m is used, we'll not use old, because it doesn't
130
- * support it.
131
- *
132
- * When to use new (given the app supports it)
133
- * * format is bech32m or
134
- * * path is normal or
135
- * * verify is true
136
- *
137
- * Otherwise use old.
138
- */
139
- if (impl instanceof BtcNew &&
140
- options.format != "bech32m" &&
141
- (!options.verify || options.verify == false) &&
142
- !isPathNormal(path)) {
143
- console.warn("WARNING: Using deprecated device protocol to get the public key because\n \n * a non-standard path is requested, and\n * verify flag is false\n \n The new protocol only allows export of non-standard paths if the \n verify flag is true. Standard paths are (currently):\n\n M/44'/(1|0)'/X'\n M/49'/(1|0)'/X'\n M/84'/(1|0)'/X'\n M/86'/(1|0)'/X'\n M/48'/(1|0)'/X'/Y'\n\n followed by \"\", \"(0|1)\", or \"(0|1)/b\", where a and b are \n non-hardened. For example, the following paths are standard\n \n M/48'/1'/99'/7'\n M/86'/1'/99'/0\n M/48'/0'/99'/7'/1/17\n\n The following paths are non-standard\n\n M/48'/0'/99' // Not deepest hardened path\n M/48'/0'/99'/7'/1/17/2 // Too many non-hardened derivation steps\n M/199'/0'/1'/0/88 // Not a known purpose 199\n M/86'/1'/99'/2 // Change path item must be 0 or 1\n\n This compatibility safeguard will be removed in the future.\n Please consider calling Btc.getWalletXpub() instead.");
144
- return _this.old().getWalletPublicKey(path, options);
145
- }
146
- else {
147
- return impl.getWalletPublicKey(path, options);
148
- }
149
- });
150
- };
151
- /**
152
- * You can sign a message according to the Bitcoin Signature format and retrieve v, r, s given the message and the BIP 32 path of the account to sign.
153
- * @example
154
- btc.signMessageNew_async("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
155
- var v = result['v'] + 27 + 4;
156
- var signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');
157
- console.log("Signature : " + signature);
158
- }).catch(function(ex) {console.log(ex);});
159
- */
160
- Btc.prototype.signMessageNew = function (path, messageHex) {
161
- return this.old().signMessageNew(path, messageHex);
162
- };
163
- /**
164
- * To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
165
- * @param inputs is an array of [ transaction, output_index, optional redeem script, optional sequence ] where
166
- *
167
- * * transaction is the previously computed transaction object for this UTXO
168
- * * output_index is the output in the transaction used as input for this UTXO (counting from 0)
169
- * * redeem script is the optional redeem script to use when consuming a Segregated Witness input
170
- * * sequence is the sequence number to use for this input (when using RBF), or non present
171
- * @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
172
- * @param changePath is an optional BIP 32 path pointing to the path to the public key used to compute the change address
173
- * @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign, including leading vararg voutCount
174
- * @param lockTime is the optional lockTime of the transaction to sign, or default (0)
175
- * @param sigHashType is the hash type of the transaction to sign, or default (all)
176
- * @param segwit is an optional boolean indicating wether to use segwit or not. This includes wrapped segwit.
177
- * @param initialTimestamp is an optional timestamp of the function call to use for coins that necessitate timestamps only, (not the one that the tx will include)
178
- * @param additionals list of additionnal options
179
- *
180
- * - "bech32" for spending native segwit outputs
181
- * - "bech32m" for spending segwit v1+ outputs
182
- * - "abc" for bch
183
- * - "gold" for btg
184
- * - "bipxxx" for using BIPxxx
185
- * - "sapling" to indicate a zec transaction is supporting sapling (to be set over block 419200)
186
- * @param expiryHeight is an optional Buffer for zec overwinter / sapling Txs
187
- * @param useTrustedInputForSegwit trust inputs for segwit transactions. If app version >= 1.4.0 this should be true.
188
- * @return the signed transaction ready to be broadcast
189
- * @example
190
- btc.createTransaction({
191
- inputs: [ [tx1, 1] ],
192
- associatedKeysets: ["0'/0/0"],
193
- outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
194
- }).then(res => ...);
195
- */
196
- Btc.prototype.createPaymentTransactionNew = function (arg) {
197
- if (arguments.length > 1) {
198
- console.warn("@ledgerhq/hw-app-btc: createPaymentTransactionNew multi argument signature is deprecated. please switch to named parameters.");
199
- }
200
- return this.getCorrectImpl().then(function (impl) {
201
- return impl.createPaymentTransactionNew(arg);
202
- });
203
- };
204
- /**
205
- * To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters
206
- * @param inputs is an array of [ transaction, output_index, redeem script, optional sequence ] where
207
- * * transaction is the previously computed transaction object for this UTXO
208
- * * output_index is the output in the transaction used as input for this UTXO (counting from 0)
209
- * * redeem script is the mandatory redeem script associated to the current P2SH input
210
- * * sequence is the sequence number to use for this input (when using RBF), or non present
211
- * @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
212
- * @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign
213
- * @param lockTime is the optional lockTime of the transaction to sign, or default (0)
214
- * @param sigHashType is the hash type of the transaction to sign, or default (all)
215
- * @return the signed transaction ready to be broadcast
216
- * @example
217
- btc.signP2SHTransaction({
218
- inputs: [ [tx, 1, "52210289b4a3ad52a919abd2bdd6920d8a6879b1e788c38aa76f0440a6f32a9f1996d02103a3393b1439d1693b063482c04bd40142db97bdf139eedd1b51ffb7070a37eac321030b9a409a1e476b0d5d17b804fcdb81cf30f9b99c6f3ae1178206e08bc500639853ae"] ],
219
- associatedKeysets: ["0'/0/0"],
220
- outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
221
- }).then(result => ...);
222
- */
223
- Btc.prototype.signP2SHTransaction = function (arg) {
224
- return this.old().signP2SHTransaction(arg);
225
- };
226
- /**
227
- * For each UTXO included in your transaction, create a transaction object from the raw serialized version of the transaction used in this UTXO.
228
- * @example
229
- const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
230
- */
231
- Btc.prototype.splitTransaction = function (transactionHex, isSegwitSupported, hasTimestamp, hasExtraData, additionals) {
232
- if (isSegwitSupported === void 0) { isSegwitSupported = false; }
233
- if (hasTimestamp === void 0) { hasTimestamp = false; }
234
- if (hasExtraData === void 0) { hasExtraData = false; }
235
- if (additionals === void 0) { additionals = []; }
236
- return splitTransaction(transactionHex, isSegwitSupported, hasTimestamp, hasExtraData, additionals);
237
- };
238
- /**
239
- @example
240
- const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
241
- const outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');
242
- */
243
- Btc.prototype.serializeTransactionOutputs = function (t) {
244
- return serializeTransactionOutputs(t);
245
- };
246
- Btc.prototype.getTrustedInput = function (indexLookup, transaction, additionals) {
247
- if (additionals === void 0) { additionals = []; }
248
- return getTrustedInput(this.transport, indexLookup, transaction, additionals);
249
- };
250
- Btc.prototype.getTrustedInputBIP143 = function (indexLookup, transaction, additionals) {
251
- if (additionals === void 0) { additionals = []; }
252
- return getTrustedInputBIP143(this.transport, indexLookup, transaction, additionals);
253
- };
254
- Btc.prototype.getCorrectImpl = function () {
255
- return __awaiter(this, void 0, void 0, function () {
256
- var _lazyImpl, impl;
257
- return __generator(this, function (_a) {
258
- switch (_a.label) {
259
- case 0:
260
- _lazyImpl = this._lazyImpl;
261
- if (_lazyImpl)
262
- return [2 /*return*/, _lazyImpl];
263
- return [4 /*yield*/, this.inferCorrectImpl()];
264
- case 1:
265
- impl = _a.sent();
266
- this._lazyImpl = impl;
267
- return [2 /*return*/, impl];
268
- }
269
- });
270
- });
271
- };
272
- Btc.prototype.inferCorrectImpl = function () {
273
- return __awaiter(this, void 0, void 0, function () {
274
- var appAndVersion, canUseNewImplementation;
275
- return __generator(this, function (_a) {
276
- switch (_a.label) {
277
- case 0: return [4 /*yield*/, getAppAndVersion(this.transport)];
278
- case 1:
279
- appAndVersion = _a.sent();
280
- canUseNewImplementation = canSupportApp(appAndVersion);
281
- if (!canUseNewImplementation) {
282
- return [2 /*return*/, this.old()];
283
- }
284
- else {
285
- return [2 /*return*/, this["new"]()];
286
- }
287
- return [2 /*return*/];
288
- }
289
- });
290
- });
291
- };
292
- Btc.prototype.old = function () {
293
- return new BtcOld(this.transport);
294
- };
295
- Btc.prototype["new"] = function () {
296
- return new BtcNew(new AppClient(this.transport));
297
- };
298
- return Btc;
299
- }());
300
- export default Btc;
301
- function isPathNormal(path) {
302
- //path is not deepest hardened node of a standard path or deeper, use BtcOld
303
- var h = 0x80000000;
304
- var pathElems = pathStringToArray(path);
305
- var hard = function (n) { return n >= h; };
306
- var soft = function (n) { return !n || n < h; };
307
- var change = function (n) { return !n || n == 0 || n == 1; };
308
- if (pathElems.length >= 3 &&
309
- pathElems.length <= 5 &&
310
- [44 + h, 49 + h, 84 + h, 86 + h].some(function (v) { return v == pathElems[0]; }) &&
311
- [0 + h, 1 + h].some(function (v) { return v == pathElems[1]; }) &&
312
- hard(pathElems[2]) &&
313
- change(pathElems[3]) &&
314
- soft(pathElems[4])) {
315
- return true;
316
- }
317
- if (pathElems.length >= 4 &&
318
- pathElems.length <= 6 &&
319
- 48 + h == pathElems[0] &&
320
- [0 + h, 1 + h].some(function (v) { return v == pathElems[1]; }) &&
321
- hard(pathElems[2]) &&
322
- hard(pathElems[3]) &&
323
- change(pathElems[4]) &&
324
- soft(pathElems[5])) {
325
- return true;
326
- }
327
- return false;
328
- }
329
- //# sourceMappingURL=Btc.js.map
package/lib-es/Btc.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"Btc.js","sourceRoot":"","sources":["../src/Btc.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,MAAM,EAAE,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;;;;;GAMG;AAEH;IAGE,aAAY,SAAoB,EAAE,WAAmB;QAAnB,4BAAA,EAAA,mBAAmB;QA4RrD,kDAAkD;QAC1C,cAAS,GAA2B,IAAI,CAAC;QA5R/C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,SAAS,CAAC,qBAAqB,CAC7B,IAAI,EACJ;YACE,eAAe;YACf,oBAAoB;YACpB,qBAAqB;YACrB,gBAAgB;YAChB,6BAA6B;YAC7B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AAS,CAAC,CAAC,CAAC,EAAjB,CAAiB,CAAC;QAC7C,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAClB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAClB;QACA,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,122 +0,0 @@
1
- import type { CreateTransactionArg } from "./createTransaction";
2
- import { AppAndVersion } from "./getAppAndVersion";
3
- import type { AddressFormat } from "./getWalletPublicKey";
4
- import { AppClient as Client } from "./newops/appClient";
5
- export declare function canSupportApp(appAndVersion: AppAndVersion): boolean;
6
- /**
7
- * This class implements the same interface as BtcOld (formerly
8
- * named Btc), but interacts with Bitcoin hardware app version 2+
9
- * which uses a totally new APDU protocol. This new
10
- * protocol is documented at
11
- * https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md
12
- *
13
- * Since the interface must remain compatible with BtcOld, the methods
14
- * of this class are quite clunky, because it needs to adapt legacy
15
- * input data into the PSBT process. In the future, a new interface should
16
- * be developed that exposes PSBT to the outer world, which would render
17
- * a much cleaner implementation.
18
- */
19
- export default class BtcNew {
20
- private client;
21
- constructor(client: Client);
22
- /**
23
- * This is a new method that allow users to get an xpub at a standard path.
24
- * Standard paths are described at
25
- * https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#description
26
- *
27
- * This boils down to paths (N=0 for Bitcoin, N=1 for Testnet):
28
- * M/44'/N'/x'/**
29
- * M/48'/N'/x'/y'/**
30
- * M/49'/N'/x'/**
31
- * M/84'/N'/x'/**
32
- * M/86'/N'/x'/**
33
- *
34
- * The method was added because of added security in the hardware app v2+. The
35
- * new hardware app will allow export of any xpub up to and including the
36
- * deepest hardened key of standard derivation paths, whereas the old app
37
- * would allow export of any key.
38
- *
39
- * This caused an issue for callers of this class, who only had
40
- * getWalletPublicKey() to call which means they have to constuct xpub
41
- * themselves:
42
- *
43
- * Suppose a user of this class wants to create an account xpub on a standard
44
- * path, M/44'/0'/Z'. The user must get the parent key fingerprint (see BIP32)
45
- * by requesting the parent key M/44'/0'. The new app won't allow that, because
46
- * it only allows exporting deepest level hardened path. So the options are to
47
- * allow requesting M/44'/0' from the app, or to add a new function
48
- * "getWalletXpub".
49
- *
50
- * We opted for adding a new function, which can greatly simplify client code.
51
- */
52
- getWalletXpub({ path, xpubVersion, }: {
53
- path: string;
54
- xpubVersion: number;
55
- }): Promise<string>;
56
- /**
57
- * This method returns a public key, a bitcoin address, and and a chaincode
58
- * for a specific derivation path.
59
- *
60
- * Limitation: If the path is not a leaf node of a standard path, the address
61
- * will be the empty string "", see this.getWalletAddress() for details.
62
- */
63
- getWalletPublicKey(path: string, opts?: {
64
- verify?: boolean;
65
- format?: AddressFormat;
66
- }): Promise<{
67
- publicKey: string;
68
- bitcoinAddress: string;
69
- chainCode: string;
70
- }>;
71
- /**
72
- * Get an address for the specified path.
73
- *
74
- * If display is true, we must get the address from the device, which would require
75
- * us to determine WalletPolicy. This requires two *extra* queries to the device, one
76
- * for the account xpub and one for master key fingerprint.
77
- *
78
- * If display is false we *could* generate the address ourselves, but chose to
79
- * get it from the device to save development time. However, it shouldn't take
80
- * too much time to implement local address generation.
81
- *
82
- * Moreover, if the path is not for a leaf, ie accountPath+/X/Y, there is no
83
- * way to get the address from the device. In this case we have to create it
84
- * ourselves, but we don't at this time, and instead return an empty ("") address.
85
- */
86
- private getWalletAddress;
87
- /**
88
- * Build and sign a transaction. See Btc.createPaymentTransactionNew for
89
- * details on how to use this method.
90
- *
91
- * This method will convert the legacy arguments, CreateTransactionArg, into
92
- * a psbt which is finally signed and finalized, and the extracted fully signed
93
- * transaction is returned.
94
- */
95
- createPaymentTransactionNew(arg: CreateTransactionArg): Promise<string>;
96
- /**
97
- * Calculates an output script along with public key and possible redeemScript
98
- * from a path and accountType. The accountPath must be a prefix of path.
99
- *
100
- * @returns an object with output script (property "script"), redeemScript (if
101
- * wrapped p2wpkh), and pubkey at provided path. The values of these three
102
- * properties depend on the accountType used.
103
- */
104
- private outputScriptAt;
105
- /**
106
- * Adds relevant data about an input to the psbt. This includes sequence,
107
- * previous txid, output index, spent UTXO, redeem script for wrapped p2wpkh,
108
- * public key and its derivation path.
109
- */
110
- private setInput;
111
- /**
112
- * This implements the "Signer" role of the BIP370 transaction signing
113
- * process.
114
- *
115
- * It ssks the hardware device to sign the a psbt using the specified wallet
116
- * policy. This method assumes BIP32 derived keys are used for all inputs, see
117
- * comment in-line. The signatures returned from the hardware device is added
118
- * to the appropriate input fields of the PSBT.
119
- */
120
- private signPsbt;
121
- }
122
- //# sourceMappingURL=BtcNew.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BtcNew.d.ts","sourceRoot":"","sources":["../src/BtcNew.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAS1D,OAAO,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAczD,wBAAgB,aAAa,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAKnE;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACb,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACG,aAAa,CAAC,EAClB,IAAI,EACJ,WAAW,GACZ,EAAE;QACD,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,MAAM,CAAC;IAYnB;;;;;;OAMG;IACG,kBAAkB,CACtB,IAAI,EAAE,M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