@ledgerhq/live-common 21.4.1-btcjs.4 → 21.5.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 (169) hide show
  1. package/lib/account/addAccounts.d.ts.map +1 -1
  2. package/lib/account/addAccounts.js +1 -2
  3. package/lib/account/addAccounts.js.map +1 -1
  4. package/lib/account/support.d.ts.map +1 -1
  5. package/lib/account/support.js +1 -24
  6. package/lib/account/support.js.map +1 -1
  7. package/lib/api/explorerConfig/index.js +15 -15
  8. package/lib/apps/polyfill.d.ts.map +1 -1
  9. package/lib/apps/polyfill.js +5 -0
  10. package/lib/apps/polyfill.js.map +1 -1
  11. package/lib/bridge/jsHelpers.d.ts +1 -6
  12. package/lib/bridge/jsHelpers.d.ts.map +1 -1
  13. package/lib/bridge/jsHelpers.js +3 -11
  14. package/lib/bridge/jsHelpers.js.map +1 -1
  15. package/lib/env.js +2 -2
  16. package/lib/families/bitcoin/account.d.ts.map +1 -1
  17. package/lib/families/bitcoin/account.js +2 -3
  18. package/lib/families/bitcoin/account.js.map +1 -1
  19. package/lib/families/bitcoin/datasets/bitcoin.js +6 -6
  20. package/lib/families/bitcoin/datasets/bitcoin.js.map +1 -1
  21. package/lib/families/bitcoin/datasets/litecoin.js +3 -3
  22. package/lib/families/bitcoin/datasets/litecoin.js.map +1 -1
  23. package/lib/families/bitcoin/serialization.d.ts +2 -2
  24. package/lib/families/bitcoin/serialization.d.ts.map +1 -1
  25. package/lib/families/bitcoin/serialization.js +4 -8
  26. package/lib/families/bitcoin/serialization.js.map +1 -1
  27. package/lib/families/bitcoin/specs.d.ts.map +1 -1
  28. package/lib/families/bitcoin/specs.js +5 -8
  29. package/lib/families/bitcoin/specs.js.map +1 -1
  30. package/lib/families/bitcoin/speculos-deviceActions.js +2 -2
  31. package/lib/families/bitcoin/speculos-deviceActions.js.map +1 -1
  32. package/lib/families/bitcoin/test-dataset.js +1 -1
  33. package/lib/families/bitcoin/test-dataset.js.map +1 -1
  34. package/lib/families/bitcoin/transaction.d.ts +3 -3
  35. package/lib/families/bitcoin/transaction.d.ts.map +1 -1
  36. package/lib/families/bitcoin/transaction.js +61 -64
  37. package/lib/families/bitcoin/transaction.js.map +1 -1
  38. package/lib/families/bitcoin/types.d.ts +36 -66
  39. package/lib/families/bitcoin/types.d.ts.map +1 -1
  40. package/lib/families/bitcoin/types.js +1 -16
  41. package/lib/families/bitcoin/types.js.map +1 -1
  42. package/lib/families/crypto_org/logic.d.ts +1 -1
  43. package/lib/families/crypto_org/logic.js +7 -7
  44. package/lib/families/elrond/js-getTransactionStatus.d.ts.map +1 -1
  45. package/lib/families/elrond/js-getTransactionStatus.js +3 -0
  46. package/lib/families/elrond/js-getTransactionStatus.js.map +1 -1
  47. package/lib/families/elrond/js-signOperation.d.ts.map +1 -1
  48. package/lib/families/elrond/js-signOperation.js +10 -7
  49. package/lib/families/elrond/js-signOperation.js.map +1 -1
  50. package/lib/generated/bridge/js.d.ts +0 -4
  51. package/lib/generated/bridge/js.d.ts.map +1 -1
  52. package/lib/generated/bridge/js.js +18 -20
  53. package/lib/generated/bridge/js.js.map +1 -1
  54. package/lib/hw/actions/initSwap.js +2 -2
  55. package/lib/hw/actions/initSwap.js.map +1 -1
  56. package/lib/migrations/accounts-dataset.d.ts.map +1 -1
  57. package/lib/migrations/accounts-dataset.js +2 -4
  58. package/lib/migrations/accounts-dataset.js.map +1 -1
  59. package/lib/migrations/accounts.d.ts.map +1 -1
  60. package/lib/migrations/accounts.js +0 -17
  61. package/lib/migrations/accounts.js.map +1 -1
  62. package/lib/mock/account.d.ts.map +1 -1
  63. package/lib/mock/account.js +1 -2
  64. package/lib/mock/account.js.map +1 -1
  65. package/package.json +22 -22
  66. package/src/__tests__/__snapshots__/all.libcore.ts.snap +43 -6
  67. package/src/account/addAccounts.ts +1 -2
  68. package/src/account/support.ts +1 -24
  69. package/src/api/explorerConfig/index.ts +15 -15
  70. package/src/apps/polyfill.ts +5 -0
  71. package/src/bridge/jsHelpers.ts +2 -22
  72. package/src/env.ts +2 -2
  73. package/src/families/bitcoin/account.ts +1 -2
  74. package/src/families/bitcoin/datasets/bitcoin.ts +6 -6
  75. package/src/families/bitcoin/datasets/litecoin.ts +6 -6
  76. package/src/families/bitcoin/serialization.ts +0 -6
  77. package/src/families/bitcoin/specs.ts +2 -5
  78. package/src/families/bitcoin/speculos-deviceActions.ts +1 -1
  79. package/src/families/bitcoin/test-dataset.ts +1 -1
  80. package/src/families/bitcoin/transaction.ts +93 -98
  81. package/src/families/bitcoin/types.ts +37 -95
  82. package/src/families/crypto_org/logic.ts +6 -6
  83. package/src/families/elrond/js-getTransactionStatus.ts +5 -0
  84. package/src/families/elrond/js-signOperation.ts +1 -0
  85. package/src/generated/bridge/js.ts +0 -3
  86. package/src/hw/actions/initSwap.ts +2 -2
  87. package/src/migrations/accounts-dataset.ts +0 -3
  88. package/src/migrations/accounts.ts +0 -18
  89. package/src/mock/account.ts +0 -2
  90. package/lib/families/bitcoin/bridge/js.d.ts +0 -8
  91. package/lib/families/bitcoin/bridge/js.d.ts.map +0 -1
  92. package/lib/families/bitcoin/bridge/js.js +0 -149
  93. package/lib/families/bitcoin/bridge/js.js.map +0 -1
  94. package/lib/families/bitcoin/cache.d.ts +0 -28
  95. package/lib/families/bitcoin/cache.d.ts.map +0 -1
  96. package/lib/families/bitcoin/cache.js +0 -109
  97. package/lib/families/bitcoin/cache.js.map +0 -1
  98. package/lib/families/bitcoin/getAccountNetworkInfo.d.ts +0 -6
  99. package/lib/families/bitcoin/getAccountNetworkInfo.d.ts.map +0 -1
  100. package/lib/families/bitcoin/getAccountNetworkInfo.js +0 -124
  101. package/lib/families/bitcoin/getAccountNetworkInfo.js.map +0 -1
  102. package/lib/families/bitcoin/getAccountNetworkInfo.test.d.ts +0 -2
  103. package/lib/families/bitcoin/getAccountNetworkInfo.test.d.ts.map +0 -1
  104. package/lib/families/bitcoin/getAccountNetworkInfo.test.js +0 -71
  105. package/lib/families/bitcoin/getAccountNetworkInfo.test.js.map +0 -1
  106. package/lib/families/bitcoin/js-broadcast.d.ts +0 -11
  107. package/lib/families/bitcoin/js-broadcast.d.ts.map +0 -1
  108. package/lib/families/bitcoin/js-broadcast.js +0 -80
  109. package/lib/families/bitcoin/js-broadcast.js.map +0 -1
  110. package/lib/families/bitcoin/js-buildTransaction.d.ts +0 -5
  111. package/lib/families/bitcoin/js-buildTransaction.d.ts.map +0 -1
  112. package/lib/families/bitcoin/js-buildTransaction.js +0 -106
  113. package/lib/families/bitcoin/js-buildTransaction.js.map +0 -1
  114. package/lib/families/bitcoin/js-createTransaction.d.ts +0 -9
  115. package/lib/families/bitcoin/js-createTransaction.d.ts.map +0 -1
  116. package/lib/families/bitcoin/js-createTransaction.js +0 -27
  117. package/lib/families/bitcoin/js-createTransaction.js.map +0 -1
  118. package/lib/families/bitcoin/js-estimateMaxSpendable.d.ts +0 -15
  119. package/lib/families/bitcoin/js-estimateMaxSpendable.d.ts.map +0 -1
  120. package/lib/families/bitcoin/js-estimateMaxSpendable.js +0 -95
  121. package/lib/families/bitcoin/js-estimateMaxSpendable.js.map +0 -1
  122. package/lib/families/bitcoin/js-getFeesForTransaction.d.ts +0 -26
  123. package/lib/families/bitcoin/js-getFeesForTransaction.d.ts.map +0 -1
  124. package/lib/families/bitcoin/js-getFeesForTransaction.js +0 -100
  125. package/lib/families/bitcoin/js-getFeesForTransaction.js.map +0 -1
  126. package/lib/families/bitcoin/js-getTransactionStatus.d.ts +0 -5
  127. package/lib/families/bitcoin/js-getTransactionStatus.d.ts.map +0 -1
  128. package/lib/families/bitcoin/js-getTransactionStatus.js +0 -131
  129. package/lib/families/bitcoin/js-getTransactionStatus.js.map +0 -1
  130. package/lib/families/bitcoin/js-prepareTransaction.d.ts +0 -5
  131. package/lib/families/bitcoin/js-prepareTransaction.d.ts.map +0 -1
  132. package/lib/families/bitcoin/js-prepareTransaction.js +0 -80
  133. package/lib/families/bitcoin/js-prepareTransaction.js.map +0 -1
  134. package/lib/families/bitcoin/js-signOperation.d.ts +0 -10
  135. package/lib/families/bitcoin/js-signOperation.d.ts.map +0 -1
  136. package/lib/families/bitcoin/js-signOperation.js +0 -212
  137. package/lib/families/bitcoin/js-signOperation.js.map +0 -1
  138. package/lib/families/bitcoin/js-synchronisation.d.ts +0 -10
  139. package/lib/families/bitcoin/js-synchronisation.d.ts.map +0 -1
  140. package/lib/families/bitcoin/js-synchronisation.js +0 -411
  141. package/lib/families/bitcoin/js-synchronisation.js.map +0 -1
  142. package/lib/families/bitcoin/logic.d.ts +0 -34
  143. package/lib/families/bitcoin/logic.d.ts.map +0 -1
  144. package/lib/families/bitcoin/logic.js +0 -283
  145. package/lib/families/bitcoin/logic.js.map +0 -1
  146. package/lib/families/bitcoin/networks.d.ts +0 -3
  147. package/lib/families/bitcoin/networks.d.ts.map +0 -1
  148. package/lib/families/bitcoin/networks.js +0 -379
  149. package/lib/families/bitcoin/networks.js.map +0 -1
  150. package/lib/families/bitcoin/wallet.d.ts +0 -6
  151. package/lib/families/bitcoin/wallet.d.ts.map +0 -1
  152. package/lib/families/bitcoin/wallet.js +0 -66
  153. package/lib/families/bitcoin/wallet.js.map +0 -1
  154. package/src/families/bitcoin/bridge/js.ts +0 -76
  155. package/src/families/bitcoin/cache.ts +0 -76
  156. package/src/families/bitcoin/getAccountNetworkInfo.test.ts +0 -27
  157. package/src/families/bitcoin/getAccountNetworkInfo.ts +0 -61
  158. package/src/families/bitcoin/js-broadcast.ts +0 -30
  159. package/src/families/bitcoin/js-buildTransaction.ts +0 -57
  160. package/src/families/bitcoin/js-createTransaction.ts +0 -27
  161. package/src/families/bitcoin/js-estimateMaxSpendable.ts +0 -36
  162. package/src/families/bitcoin/js-getFeesForTransaction.ts +0 -59
  163. package/src/families/bitcoin/js-getTransactionStatus.ts +0 -118
  164. package/src/families/bitcoin/js-prepareTransaction.ts +0 -35
  165. package/src/families/bitcoin/js-signOperation.ts +0 -164
  166. package/src/families/bitcoin/js-synchronisation.ts +0 -362
  167. package/src/families/bitcoin/logic.ts +0 -243
  168. package/src/families/bitcoin/networks.ts +0 -360
  169. package/src/families/bitcoin/wallet.ts +0 -21
@@ -15,7 +15,7 @@ const initialExplorerConfig: FullConfig = {
15
15
  id: "abc",
16
16
  stable: {
17
17
  base: "EXPLORER",
18
- version: "v3",
18
+ version: "v2",
19
19
  },
20
20
  /*
21
21
  experimental: {
@@ -28,7 +28,7 @@ const initialExplorerConfig: FullConfig = {
28
28
  id: "btg",
29
29
  stable: {
30
30
  base: "EXPLORER",
31
- version: "v3",
31
+ version: "v2",
32
32
  },
33
33
  experimental: {
34
34
  base: "EXPLORER",
@@ -60,7 +60,7 @@ const initialExplorerConfig: FullConfig = {
60
60
  id: "dgb",
61
61
  stable: {
62
62
  base: "EXPLORER",
63
- version: "v3",
63
+ version: "v2",
64
64
  },
65
65
  experimental: {
66
66
  base: "EXPLORER",
@@ -71,7 +71,7 @@ const initialExplorerConfig: FullConfig = {
71
71
  id: "doge",
72
72
  stable: {
73
73
  base: "EXPLORER",
74
- version: "v3",
74
+ version: "v2",
75
75
  },
76
76
  experimental: {
77
77
  base: "EXPLORER",
@@ -89,7 +89,7 @@ const initialExplorerConfig: FullConfig = {
89
89
  id: "kmd",
90
90
  stable: {
91
91
  base: "EXPLORER",
92
- version: "v3",
92
+ version: "v2",
93
93
  },
94
94
  /*
95
95
  experimental: {
@@ -109,7 +109,7 @@ const initialExplorerConfig: FullConfig = {
109
109
  id: "ppc",
110
110
  stable: {
111
111
  base: "EXPLORER",
112
- version: "v3",
112
+ version: "v2",
113
113
  },
114
114
  experimental: {
115
115
  base: "EXPLORER",
@@ -120,7 +120,7 @@ const initialExplorerConfig: FullConfig = {
120
120
  id: "pivx",
121
121
  stable: {
122
122
  base: "EXPLORER",
123
- version: "v3",
123
+ version: "v2",
124
124
  },
125
125
  experimental: {
126
126
  base: "EXPLORER",
@@ -138,7 +138,7 @@ const initialExplorerConfig: FullConfig = {
138
138
  id: "qtum",
139
139
  stable: {
140
140
  base: "EXPLORER",
141
- version: "v3",
141
+ version: "v2",
142
142
  },
143
143
  experimental: {
144
144
  base: "EXPLORER",
@@ -149,14 +149,14 @@ const initialExplorerConfig: FullConfig = {
149
149
  id: "xsn",
150
150
  stable: {
151
151
  base: "EXPLORER",
152
- version: "v3",
152
+ version: "v2",
153
153
  },
154
154
  },
155
155
  stratis: {
156
156
  id: "strat",
157
157
  stable: {
158
158
  base: "EXPLORER",
159
- version: "v3",
159
+ version: "v2",
160
160
  },
161
161
  },
162
162
  stealthcoin: {
@@ -170,7 +170,7 @@ const initialExplorerConfig: FullConfig = {
170
170
  id: "vtc",
171
171
  stable: {
172
172
  base: "EXPLORER",
173
- version: "v3",
173
+ version: "v2",
174
174
  },
175
175
  experimental: {
176
176
  base: "EXPLORER",
@@ -181,7 +181,7 @@ const initialExplorerConfig: FullConfig = {
181
181
  id: "via",
182
182
  stable: {
183
183
  base: "EXPLORER",
184
- version: "v3",
184
+ version: "v2",
185
185
  },
186
186
  experimental: {
187
187
  base: "EXPLORER",
@@ -192,7 +192,7 @@ const initialExplorerConfig: FullConfig = {
192
192
  id: "zec",
193
193
  stable: {
194
194
  base: "EXPLORER",
195
- version: "v3",
195
+ version: "v2",
196
196
  },
197
197
  experimental: {
198
198
  base: "EXPLORER",
@@ -203,7 +203,7 @@ const initialExplorerConfig: FullConfig = {
203
203
  id: "zen",
204
204
  stable: {
205
205
  base: "EXPLORER",
206
- version: "v3",
206
+ version: "v2",
207
207
  },
208
208
  experimental: {
209
209
  base: "EXPLORER",
@@ -214,7 +214,7 @@ const initialExplorerConfig: FullConfig = {
214
214
  id: "btc_testnet",
215
215
  stable: {
216
216
  base: "EXPLORER",
217
- version: "v3",
217
+ version: "v2",
218
218
  },
219
219
  experimental: {
220
220
  base: "EXPLORER",
@@ -43,6 +43,11 @@ export const whitelistDependencies = ["Decred", "Decred Testnet"];
43
43
  ["ZenCash", "Bitcoin"],
44
44
  ["Paraswap", "Ethereum"],
45
45
  ["Lido", "Ethereum"],
46
+ ["1inch", "Ethereum"],
47
+ ["Aave", "Ethereum"],
48
+ ["Compound", "Ethereum"],
49
+ ["Opensea", "Ethereum"],
50
+ ["StakeDAO", "Ethereum"],
46
51
  ].forEach(([name, dep]) => declareDep(name, dep));
47
52
  export const getDependencies = (appName: string): string[] =>
48
53
  directDep[appName] || [];
@@ -3,7 +3,6 @@ import { BigNumber } from "bignumber.js";
3
3
  import { Observable, from } from "rxjs";
4
4
  import { log } from "@ledgerhq/logs";
5
5
  import { WrongDeviceForAccount } from "@ledgerhq/errors";
6
- import Transport from "@ledgerhq/hw-transport";
7
6
  import {
8
7
  getSeedIdentifierDerivation,
9
8
  getDerivationModesForCurrency,
@@ -32,7 +31,6 @@ import type {
32
31
  ScanAccountEvent,
33
32
  SyncConfig,
34
33
  CryptoCurrency,
35
- DerivationMode,
36
34
  } from "../types";
37
35
  import type { CurrencyBridge, AccountBridge } from "../types/bridge";
38
36
  import getAddress from "../hw/getAddress";
@@ -43,11 +41,7 @@ export type GetAccountShape = (
43
41
  currency: CryptoCurrency;
44
42
  address: string;
45
43
  id: string;
46
- index: number;
47
44
  initialAccount?: Account;
48
- derivationPath: string;
49
- derivationMode: DerivationMode;
50
- transport?: Transport;
51
45
  rest?: any;
52
46
  },
53
47
  arg1: SyncConfig
@@ -123,19 +117,11 @@ export const makeSync =
123
117
  const needClear = initial.id !== accountId;
124
118
 
125
119
  try {
126
- const freshAddressPath = getSeedIdentifierDerivation(
127
- initial.currency,
128
- initial.derivationMode
129
- );
130
-
131
120
  const shape = await getAccountShape(
132
121
  {
133
122
  currency: initial.currency,
134
123
  id: accountId,
135
- index: initial.index,
136
124
  address: initial.freshAddress,
137
- derivationPath: freshAddressPath,
138
- derivationMode: initial.derivationMode,
139
125
  initialAccount: needClear ? clearAccount(initial) : initial,
140
126
  },
141
127
  syncConfig
@@ -190,20 +176,15 @@ export const makeScanAccounts =
190
176
  index,
191
177
  { address, path: freshAddressPath, ...rest },
192
178
  derivationMode,
193
- seedIdentifier,
194
- transport
179
+ seedIdentifier
195
180
  ): Promise<Account | null | undefined> {
196
181
  if (finished) return;
197
182
  const accountId = `js:2:${currency.id}:${address}:${derivationMode}`;
198
183
  const accountShape: Partial<Account> = await getAccountShape(
199
184
  {
200
- transport,
201
185
  currency,
202
186
  id: accountId,
203
- index,
204
187
  address,
205
- derivationPath: freshAddressPath,
206
- derivationMode,
207
188
  rest,
208
189
  },
209
190
  syncConfig
@@ -332,8 +313,7 @@ export const makeScanAccounts =
332
313
  index,
333
314
  res,
334
315
  derivationMode,
335
- seedIdentifier,
336
- transport
316
+ seedIdentifier
337
317
  );
338
318
  log(
339
319
  "scanAccounts",
package/src/env.ts CHANGED
@@ -156,7 +156,7 @@ const envDefinitions = {
156
156
  desc: "location of the crypto.org indexer API",
157
157
  },
158
158
  CRYPTO_ORG_TESTNET_INDEXER: {
159
- def: "https://crypto.org/explorer/croeseid3",
159
+ def: "https://crypto.org/explorer/croeseid4",
160
160
  parser: stringParser,
161
161
  desc: "location of the crypto.org indexer testnet API",
162
162
  },
@@ -166,7 +166,7 @@ const envDefinitions = {
166
166
  desc: "location of the crypto.org indexer API",
167
167
  },
168
168
  CRYPTO_ORG_TESTNET_RPC_URL: {
169
- def: "https://testnet-croeseid-3.crypto.org:26657",
169
+ def: "https://testnet-croeseid-4.crypto.org:26657",
170
170
  parser: stringParser,
171
171
  desc: "location of the crypto.org chain testnet node",
172
172
  },
@@ -2,7 +2,7 @@ import type { Account } from "../../types";
2
2
  import type { BitcoinOutput, BitcoinInput } from "./types";
3
3
  import { formatCurrencyUnit } from "../../currencies";
4
4
  import { getEnv } from "../../env";
5
- import { perCoinLogic } from "./logic";
5
+ import { perCoinLogic } from "./transaction";
6
6
 
7
7
  const sortUTXO = (a, b) => b.value.minus(a.value).toNumber();
8
8
 
@@ -31,7 +31,6 @@ export function formatOutput(account: Account, o: BitcoinOutput): string {
31
31
  }).padEnd(12),
32
32
  o.address,
33
33
  o.path,
34
- o.isChange ? "(change)" : "",
35
34
  o.rbf ? "rbf" : "",
36
35
  o.hash,
37
36
  `@${o.outputIndex} (${
@@ -50,8 +50,8 @@ const dataset: CurrenciesData<Transaction> = {
50
50
  expectedStatus: {
51
51
  amount: new BigNumber("999"),
52
52
  // FIXME fee are reloaded?
53
- // estimatedFees: new BigNumber("250"),
54
- // totalSpent: new BigNumber("1249"),
53
+ // estimatedFees: BigNumber("250"),
54
+ // totalSpent: BigNumber("1249"),
55
55
  errors: {},
56
56
  warnings: {
57
57
  // feeTooHigh: new FeeTooHigh()
@@ -76,8 +76,8 @@ const dataset: CurrenciesData<Transaction> = {
76
76
  expectedStatus: {
77
77
  amount: new BigNumber("998"),
78
78
  // FIXME fee are reloaded?
79
- // estimatedFees: new BigNumber("250"),
80
- // totalSpent: new BigNumber("1248"),
79
+ // estimatedFees: BigNumber("250"),
80
+ // totalSpent: BigNumber("1248"),
81
81
  errors: {},
82
82
  warnings: {
83
83
  // feeTooHigh: new FeeTooHigh()
@@ -102,8 +102,8 @@ const dataset: CurrenciesData<Transaction> = {
102
102
  expectedStatus: {
103
103
  amount: new BigNumber("997"),
104
104
  // FIXME fee are reloaded?
105
- // estimatedFees: new BigNumber("250"),
106
- // totalSpent: new BigNumber("1247"),
105
+ // estimatedFees: BigNumber("250"),
106
+ // totalSpent: BigNumber("1247"),
107
107
  errors: {},
108
108
  warnings: {
109
109
  // feeTooHigh: new FeeTooHigh(),
@@ -50,8 +50,8 @@ const dataset: CurrenciesData<Transaction> = {
50
50
  expectedStatus: {
51
51
  errors: {},
52
52
  warnings: {},
53
- // estimatedFees: new BigNumber("5694"),
54
- amount: new BigNumber("200000"), // totalSpent: new BigNumber("205694")
53
+ // estimatedFees: BigNumber("5694"),
54
+ amount: new BigNumber("200000"), // totalSpent: BigNumber("205694")
55
55
  },
56
56
  },
57
57
  {
@@ -73,8 +73,8 @@ const dataset: CurrenciesData<Transaction> = {
73
73
  expectedStatus: {
74
74
  errors: {},
75
75
  warnings: {},
76
- // estimatedFees: new BigNumber("5694"),
77
- amount: new BigNumber("147200"), // totalSpent: new BigNumber("152894")
76
+ // estimatedFees: BigNumber("5694"),
77
+ amount: new BigNumber("147200"), // totalSpent: BigNumber("152894")
78
78
  },
79
79
  },
80
80
  {
@@ -96,8 +96,8 @@ const dataset: CurrenciesData<Transaction> = {
96
96
  expectedStatus: {
97
97
  errors: {},
98
98
  warnings: {},
99
- // estimatedFees: new BigNumber("5694"),
100
- amount: new BigNumber("205273"), // totalSpent: new BigNumber("210967")
99
+ // estimatedFees: BigNumber("5694"),
100
+ amount: new BigNumber("205273"), // totalSpent: BigNumber("210967")
101
101
  },
102
102
  },
103
103
  ],
@@ -38,7 +38,6 @@ export function toBitcoinOutputRaw({
38
38
  outputIndex,
39
39
  blockHeight,
40
40
  address,
41
- isChange,
42
41
  path,
43
42
  value,
44
43
  rbf,
@@ -48,7 +47,6 @@ export function toBitcoinOutputRaw({
48
47
  outputIndex,
49
48
  blockHeight,
50
49
  address,
51
- isChange ? 1 : 0,
52
50
  path,
53
51
  value.toString(),
54
52
  rbf ? 1 : 0,
@@ -59,7 +57,6 @@ export function fromBitcoinOutputRaw([
59
57
  outputIndex,
60
58
  blockHeight,
61
59
  address,
62
- isChange,
63
60
  path,
64
61
  value,
65
62
  rbf,
@@ -69,7 +66,6 @@ export function fromBitcoinOutputRaw([
69
66
  outputIndex,
70
67
  blockHeight: blockHeight || undefined,
71
68
  address: address || undefined,
72
- isChange: !!isChange,
73
69
  path: path || undefined,
74
70
  value: new BigNumber(value),
75
71
  rbf: !!rbf,
@@ -80,7 +76,6 @@ export function toBitcoinResourcesRaw(
80
76
  ): BitcoinResourcesRaw {
81
77
  return {
82
78
  utxos: r.utxos.map(toBitcoinOutputRaw),
83
- serializedData: r.serializedData,
84
79
  };
85
80
  }
86
81
  export function fromBitcoinResourcesRaw(
@@ -88,6 +83,5 @@ export function fromBitcoinResourcesRaw(
88
83
  ): BitcoinResources {
89
84
  return {
90
85
  utxos: r.utxos.map(fromBitcoinOutputRaw),
91
- serializedData: r.serializedData,
92
86
  };
93
87
  }
@@ -10,7 +10,8 @@ import { pickSiblings } from "../../bot/specs";
10
10
  import { bitcoinPickingStrategy } from "./types";
11
11
  import type { MutationSpec, AppSpec } from "../../bot/types";
12
12
  import { LowerThanMinimumRelayFee } from "../../errors";
13
- import { getMinRelayFee, getUTXOStatus, isChangeOutput } from "./logic";
13
+ import { getMinRelayFee } from "./fees";
14
+ import { isChangeOutput, getUTXOStatus } from "./transaction";
14
15
  import { DeviceModelId } from "@ledgerhq/devices";
15
16
  type Arg = Partial<{
16
17
  minimalAmount: BigNumber;
@@ -80,11 +81,7 @@ const genericTest = ({
80
81
  ? operation.senders
81
82
  : txInputs.map((t) => t.address).filter(Boolean),
82
83
  recipients: txOutputs
83
- // TODO REPLACE >>>>>>>>>>>>>>>>>>
84
84
  .filter((o) => !isChangeOutput(o))
85
- /*/ WITH <<<<<<<<<<<<<<<<<<<<<<<<<
86
- .filter((o) => !o.isChange)
87
- //*/
88
85
  .map((t) => t.address)
89
86
  .filter(Boolean),
90
87
  })
@@ -2,7 +2,7 @@ import type { DeviceAction } from "../../bot/types";
2
2
  import type { Transaction } from "./types";
3
3
  import { formatCurrencyUnit } from "../../currencies";
4
4
  import { deviceActionFlow } from "../../bot/specs";
5
- import { perCoinLogic } from "./logic";
5
+ import { perCoinLogic } from "./transaction";
6
6
  const acceptTransaction: DeviceAction<Transaction, any> = deviceActionFlow({
7
7
  steps: [
8
8
  {
@@ -19,7 +19,7 @@ import vertcoin from "./datasets/vertcoin";
19
19
  import viacoin from "./datasets/viacoin";
20
20
  import zcash from "./datasets/zcash";
21
21
  const dataset: DatasetTest<Transaction> = {
22
- implementations: ["js", "mock"],
22
+ implementations: ["libcore", "mock"],
23
23
  currencies: {
24
24
  bitcoin_cash,
25
25
  bitcoin_gold,
@@ -25,102 +25,6 @@ import { formatCurrencyUnit } from "../../currencies";
25
25
  import type { CryptoCurrencyIds } from "../../types";
26
26
  import { libcoreAmountToBigNumber } from "../../libcore/buildBigNumber";
27
27
 
28
- const fromFeeItemsRaw = (fir: FeeItemsRaw): FeeItems => ({
29
- items: fir.items.map((fi) => ({
30
- key: fi.key,
31
- speed: fi.speed,
32
- feePerByte: new BigNumber(fi.feePerByte),
33
- })),
34
- defaultFeePerByte: new BigNumber(fir.defaultFeePerByte),
35
- });
36
-
37
- const toFeeItemsRaw = (fir: FeeItems): FeeItemsRaw => ({
38
- items: fir.items.map((fi) => ({
39
- key: fi.key,
40
- speed: fi.speed,
41
- feePerByte: fi.feePerByte.toString(),
42
- })),
43
- defaultFeePerByte: fir.defaultFeePerByte.toString(),
44
- });
45
-
46
- export const fromTransactionRaw = (tr: TransactionRaw): Transaction => {
47
- const common = fromTransactionCommonRaw(tr);
48
- return {
49
- ...common,
50
- rbf: tr.rbf,
51
- utxoStrategy: tr.utxoStrategy,
52
- family: tr.family,
53
- feePerByte: tr.feePerByte ? new BigNumber(tr.feePerByte) : null,
54
- networkInfo: tr.networkInfo && {
55
- family: tr.networkInfo.family,
56
- feeItems: fromFeeItemsRaw(tr.networkInfo.feeItems),
57
- },
58
- feesStrategy: tr.feesStrategy,
59
- };
60
- };
61
- export const toTransactionRaw = (t: Transaction): TransactionRaw => {
62
- const common = toTransactionCommonRaw(t);
63
- return {
64
- ...common,
65
- rbf: t.rbf,
66
- utxoStrategy: t.utxoStrategy,
67
- family: t.family,
68
- feePerByte: t.feePerByte ? t.feePerByte.toString() : null,
69
- networkInfo: t.networkInfo && {
70
- family: t.networkInfo.family,
71
- feeItems: toFeeItemsRaw(t.networkInfo.feeItems),
72
- },
73
- feesStrategy: t.feesStrategy,
74
- };
75
- };
76
-
77
- const formatNetworkInfo = (
78
- networkInfo:
79
- | {
80
- feeItems: FeeItems;
81
- }
82
- | null
83
- | undefined
84
- ) => {
85
- if (!networkInfo) return "network info not loaded";
86
- return `network fees: ${networkInfo.feeItems.items
87
- .map((i) => i.key + "=" + i.feePerByte.toString())
88
- .join(", ")}`;
89
- };
90
-
91
- export const formatTransaction = (t: Transaction, account: Account): string => {
92
- const n = getEnv("DEBUG_UTXO_DISPLAY");
93
- const { excludeUTXOs, strategy, pickUnconfirmedRBF } = t.utxoStrategy;
94
- const displayAll = excludeUTXOs.length <= n;
95
- return `
96
- SEND ${
97
- t.useAllAmount
98
- ? "MAX"
99
- : formatCurrencyUnit(getAccountUnit(account), t.amount, {
100
- showCode: true,
101
- disableRounding: true,
102
- })
103
- }
104
- TO ${t.recipient}
105
- with feePerByte=${
106
- t.feePerByte ? t.feePerByte.toString() : "?"
107
- } (${formatNetworkInfo(t.networkInfo)})
108
- ${[
109
- Object.keys(bitcoinPickingStrategy).find(
110
- (k) => bitcoinPickingStrategy[k] === strategy
111
- ),
112
- pickUnconfirmedRBF && "pick-unconfirmed",
113
- t.rbf && "RBF-enabled",
114
- ]
115
- .filter(Boolean)
116
- .join(" ")}${excludeUTXOs
117
- .slice(0, displayAll ? excludeUTXOs.length : n)
118
- .map((utxo) => `\nexclude ${utxo.hash} @${utxo.outputIndex}`)
119
- .join("")}`;
120
- };
121
-
122
- // TODO vvvvv DEPRECATED, TO BE REMOVED vvvvv
123
-
124
28
  function bchExplicit(str: string): string {
125
29
  const explicit = str.includes(":") ? str : "bitcoincash:" + str;
126
30
 
@@ -254,7 +158,6 @@ export async function parseBitcoinOutput(
254
158
  outputIndex,
255
159
  blockHeight,
256
160
  address,
257
- isChange: false,
258
161
  path,
259
162
  value,
260
163
  rbf,
@@ -298,8 +201,100 @@ export function isChangeOutput(output: BitcoinOutput): boolean {
298
201
  const p = output.path.split("/");
299
202
  return p[p.length - 2] === "1";
300
203
  }
301
- // ==============================================================================
302
204
 
205
+ const fromFeeItemsRaw = (fir: FeeItemsRaw): FeeItems => ({
206
+ items: fir.items.map((fi) => ({
207
+ key: fi.key,
208
+ speed: fi.speed,
209
+ feePerByte: new BigNumber(fi.feePerByte),
210
+ })),
211
+ defaultFeePerByte: new BigNumber(fir.defaultFeePerByte),
212
+ });
213
+
214
+ const toFeeItemsRaw = (fir: FeeItems): FeeItemsRaw => ({
215
+ items: fir.items.map((fi) => ({
216
+ key: fi.key,
217
+ speed: fi.speed,
218
+ feePerByte: fi.feePerByte.toString(),
219
+ })),
220
+ defaultFeePerByte: fir.defaultFeePerByte.toString(),
221
+ });
222
+
223
+ export const fromTransactionRaw = (tr: TransactionRaw): Transaction => {
224
+ const common = fromTransactionCommonRaw(tr);
225
+ return {
226
+ ...common,
227
+ rbf: tr.rbf,
228
+ utxoStrategy: tr.utxoStrategy,
229
+ family: tr.family,
230
+ feePerByte: tr.feePerByte ? new BigNumber(tr.feePerByte) : null,
231
+ networkInfo: tr.networkInfo && {
232
+ family: tr.networkInfo.family,
233
+ feeItems: fromFeeItemsRaw(tr.networkInfo.feeItems),
234
+ },
235
+ feesStrategy: tr.feesStrategy,
236
+ };
237
+ };
238
+ export const toTransactionRaw = (t: Transaction): TransactionRaw => {
239
+ const common = toTransactionCommonRaw(t);
240
+ return {
241
+ ...common,
242
+ rbf: t.rbf,
243
+ utxoStrategy: t.utxoStrategy,
244
+ family: t.family,
245
+ feePerByte: t.feePerByte ? t.feePerByte.toString() : null,
246
+ networkInfo: t.networkInfo && {
247
+ family: t.networkInfo.family,
248
+ feeItems: toFeeItemsRaw(t.networkInfo.feeItems),
249
+ },
250
+ feesStrategy: t.feesStrategy,
251
+ };
252
+ };
253
+
254
+ const formatNetworkInfo = (
255
+ networkInfo:
256
+ | {
257
+ feeItems: FeeItems;
258
+ }
259
+ | null
260
+ | undefined
261
+ ) => {
262
+ if (!networkInfo) return "network info not loaded";
263
+ return `network fees: ${networkInfo.feeItems.items
264
+ .map((i) => i.key + "=" + i.feePerByte.toString())
265
+ .join(", ")}`;
266
+ };
267
+
268
+ export const formatTransaction = (t: Transaction, account: Account): string => {
269
+ const n = getEnv("DEBUG_UTXO_DISPLAY");
270
+ const { excludeUTXOs, strategy, pickUnconfirmedRBF } = t.utxoStrategy;
271
+ const displayAll = excludeUTXOs.length <= n;
272
+ return `
273
+ SEND ${
274
+ t.useAllAmount
275
+ ? "MAX"
276
+ : formatCurrencyUnit(getAccountUnit(account), t.amount, {
277
+ showCode: true,
278
+ disableRounding: true,
279
+ })
280
+ }
281
+ TO ${t.recipient}
282
+ with feePerByte=${
283
+ t.feePerByte ? t.feePerByte.toString() : "?"
284
+ } (${formatNetworkInfo(t.networkInfo)})
285
+ ${[
286
+ Object.keys(bitcoinPickingStrategy).find(
287
+ (k) => bitcoinPickingStrategy[k] === strategy
288
+ ),
289
+ pickUnconfirmedRBF && "pick-unconfirmed",
290
+ t.rbf && "RBF-enabled",
291
+ ]
292
+ .filter(Boolean)
293
+ .join(" ")}${excludeUTXOs
294
+ .slice(0, displayAll ? excludeUTXOs.length : n)
295
+ .map((utxo) => `\nexclude ${utxo.hash} @${utxo.outputIndex}`)
296
+ .join("")}`;
297
+ };
303
298
  export default {
304
299
  fromTransactionRaw,
305
300
  toTransactionRaw,