@ledgerhq/live-common 21.14.0 → 21.16.1

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 (228) hide show
  1. package/lib/__tests__/derivation.js +1 -1
  2. package/lib/__tests__/derivation.js.map +1 -1
  3. package/lib/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.js +2 -2
  4. package/lib/account/formatters.d.ts.map +1 -1
  5. package/lib/account/formatters.js +33 -1
  6. package/lib/account/formatters.js.map +1 -1
  7. package/lib/account/groupOperations.js +1 -1
  8. package/lib/account/groupOperations.js.map +1 -1
  9. package/lib/account/pending.d.ts +1 -0
  10. package/lib/account/pending.d.ts.map +1 -1
  11. package/lib/account/serialization.d.ts +6 -4
  12. package/lib/account/serialization.d.ts.map +1 -1
  13. package/lib/account/serialization.js +47 -9
  14. package/lib/account/serialization.js.map +1 -1
  15. package/lib/api/Ethereum.d.ts +22 -1
  16. package/lib/api/Ethereum.d.ts.map +1 -1
  17. package/lib/api/Ethereum.js +21 -1
  18. package/lib/api/Ethereum.js.map +1 -1
  19. package/lib/bridge/jsHelpers.d.ts +2 -1
  20. package/lib/bridge/jsHelpers.d.ts.map +1 -1
  21. package/lib/bridge/jsHelpers.js +27 -1
  22. package/lib/bridge/jsHelpers.js.map +1 -1
  23. package/lib/csvExport.d.ts.map +1 -1
  24. package/lib/csvExport.js +3 -1
  25. package/lib/csvExport.js.map +1 -1
  26. package/lib/currencies/sortByMarketcap.d.ts.map +1 -1
  27. package/lib/currencies/sortByMarketcap.js +8 -1
  28. package/lib/currencies/sortByMarketcap.js.map +1 -1
  29. package/lib/env.d.ts +15 -5
  30. package/lib/env.d.ts.map +1 -1
  31. package/lib/env.js +11 -0
  32. package/lib/env.js.map +1 -1
  33. package/lib/env.react.d.ts +1 -1
  34. package/lib/env.react.d.ts.map +1 -1
  35. package/lib/families/bitcoin/datasets/bitcoin.d.ts.map +1 -1
  36. package/lib/families/bitcoin/datasets/bitcoin.js +4 -0
  37. package/lib/families/bitcoin/datasets/bitcoin.js.map +1 -1
  38. package/lib/families/bitcoin/datasets/bitcoin_cash.d.ts.map +1 -1
  39. package/lib/families/bitcoin/datasets/bitcoin_cash.js +4 -0
  40. package/lib/families/bitcoin/datasets/bitcoin_cash.js.map +1 -1
  41. package/lib/families/bitcoin/datasets/bitcoin_gold.d.ts.map +1 -1
  42. package/lib/families/bitcoin/datasets/bitcoin_gold.js +4 -0
  43. package/lib/families/bitcoin/datasets/bitcoin_gold.js.map +1 -1
  44. package/lib/families/bitcoin/datasets/dash.d.ts.map +1 -1
  45. package/lib/families/bitcoin/datasets/dash.js +4 -0
  46. package/lib/families/bitcoin/datasets/dash.js.map +1 -1
  47. package/lib/families/bitcoin/datasets/decred.d.ts.map +1 -1
  48. package/lib/families/bitcoin/datasets/decred.js +4 -0
  49. package/lib/families/bitcoin/datasets/decred.js.map +1 -1
  50. package/lib/families/bitcoin/datasets/digibyte.d.ts.map +1 -1
  51. package/lib/families/bitcoin/datasets/digibyte.js +4 -0
  52. package/lib/families/bitcoin/datasets/digibyte.js.map +1 -1
  53. package/lib/families/bitcoin/datasets/dogecoin.d.ts.map +1 -1
  54. package/lib/families/bitcoin/datasets/dogecoin.js +4 -0
  55. package/lib/families/bitcoin/datasets/dogecoin.js.map +1 -1
  56. package/lib/families/bitcoin/datasets/komodo.d.ts.map +1 -1
  57. package/lib/families/bitcoin/datasets/komodo.js +4 -0
  58. package/lib/families/bitcoin/datasets/komodo.js.map +1 -1
  59. package/lib/families/bitcoin/datasets/litecoin.d.ts.map +1 -1
  60. package/lib/families/bitcoin/datasets/litecoin.js +4 -0
  61. package/lib/families/bitcoin/datasets/litecoin.js.map +1 -1
  62. package/lib/families/bitcoin/datasets/peercoin.d.ts.map +1 -1
  63. package/lib/families/bitcoin/datasets/peercoin.js +4 -0
  64. package/lib/families/bitcoin/datasets/peercoin.js.map +1 -1
  65. package/lib/families/bitcoin/datasets/pivx.d.ts.map +1 -1
  66. package/lib/families/bitcoin/datasets/pivx.js +4 -0
  67. package/lib/families/bitcoin/datasets/pivx.js.map +1 -1
  68. package/lib/families/bitcoin/datasets/qtum.d.ts.map +1 -1
  69. package/lib/families/bitcoin/datasets/qtum.js +4 -0
  70. package/lib/families/bitcoin/datasets/qtum.js.map +1 -1
  71. package/lib/families/bitcoin/datasets/stakenet.d.ts.map +1 -1
  72. package/lib/families/bitcoin/datasets/stakenet.js +4 -0
  73. package/lib/families/bitcoin/datasets/stakenet.js.map +1 -1
  74. package/lib/families/bitcoin/datasets/vertcoin.d.ts.map +1 -1
  75. package/lib/families/bitcoin/datasets/vertcoin.js +4 -0
  76. package/lib/families/bitcoin/datasets/vertcoin.js.map +1 -1
  77. package/lib/families/bitcoin/datasets/viacoin.d.ts.map +1 -1
  78. package/lib/families/bitcoin/datasets/viacoin.js +4 -0
  79. package/lib/families/bitcoin/datasets/viacoin.js.map +1 -1
  80. package/lib/families/bitcoin/datasets/zcash.d.ts.map +1 -1
  81. package/lib/families/bitcoin/datasets/zcash.js +4 -0
  82. package/lib/families/bitcoin/datasets/zcash.js.map +1 -1
  83. package/lib/families/bitcoin/datasets/zencash.d.ts.map +1 -1
  84. package/lib/families/bitcoin/datasets/zencash.js +4 -0
  85. package/lib/families/bitcoin/datasets/zencash.js.map +1 -1
  86. package/lib/families/bitcoin/js-synchronisation.d.ts.map +1 -1
  87. package/lib/families/bitcoin/js-synchronisation.js +25 -14
  88. package/lib/families/bitcoin/js-synchronisation.js.map +1 -1
  89. package/lib/families/bitcoin/logic.d.ts +1 -1
  90. package/lib/families/bitcoin/logic.d.ts.map +1 -1
  91. package/lib/families/bitcoin/logic.js +6 -0
  92. package/lib/families/bitcoin/logic.js.map +1 -1
  93. package/lib/families/bitcoin/specs.d.ts.map +1 -1
  94. package/lib/families/bitcoin/specs.js +2 -1
  95. package/lib/families/bitcoin/specs.js.map +1 -1
  96. package/lib/families/bitcoin/test-dataset.js +2 -2
  97. package/lib/families/bitcoin/test-dataset.js.map +1 -1
  98. package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts.map +1 -1
  99. package/lib/families/bitcoin/wallet-btc/crypto/base.js +1 -0
  100. package/lib/families/bitcoin/wallet-btc/crypto/base.js.map +1 -1
  101. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js +1 -1
  102. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js.map +1 -1
  103. package/lib/families/bitcoin/wallet-btc/crypto/zec.js +1 -1
  104. package/lib/families/bitcoin/wallet-btc/crypto/zec.js.map +1 -1
  105. package/lib/families/bitcoin/wallet-btc/crypto/zen.js +1 -1
  106. package/lib/families/bitcoin/wallet-btc/crypto/zen.js.map +1 -1
  107. package/lib/families/bitcoin/wallet-btc/pickingstrategies/CoinSelect.js +3 -3
  108. package/lib/families/bitcoin/wallet-btc/pickingstrategies/DeepFirst.js +5 -5
  109. package/lib/families/bitcoin/wallet-btc/pickingstrategies/Merge.js +5 -5
  110. package/lib/families/bitcoin/wallet-btc/utils.d.ts +2 -1
  111. package/lib/families/bitcoin/wallet-btc/utils.d.ts.map +1 -1
  112. package/lib/families/bitcoin/wallet-btc/utils.js +18 -10
  113. package/lib/families/bitcoin/wallet-btc/utils.js.map +1 -1
  114. package/lib/families/bitcoin/wallet-btc/wallet.d.ts.map +1 -1
  115. package/lib/families/bitcoin/wallet-btc/wallet.js +5 -3
  116. package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
  117. package/lib/families/ethereum/signOperation.d.ts.map +1 -1
  118. package/lib/families/ethereum/signOperation.js +7 -0
  119. package/lib/families/ethereum/signOperation.js.map +1 -1
  120. package/lib/families/ethereum/synchronisation.d.ts.map +1 -1
  121. package/lib/families/ethereum/synchronisation.js +175 -15
  122. package/lib/families/ethereum/synchronisation.js.map +1 -1
  123. package/lib/families/ethereum/versions.d.ts +2 -0
  124. package/lib/families/ethereum/versions.d.ts.map +1 -0
  125. package/lib/families/ethereum/versions.js +5 -0
  126. package/lib/families/ethereum/versions.js.map +1 -0
  127. package/lib/nft/NftMetadataProvider/index.d.ts +17 -0
  128. package/lib/nft/NftMetadataProvider/index.d.ts.map +1 -0
  129. package/lib/nft/NftMetadataProvider/index.js +244 -0
  130. package/lib/nft/NftMetadataProvider/index.js.map +1 -0
  131. package/lib/nft/NftMetadataProvider/logic.d.ts +3 -0
  132. package/lib/nft/NftMetadataProvider/logic.d.ts.map +1 -0
  133. package/lib/nft/NftMetadataProvider/logic.js +22 -0
  134. package/lib/nft/NftMetadataProvider/logic.js.map +1 -0
  135. package/lib/nft/NftMetadataProvider/types.d.ts +44 -0
  136. package/lib/nft/NftMetadataProvider/types.d.ts.map +1 -0
  137. package/lib/nft/NftMetadataProvider/types.js +3 -0
  138. package/lib/nft/NftMetadataProvider/types.js.map +1 -0
  139. package/lib/nft/helpers.d.ts +10 -0
  140. package/lib/nft/helpers.d.ts.map +1 -0
  141. package/lib/nft/helpers.js +85 -0
  142. package/lib/nft/helpers.js.map +1 -0
  143. package/lib/nft/index.d.ts +4 -0
  144. package/lib/nft/index.d.ts.map +1 -0
  145. package/lib/nft/index.js +16 -0
  146. package/lib/nft/index.js.map +1 -0
  147. package/lib/nft/nftId.d.ts +3 -0
  148. package/lib/nft/nftId.d.ts.map +1 -0
  149. package/lib/nft/nftId.js +33 -0
  150. package/lib/nft/nftId.js.map +1 -0
  151. package/lib/operation.d.ts +1 -1
  152. package/lib/operation.d.ts.map +1 -1
  153. package/lib/operation.js +19 -5
  154. package/lib/operation.js.map +1 -1
  155. package/lib/reconciliation.d.ts.map +1 -1
  156. package/lib/reconciliation.js +6 -0
  157. package/lib/reconciliation.js.map +1 -1
  158. package/lib/types/account.d.ts +3 -0
  159. package/lib/types/account.d.ts.map +1 -1
  160. package/lib/types/index.d.ts +1 -0
  161. package/lib/types/index.d.ts.map +1 -1
  162. package/lib/types/index.js +1 -0
  163. package/lib/types/index.js.map +1 -1
  164. package/lib/types/nft.d.ts +29 -0
  165. package/lib/types/nft.d.ts.map +1 -0
  166. package/lib/types/nft.js +3 -0
  167. package/lib/types/nft.js.map +1 -0
  168. package/lib/types/operation.d.ts +12 -1
  169. package/lib/types/operation.d.ts.map +1 -1
  170. package/package.json +12 -12
  171. package/src/__tests__/__snapshots__/all.libcore.ts.snap +11922 -128102
  172. package/src/__tests__/derivation.ts +1 -1
  173. package/src/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.ts +2 -2
  174. package/src/account/formatters.ts +43 -0
  175. package/src/account/groupOperations.ts +2 -2
  176. package/src/account/serialization.ts +52 -0
  177. package/src/api/Ethereum.ts +40 -2
  178. package/src/bridge/jsHelpers.ts +35 -0
  179. package/src/csvExport.ts +3 -2
  180. package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +1351 -0
  181. package/src/currencies/sortByMarketcap.ts +9 -1
  182. package/src/env.ts +11 -0
  183. package/src/families/bitcoin/datasets/bitcoin.ts +4 -0
  184. package/src/families/bitcoin/datasets/bitcoin_cash.ts +4 -0
  185. package/src/families/bitcoin/datasets/bitcoin_gold.ts +4 -0
  186. package/src/families/bitcoin/datasets/dash.ts +4 -0
  187. package/src/families/bitcoin/datasets/decred.ts +4 -0
  188. package/src/families/bitcoin/datasets/digibyte.ts +4 -0
  189. package/src/families/bitcoin/datasets/dogecoin.ts +4 -0
  190. package/src/families/bitcoin/datasets/komodo.ts +4 -0
  191. package/src/families/bitcoin/datasets/litecoin.ts +4 -0
  192. package/src/families/bitcoin/datasets/peercoin.ts +4 -0
  193. package/src/families/bitcoin/datasets/pivx.ts +4 -0
  194. package/src/families/bitcoin/datasets/qtum.ts +4 -0
  195. package/src/families/bitcoin/datasets/stakenet.ts +4 -0
  196. package/src/families/bitcoin/datasets/vertcoin.ts +4 -0
  197. package/src/families/bitcoin/datasets/viacoin.ts +4 -0
  198. package/src/families/bitcoin/datasets/zcash.ts +4 -0
  199. package/src/families/bitcoin/datasets/zencash.ts +4 -0
  200. package/src/families/bitcoin/js-synchronisation.ts +28 -16
  201. package/src/families/bitcoin/logic.ts +7 -2
  202. package/src/families/bitcoin/specs.ts +6 -1
  203. package/src/families/bitcoin/test-dataset.ts +2 -2
  204. package/src/families/bitcoin/wallet-btc/crypto/base.ts +1 -0
  205. package/src/families/bitcoin/wallet-btc/crypto/bitcoincash.ts +1 -1
  206. package/src/families/bitcoin/wallet-btc/crypto/zec.ts +1 -1
  207. package/src/families/bitcoin/wallet-btc/crypto/zen.ts +1 -1
  208. package/src/families/bitcoin/wallet-btc/pickingstrategies/CoinSelect.ts +3 -3
  209. package/src/families/bitcoin/wallet-btc/pickingstrategies/DeepFirst.ts +5 -5
  210. package/src/families/bitcoin/wallet-btc/pickingstrategies/Merge.ts +5 -5
  211. package/src/families/bitcoin/wallet-btc/utils.ts +24 -9
  212. package/src/families/bitcoin/wallet-btc/wallet.ts +4 -2
  213. package/src/families/ethereum/modules/__snapshots__/compound.resilience.test.ts.snap +2876 -0
  214. package/src/families/ethereum/signOperation.ts +8 -0
  215. package/src/families/ethereum/synchronisation.ts +185 -6
  216. package/src/families/ethereum/versions.ts +1 -0
  217. package/src/nft/NftMetadataProvider/index.tsx +205 -0
  218. package/src/nft/NftMetadataProvider/logic.ts +20 -0
  219. package/src/nft/NftMetadataProvider/types.ts +60 -0
  220. package/src/nft/helpers.ts +78 -0
  221. package/src/nft/index.ts +3 -0
  222. package/src/nft/nftId.ts +17 -0
  223. package/src/operation.ts +22 -3
  224. package/src/reconciliation.ts +7 -0
  225. package/src/types/account.ts +4 -0
  226. package/src/types/index.ts +1 -0
  227. package/src/types/nft.ts +38 -0
  228. package/src/types/operation.ts +23 -1
@@ -81,7 +81,15 @@ export const getMarketcapTickers: () => Promise<string[]> = makeLRUCache(() =>
81
81
  export const useMarketcapTickers = (): string[] | null | undefined => {
82
82
  const [tickers, setMarketcapTickers] = useState(marketcapTickersCache);
83
83
  useEffect(() => {
84
- getMarketcapTickers().then(setMarketcapTickers);
84
+ let isMounted = true;
85
+
86
+ getMarketcapTickers().then((data) => {
87
+ if (isMounted) setMarketcapTickers(data);
88
+ });
89
+
90
+ return () => {
91
+ isMounted = false;
92
+ };
85
93
  }, []);
86
94
  return tickers;
87
95
  };
package/src/env.ts CHANGED
@@ -376,6 +376,17 @@ const envDefinitions = {
376
376
  parser: stringParser,
377
377
  desc: "mock the server response for the exchange KYC check, options are 'open', 'pending', 'closed' or 'approved'.",
378
378
  },
379
+ NFT: {
380
+ def: false,
381
+ parser: boolParser,
382
+ desc: "synchronizing nfts",
383
+ },
384
+ NFT_ETH_METADATA_SERVICE: {
385
+ // FIXME LL-8001
386
+ def: "https://nft.staging.aws.ledger.fr/v1/ethereum/1/contracts/tokens/infos",
387
+ parser: stringParser,
388
+ desc: "service uri used to get the metadata of an nft",
389
+ },
379
390
  OPERATION_ADDRESSES_LIMIT: {
380
391
  def: 100,
381
392
  parser: intParser,
@@ -28,6 +28,10 @@ const networkInfo: NetworkInfoRaw = {
28
28
  },
29
29
  };
30
30
  const dataset: CurrenciesData<Transaction> = {
31
+ FIXME_ignoreAccountFields: [
32
+ "bitcoinResources.walletAccount", // it is not "stable"
33
+ "bitcoinResources.utxos", // TODO: fix ordering
34
+ ],
31
35
  scanAccounts: [scanAccounts1],
32
36
  accounts: [
33
37
  {
@@ -1,6 +1,10 @@
1
1
  import type { CurrenciesData } from "../../../types";
2
2
  import type { Transaction } from "../types";
3
3
  const dataset: CurrenciesData<Transaction> = {
4
+ FIXME_ignoreAccountFields: [
5
+ "bitcoinResources.walletAccount", // it is not "stable"
6
+ "bitcoinResources.utxos", // TODO: fix ordering
7
+ ],
4
8
  scanAccounts: [
5
9
  {
6
10
  name: "bitcoin_cash seed 1",
@@ -1,6 +1,10 @@
1
1
  import type { CurrenciesData } from "../../../types";
2
2
  import type { Transaction } from "../types";
3
3
  const dataset: CurrenciesData<Transaction> = {
4
+ FIXME_ignoreAccountFields: [
5
+ "bitcoinResources.walletAccount", // it is not "stable"
6
+ "bitcoinResources.utxos", // TODO: fix ordering
7
+ ],
4
8
  scanAccounts: [
5
9
  {
6
10
  name: "bitcoin_gold seed 1",
@@ -1,6 +1,10 @@
1
1
  import type { CurrenciesData } from "../../../types";
2
2
  import type { Transaction } from "../types";
3
3
  const dataset: CurrenciesData<Transaction> = {
4
+ FIXME_ignoreAccountFields: [
5
+ "bitcoinResources.walletAccount", // it is not "stable"
6
+ "bitcoinResources.utxos", // TODO: fix ordering
7
+ ],
4
8
  scanAccounts: [
5
9
  {
6
10
  name: "dash seed 1",
@@ -1,6 +1,10 @@
1
1
  import type { CurrenciesData } from "../../../types";
2
2
  import type { Transaction } from "../types";
3
3
  const dataset: CurrenciesData<Transaction> = {
4
+ FIXME_ignoreAccountFields: [
5
+ "bitcoinResources.walletAccount", // it is not "stable"
6
+ "bitcoinResources.utxos", // TODO: fix ordering
7
+ ],
4
8
  scanAccounts: [
5
9
  {
6
10
  name: "decred seed 1",
@@ -27,6 +27,10 @@ const networkInfo: NetworkInfoRaw = {
27
27
  },
28
28
  };
29
29
  const dataset: CurrenciesData<Transaction> = {
30
+ FIXME_ignoreAccountFields: [
31
+ "bitcoinResources.walletAccount", // it is not "stable"
32
+ "bitcoinResources.utxos", // TODO: fix ordering
33
+ ],
30
34
  scanAccounts: [scanAccounts1],
31
35
  accounts: [
32
36
  {
@@ -1,6 +1,10 @@
1
1
  import type { CurrenciesData } from "../../../types";
2
2
  import type { Transaction } from "../types";
3
3
  const dataset: CurrenciesData<Transaction> = {
4
+ FIXME_ignoreAccountFields: [
5
+ "bitcoinResources.walletAccount", // it is not "stable"
6
+ "bitcoinResources.utxos", // TODO: fix ordering
7
+ ],
4
8
  scanAccounts: [
5
9
  {
6
10
  name: "dogecoin seed 1",
@@ -1,6 +1,10 @@
1
1
  import type { CurrenciesData } from "../../../types";
2
2
  import type { Transaction } from "../types";
3
3
  const dataset: CurrenciesData<Transaction> = {
4
+ FIXME_ignoreAccountFields: [
5
+ "bitcoinResources.walletAccount", // it is not "stable"
6
+ "bitcoinResources.utxos", // TODO: fix ordering
7
+ ],
4
8
  scanAccounts: [
5
9
  {
6
10
  name: "komodo seed 1",
@@ -27,6 +27,10 @@ const networkInfo: NetworkInfoRaw = {
27
27
  },
28
28
  };
29
29
  const dataset: CurrenciesData<Transaction> = {
30
+ FIXME_ignoreAccountFields: [
31
+ "bitcoinResources.walletAccount", // it is not "stable"
32
+ "bitcoinResources.utxos", // TODO: fix ordering
33
+ ],
30
34
  scanAccounts: [scanAccounts1],
31
35
  accounts: [
32
36
  {
@@ -1,6 +1,10 @@
1
1
  import type { CurrenciesData } from "../../../types";
2
2
  import type { Transaction } from "../types";
3
3
  const dataset: CurrenciesData<Transaction> = {
4
+ FIXME_ignoreAccountFields: [
5
+ "bitcoinResources.walletAccount", // it is not "stable"
6
+ "bitcoinResources.utxos", // TODO: fix ordering
7
+ ],
4
8
  scanAccounts: [
5
9
  {
6
10
  name: "peercoin seed 1",
@@ -1,6 +1,10 @@
1
1
  import type { CurrenciesData } from "../../../types";
2
2
  import type { Transaction } from "../types";
3
3
  const dataset: CurrenciesData<Transaction> = {
4
+ FIXME_ignoreAccountFields: [
5
+ "bitcoinResources.walletAccount", // it is not "stable"
6
+ "bitcoinResources.utxos", // TODO: fix ordering
7
+ ],
4
8
  scanAccounts: [
5
9
  {
6
10
  name: "pivx seed 1",
@@ -1,6 +1,10 @@
1
1
  import type { CurrenciesData } from "../../../types";
2
2
  import type { Transaction } from "../types";
3
3
  const dataset: CurrenciesData<Transaction> = {
4
+ FIXME_ignoreAccountFields: [
5
+ "bitcoinResources.walletAccount", // it is not "stable"
6
+ "bitcoinResources.utxos", // TODO: fix ordering
7
+ ],
4
8
  scanAccounts: [
5
9
  {
6
10
  name: "qtum seed 1",
@@ -1,6 +1,10 @@
1
1
  import type { CurrenciesData } from "../../../types";
2
2
  import type { Transaction } from "../types";
3
3
  const dataset: CurrenciesData<Transaction> = {
4
+ FIXME_ignoreAccountFields: [
5
+ "bitcoinResources.walletAccount", // it is not "stable"
6
+ "bitcoinResources.utxos", // TODO: fix ordering
7
+ ],
4
8
  scanAccounts: [
5
9
  {
6
10
  name: "stakenet seed 1",
@@ -1,6 +1,10 @@
1
1
  import type { CurrenciesData } from "../../../types";
2
2
  import type { Transaction } from "../types";
3
3
  const dataset: CurrenciesData<Transaction> = {
4
+ FIXME_ignoreAccountFields: [
5
+ "bitcoinResources.walletAccount", // it is not "stable"
6
+ "bitcoinResources.utxos", // TODO: fix ordering
7
+ ],
4
8
  scanAccounts: [
5
9
  {
6
10
  name: "vertcoin seed 1",
@@ -1,6 +1,10 @@
1
1
  import type { CurrenciesData } from "../../../types";
2
2
  import type { Transaction } from "../types";
3
3
  const dataset: CurrenciesData<Transaction> = {
4
+ FIXME_ignoreAccountFields: [
5
+ "bitcoinResources.walletAccount", // it is not "stable"
6
+ "bitcoinResources.utxos", // TODO: fix ordering
7
+ ],
4
8
  scanAccounts: [
5
9
  {
6
10
  name: "viacoin seed 1",
@@ -1,6 +1,10 @@
1
1
  import type { CurrenciesData } from "../../../types";
2
2
  import type { Transaction } from "../types";
3
3
  const dataset: CurrenciesData<Transaction> = {
4
+ FIXME_ignoreAccountFields: [
5
+ "bitcoinResources.walletAccount", // it is not "stable"
6
+ "bitcoinResources.utxos", // TODO: fix ordering
7
+ ],
4
8
  scanAccounts: [
5
9
  {
6
10
  name: "zcash seed 1",
@@ -1,6 +1,10 @@
1
1
  import type { CurrenciesData } from "../../../types";
2
2
  import type { Transaction } from "../types";
3
3
  const dataset: CurrenciesData<Transaction> = {
4
+ FIXME_ignoreAccountFields: [
5
+ "bitcoinResources.walletAccount", // it is not "stable"
6
+ "bitcoinResources.utxos", // TODO: fix ordering
7
+ ],
4
8
  scanAccounts: [
5
9
  {
6
10
  name: "zencash seed 1",
@@ -128,18 +128,42 @@ const mapTxToOperations = (
128
128
  // All inputs of a same transaction have the same sequence
129
129
  const transactionSequenceNumber =
130
130
  (accountInputs.length > 0 && accountInputs[0].sequence) || undefined;
131
+
131
132
  const hasSpentNothing = value.eq(0);
133
+ // Change output is always the last one
134
+ const changeOutputIndex = tx.outputs
135
+ .map((o) => o.output_index)
136
+ .reduce((p, c) => (p > c ? p : c));
132
137
 
133
138
  for (const output of tx.outputs) {
134
139
  if (output.address) {
135
- if (accountAddresses.includes(output.address)) {
140
+ if (!accountAddresses.includes(output.address)) {
141
+ // The output doesn't belong to this account
142
+ if (output.output_index < changeOutputIndex) {
143
+ // The output isn't the change output
144
+ recipients.push(
145
+ syncReplaceAddress
146
+ ? syncReplaceAddress(output.address)
147
+ : output.address
148
+ );
149
+ }
150
+ } else {
151
+ // The output belongs to this account
136
152
  accountOutputs.push(output);
137
153
 
138
- if (changeAddresses.includes(output.address)) {
154
+ if (!changeAddresses.includes(output.address)) {
155
+ // The output isn't a change output of this account
156
+ recipients.push(
157
+ syncReplaceAddress
158
+ ? syncReplaceAddress(output.address)
159
+ : output.address
160
+ );
161
+ } else {
162
+ // The output is a change output of this account,
163
+ // we count it as a recipient only in some special cases
139
164
  if (
140
165
  (recipients.length === 0 &&
141
- output.output_hash ===
142
- tx.outputs[tx.outputs.length - 1].output_hash) ||
166
+ output.output_index >= changeOutputIndex) ||
143
167
  hasSpentNothing
144
168
  ) {
145
169
  recipients.push(
@@ -148,19 +172,7 @@ const mapTxToOperations = (
148
172
  : output.address
149
173
  );
150
174
  }
151
- } else {
152
- recipients.push(
153
- syncReplaceAddress
154
- ? syncReplaceAddress(output.address)
155
- : output.address
156
- );
157
175
  }
158
- } else {
159
- recipients.push(
160
- syncReplaceAddress
161
- ? syncReplaceAddress(output.address)
162
- : output.address
163
- );
164
176
  }
165
177
  }
166
178
  }
@@ -79,7 +79,7 @@ export function isChangeOutput(output: BitcoinOutput): boolean {
79
79
  type UTXOStatus =
80
80
  | {
81
81
  excluded: true;
82
- reason: "pickUnconfirmedRBF" | "userExclusion";
82
+ reason: "pickUnconfirmedRBF" | "pickPendingNonRBF" | "userExclusion";
83
83
  }
84
84
  | {
85
85
  excluded: false;
@@ -94,7 +94,12 @@ export const getUTXOStatus = (
94
94
  reason: "pickUnconfirmedRBF",
95
95
  };
96
96
  }
97
-
97
+ if (!utxo.rbf && !utxo.blockHeight) {
98
+ return {
99
+ excluded: true,
100
+ reason: "pickPendingNonRBF",
101
+ };
102
+ }
98
103
  if (
99
104
  utxoStrategy.excludeUTXOs.some(
100
105
  (u) => u.hash === utxo.hash && u.outputIndex === utxo.outputIndex
@@ -254,7 +254,12 @@ const bitcoinLikeMutations = ({
254
254
  },
255
255
  recoverBadTransactionStatus,
256
256
  test: ({ account }) => {
257
- expect(account.balance.toString()).toBe("0");
257
+ expect(
258
+ account.bitcoinResources?.utxos
259
+ .filter((u) => u.blockHeight) // Exclude pending UTXOs
260
+ .reduce((p, c) => p.plus(c.value), new BigNumber(0))
261
+ .toString()
262
+ ).toBe("0");
258
263
  },
259
264
  },
260
265
  ];
@@ -1,7 +1,7 @@
1
1
  import type { DatasetTest } from "../../types";
2
2
  import type { Transaction } from "./types";
3
3
  import bitcoin_cash from "./datasets/bitcoin_cash";
4
- import bitcoin_gold from "./datasets/bitcoin_gold";
4
+ // import bitcoin_gold from "./datasets/bitcoin_gold";
5
5
  import bitcoin from "./datasets/bitcoin";
6
6
  import dash from "./datasets/dash";
7
7
  // import decred from "./datasets/decred";
@@ -22,7 +22,7 @@ const dataset: DatasetTest<Transaction> = {
22
22
  currencies: {
23
23
  bitcoin,
24
24
  bitcoin_cash,
25
- bitcoin_gold,
25
+ // bitcoin_gold,
26
26
  dash,
27
27
  // decred, // BACK-2443
28
28
  digibyte,
@@ -150,6 +150,7 @@ class Base implements ICrypto {
150
150
  );
151
151
  }
152
152
 
153
+ // eslint-disable-next-line
153
154
  isTaprootAddress(address: string): boolean {
154
155
  return false;
155
156
  }
@@ -71,7 +71,7 @@ class BitcoinCash implements ICrypto {
71
71
  return bchaddr.isValidAddress(address);
72
72
  }
73
73
 
74
- // eslint-disable-next-line class-methods-use-this
74
+ // eslint-disable-next-line
75
75
  isTaprootAddress(address: string): boolean {
76
76
  return false;
77
77
  }
@@ -75,7 +75,7 @@ class ZCash implements ICrypto {
75
75
  return zec.Address.isValid(address, "livenet");
76
76
  }
77
77
 
78
- // eslint-disable-next-line class-methods-use-this
78
+ // eslint-disable-next-line
79
79
  isTaprootAddress(address: string): boolean {
80
80
  return false;
81
81
  }
@@ -103,7 +103,7 @@ class Zen implements ICrypto {
103
103
  );
104
104
  }
105
105
 
106
- // eslint-disable-next-line class-methods-use-this
106
+ // eslint-disable-next-line
107
107
  isTaprootAddress(address: string): boolean {
108
108
  return false;
109
109
  }
@@ -34,7 +34,7 @@ export class CoinSelect extends PickingStrategy {
34
34
  const TOTAL_TRIES = 100000;
35
35
  log("picking strategy", "utxos", unspentUtxos);
36
36
  // Compute cost of change
37
- const fixedSize = utils.estimateTxSize(
37
+ const fixedSize = utils.accurateTxSize(
38
38
  0,
39
39
  0,
40
40
  this.crypto,
@@ -42,10 +42,10 @@ export class CoinSelect extends PickingStrategy {
42
42
  );
43
43
  // Size of only 1 output (without fixed size)
44
44
  const oneOutputSize =
45
- utils.estimateTxSize(0, 1, this.crypto, this.derivationMode) - fixedSize;
45
+ utils.accurateTxSize(0, 1, this.crypto, this.derivationMode) - fixedSize;
46
46
  // Size 1 signed UTXO (signed input)
47
47
  const oneInputSize =
48
- utils.estimateTxSize(1, 0, this.crypto, this.derivationMode) - fixedSize;
48
+ utils.accurateTxSize(1, 0, this.crypto, this.derivationMode) - fixedSize;
49
49
 
50
50
  // Calculate effective value of outputs
51
51
  let currentAvailableValue = 0;
@@ -33,7 +33,7 @@ export class DeepFirst extends PickingStrategy {
33
33
 
34
34
  unspentUtxos = sortBy(unspentUtxos, "block_height");
35
35
  // https://metamug.com/article/security/bitcoin-transaction-fee-satoshi-per-byte.html
36
- const txSizeNoInput = utils.estimateTxSize(
36
+ const txSizeNoInput = utils.accurateTxSize(
37
37
  0,
38
38
  nbOutputsWithoutChange,
39
39
  this.crypto,
@@ -41,12 +41,12 @@ export class DeepFirst extends PickingStrategy {
41
41
  );
42
42
  let fee = txSizeNoInput * feePerByte;
43
43
  const sizePerInput =
44
- utils.estimateTxSize(1, 0, this.crypto, this.derivationMode) -
45
- utils.estimateTxSize(0, 0, this.crypto, this.derivationMode);
44
+ utils.accurateTxSize(1, 0, this.crypto, this.derivationMode) -
45
+ utils.accurateTxSize(0, 0, this.crypto, this.derivationMode);
46
46
 
47
47
  const sizePerOutput =
48
- utils.estimateTxSize(0, 1, this.crypto, this.derivationMode) -
49
- utils.estimateTxSize(0, 0, this.crypto, this.derivationMode);
48
+ utils.accurateTxSize(0, 1, this.crypto, this.derivationMode) -
49
+ utils.accurateTxSize(0, 0, this.crypto, this.derivationMode);
50
50
 
51
51
  let total = new BigNumber(0);
52
52
  const unspentUtxoSelected: Output[] = [];
@@ -32,16 +32,16 @@ export class Merge extends PickingStrategy {
32
32
  );
33
33
 
34
34
  const sizePerInput =
35
- utils.estimateTxSize(1, 0, this.crypto, this.derivationMode) -
36
- utils.estimateTxSize(0, 0, this.crypto, this.derivationMode);
35
+ utils.accurateTxSize(1, 0, this.crypto, this.derivationMode) -
36
+ utils.accurateTxSize(0, 0, this.crypto, this.derivationMode);
37
37
 
38
38
  const sizePerOutput =
39
- utils.estimateTxSize(0, 1, this.crypto, this.derivationMode) -
40
- utils.estimateTxSize(0, 0, this.crypto, this.derivationMode);
39
+ utils.accurateTxSize(0, 1, this.crypto, this.derivationMode) -
40
+ utils.accurateTxSize(0, 0, this.crypto, this.derivationMode);
41
41
 
42
42
  unspentUtxos = sortBy(unspentUtxos, (utxo) => parseInt(utxo.value, 10));
43
43
  // https://metamug.com/article/security/bitcoin-transaction-fee-satoshi-per-byte.html
44
- const txSizeNoInput = utils.estimateTxSize(
44
+ const txSizeNoInput = utils.accurateTxSize(
45
45
  0,
46
46
  nbOutputsWithoutChange,
47
47
  this.crypto,
@@ -83,16 +83,16 @@ export function byteSize(count: number) {
83
83
  return 1;
84
84
  }
85
85
  if (count <= 0xffff) {
86
- return 2;
86
+ return 3;
87
87
  }
88
88
  if (count <= 0xffffffff) {
89
- return 4;
89
+ return 5;
90
90
  }
91
- return 8;
91
+ return 9;
92
92
  }
93
93
 
94
94
  // refer to https://github.com/LedgerHQ/lib-ledger-core/blob/fc9d762b83fc2b269d072b662065747a64ab2816/core/src/wallet/bitcoin/api_impl/BitcoinLikeTransactionApi.cpp#L217
95
- export function estimateTxSize(
95
+ export function accurateTxSize(
96
96
  inputCount: number,
97
97
  outputCount: number,
98
98
  currency: ICrypto,
@@ -106,11 +106,15 @@ export function estimateTxSize(
106
106
  fixedSize += byteSize(inputCount); // Number of inputs
107
107
  fixedSize += byteSize(outputCount); // Number of outputs
108
108
  fixedSize += 4; // Timelock
109
+ if (derivationMode !== DerivationModes.LEGACY) {
110
+ fixedSize += 0.5; // Segwit marker & segwit flag
111
+ }
109
112
  // refer to https://medium.com/coinmonks/on-bitcoin-transaction-sizes-part-2-9445373d17f4
110
113
  // and https://bitcoin.stackexchange.com/questions/96017/what-are-the-sizes-of-single-sig-and-2-of-3-multisig-taproot-inputs
114
+ // and https://bitcoinops.org/en/tools/calc-size/
111
115
  if (derivationMode === DerivationModes.TAPROOT) {
112
- txSize = fixedSize + 57.5 * inputCount + 43 * outputCount;
113
- return Math.ceil(txSize);
116
+ txSize = fixedSize + 57.75 * inputCount + 43 * outputCount;
117
+ return txSize;
114
118
  }
115
119
  const isSegwit =
116
120
  derivationMode === DerivationModes.NATIVE_SEGWIT ||
@@ -120,14 +124,25 @@ export function estimateTxSize(
120
124
  // P2SH: 32 PrevTxHash + 4 Index + 23 scriptPubKey + 4 sequence
121
125
  const isNativeSegwit = derivationMode === DerivationModes.NATIVE_SEGWIT;
122
126
  const inputSize = isNativeSegwit ? 41 : 63;
123
- const noWitness = fixedSize + inputSize * inputCount + 34 * outputCount;
127
+ const noWitness = fixedSize + inputSize * inputCount + 43 * outputCount; //43 is the biggest output(taproot output) size, we use the biggest one for safety
124
128
  // Include flag and marker size (one byte each)
125
129
  const witnessSize = noWitness + 108 * inputCount + 2;
126
130
  txSize = (noWitness * 3 + witnessSize) / 4;
127
131
  } else {
128
- txSize = fixedSize + 148 * inputCount + 34 * outputCount;
132
+ txSize = fixedSize + 148 * inputCount + 43 * outputCount;
129
133
  }
130
- return Math.ceil(txSize); // We don't allow floating value
134
+ return txSize;
135
+ }
136
+
137
+ export function estimateTxSize(
138
+ inputCount: number,
139
+ outputCount: number,
140
+ currency: ICrypto,
141
+ derivationMode: string
142
+ ) {
143
+ return Math.ceil(
144
+ accurateTxSize(inputCount, outputCount, currency, derivationMode)
145
+ ); // We don't allow floating value
131
146
  }
132
147
 
133
148
  // refer to https://github.com/LedgerHQ/lib-ledger-core/blob/fc9d762b83fc2b269d072b662065747a64ab2816/core/src/wallet/bitcoin/api_impl/BitcoinLikeTransactionApi.cpp#L253
@@ -133,6 +133,7 @@ class BitcoinLikeWallet {
133
133
  )
134
134
  );
135
135
  let balance = new BigNumber(0);
136
+ let availableUtxoCount = 0;
136
137
  log("btcwallet", "estimateAccountMaxSpendable utxos", utxos);
137
138
  utxos.forEach((utxo) => {
138
139
  if (
@@ -144,6 +145,7 @@ class BitcoinLikeWallet {
144
145
  ) {
145
146
  if ((pickUnconfirmedRBF && utxo.rbf) || utxo.block_height !== null) {
146
147
  balance = balance.plus(utxo.value);
148
+ availableUtxoCount += 1;
147
149
  }
148
150
  }
149
151
  });
@@ -151,7 +153,7 @@ class BitcoinLikeWallet {
151
153
  const fees =
152
154
  feePerByte *
153
155
  utils.estimateTxSize(
154
- utxos.length,
156
+ availableUtxoCount,
155
157
  1,
156
158
  account.xpub.crypto,
157
159
  account.xpub.derivationMode
@@ -263,7 +265,7 @@ class BitcoinLikeWallet {
263
265
  return [
264
266
  btc.splitTransaction(
265
267
  i.txHex,
266
- segwit,
268
+ true,
267
269
  false, // FIXME hasTimestamp needed for LL-7539
268
270
  hasExtraData,
269
271
  additionals