@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.
- package/lib/account/addAccounts.d.ts.map +1 -1
- package/lib/account/addAccounts.js +1 -2
- package/lib/account/addAccounts.js.map +1 -1
- package/lib/account/support.d.ts.map +1 -1
- package/lib/account/support.js +1 -24
- package/lib/account/support.js.map +1 -1
- package/lib/api/explorerConfig/index.js +15 -15
- package/lib/apps/polyfill.d.ts.map +1 -1
- package/lib/apps/polyfill.js +5 -0
- package/lib/apps/polyfill.js.map +1 -1
- package/lib/bridge/jsHelpers.d.ts +1 -6
- package/lib/bridge/jsHelpers.d.ts.map +1 -1
- package/lib/bridge/jsHelpers.js +3 -11
- package/lib/bridge/jsHelpers.js.map +1 -1
- package/lib/env.js +2 -2
- package/lib/families/bitcoin/account.d.ts.map +1 -1
- package/lib/families/bitcoin/account.js +2 -3
- package/lib/families/bitcoin/account.js.map +1 -1
- package/lib/families/bitcoin/datasets/bitcoin.js +6 -6
- package/lib/families/bitcoin/datasets/bitcoin.js.map +1 -1
- package/lib/families/bitcoin/datasets/litecoin.js +3 -3
- package/lib/families/bitcoin/datasets/litecoin.js.map +1 -1
- package/lib/families/bitcoin/serialization.d.ts +2 -2
- package/lib/families/bitcoin/serialization.d.ts.map +1 -1
- package/lib/families/bitcoin/serialization.js +4 -8
- package/lib/families/bitcoin/serialization.js.map +1 -1
- package/lib/families/bitcoin/specs.d.ts.map +1 -1
- package/lib/families/bitcoin/specs.js +5 -8
- package/lib/families/bitcoin/specs.js.map +1 -1
- package/lib/families/bitcoin/speculos-deviceActions.js +2 -2
- package/lib/families/bitcoin/speculos-deviceActions.js.map +1 -1
- package/lib/families/bitcoin/test-dataset.js +1 -1
- package/lib/families/bitcoin/test-dataset.js.map +1 -1
- package/lib/families/bitcoin/transaction.d.ts +3 -3
- package/lib/families/bitcoin/transaction.d.ts.map +1 -1
- package/lib/families/bitcoin/transaction.js +61 -64
- package/lib/families/bitcoin/transaction.js.map +1 -1
- package/lib/families/bitcoin/types.d.ts +36 -66
- package/lib/families/bitcoin/types.d.ts.map +1 -1
- package/lib/families/bitcoin/types.js +1 -16
- package/lib/families/bitcoin/types.js.map +1 -1
- package/lib/families/crypto_org/logic.d.ts +1 -1
- package/lib/families/crypto_org/logic.js +7 -7
- package/lib/families/elrond/js-getTransactionStatus.d.ts.map +1 -1
- package/lib/families/elrond/js-getTransactionStatus.js +3 -0
- package/lib/families/elrond/js-getTransactionStatus.js.map +1 -1
- package/lib/families/elrond/js-signOperation.d.ts.map +1 -1
- package/lib/families/elrond/js-signOperation.js +10 -7
- package/lib/families/elrond/js-signOperation.js.map +1 -1
- package/lib/generated/bridge/js.d.ts +0 -4
- package/lib/generated/bridge/js.d.ts.map +1 -1
- package/lib/generated/bridge/js.js +18 -20
- package/lib/generated/bridge/js.js.map +1 -1
- package/lib/hw/actions/initSwap.js +2 -2
- package/lib/hw/actions/initSwap.js.map +1 -1
- package/lib/migrations/accounts-dataset.d.ts.map +1 -1
- package/lib/migrations/accounts-dataset.js +2 -4
- package/lib/migrations/accounts-dataset.js.map +1 -1
- package/lib/migrations/accounts.d.ts.map +1 -1
- package/lib/migrations/accounts.js +0 -17
- package/lib/migrations/accounts.js.map +1 -1
- package/lib/mock/account.d.ts.map +1 -1
- package/lib/mock/account.js +1 -2
- package/lib/mock/account.js.map +1 -1
- package/package.json +22 -22
- package/src/__tests__/__snapshots__/all.libcore.ts.snap +43 -6
- package/src/account/addAccounts.ts +1 -2
- package/src/account/support.ts +1 -24
- package/src/api/explorerConfig/index.ts +15 -15
- package/src/apps/polyfill.ts +5 -0
- package/src/bridge/jsHelpers.ts +2 -22
- package/src/env.ts +2 -2
- package/src/families/bitcoin/account.ts +1 -2
- package/src/families/bitcoin/datasets/bitcoin.ts +6 -6
- package/src/families/bitcoin/datasets/litecoin.ts +6 -6
- package/src/families/bitcoin/serialization.ts +0 -6
- package/src/families/bitcoin/specs.ts +2 -5
- package/src/families/bitcoin/speculos-deviceActions.ts +1 -1
- package/src/families/bitcoin/test-dataset.ts +1 -1
- package/src/families/bitcoin/transaction.ts +93 -98
- package/src/families/bitcoin/types.ts +37 -95
- package/src/families/crypto_org/logic.ts +6 -6
- package/src/families/elrond/js-getTransactionStatus.ts +5 -0
- package/src/families/elrond/js-signOperation.ts +1 -0
- package/src/generated/bridge/js.ts +0 -3
- package/src/hw/actions/initSwap.ts +2 -2
- package/src/migrations/accounts-dataset.ts +0 -3
- package/src/migrations/accounts.ts +0 -18
- package/src/mock/account.ts +0 -2
- package/lib/families/bitcoin/bridge/js.d.ts +0 -8
- package/lib/families/bitcoin/bridge/js.d.ts.map +0 -1
- package/lib/families/bitcoin/bridge/js.js +0 -149
- package/lib/families/bitcoin/bridge/js.js.map +0 -1
- package/lib/families/bitcoin/cache.d.ts +0 -28
- package/lib/families/bitcoin/cache.d.ts.map +0 -1
- package/lib/families/bitcoin/cache.js +0 -109
- package/lib/families/bitcoin/cache.js.map +0 -1
- package/lib/families/bitcoin/getAccountNetworkInfo.d.ts +0 -6
- package/lib/families/bitcoin/getAccountNetworkInfo.d.ts.map +0 -1
- package/lib/families/bitcoin/getAccountNetworkInfo.js +0 -124
- package/lib/families/bitcoin/getAccountNetworkInfo.js.map +0 -1
- package/lib/families/bitcoin/getAccountNetworkInfo.test.d.ts +0 -2
- package/lib/families/bitcoin/getAccountNetworkInfo.test.d.ts.map +0 -1
- package/lib/families/bitcoin/getAccountNetworkInfo.test.js +0 -71
- package/lib/families/bitcoin/getAccountNetworkInfo.test.js.map +0 -1
- package/lib/families/bitcoin/js-broadcast.d.ts +0 -11
- package/lib/families/bitcoin/js-broadcast.d.ts.map +0 -1
- package/lib/families/bitcoin/js-broadcast.js +0 -80
- package/lib/families/bitcoin/js-broadcast.js.map +0 -1
- package/lib/families/bitcoin/js-buildTransaction.d.ts +0 -5
- package/lib/families/bitcoin/js-buildTransaction.d.ts.map +0 -1
- package/lib/families/bitcoin/js-buildTransaction.js +0 -106
- package/lib/families/bitcoin/js-buildTransaction.js.map +0 -1
- package/lib/families/bitcoin/js-createTransaction.d.ts +0 -9
- package/lib/families/bitcoin/js-createTransaction.d.ts.map +0 -1
- package/lib/families/bitcoin/js-createTransaction.js +0 -27
- package/lib/families/bitcoin/js-createTransaction.js.map +0 -1
- package/lib/families/bitcoin/js-estimateMaxSpendable.d.ts +0 -15
- package/lib/families/bitcoin/js-estimateMaxSpendable.d.ts.map +0 -1
- package/lib/families/bitcoin/js-estimateMaxSpendable.js +0 -95
- package/lib/families/bitcoin/js-estimateMaxSpendable.js.map +0 -1
- package/lib/families/bitcoin/js-getFeesForTransaction.d.ts +0 -26
- package/lib/families/bitcoin/js-getFeesForTransaction.d.ts.map +0 -1
- package/lib/families/bitcoin/js-getFeesForTransaction.js +0 -100
- package/lib/families/bitcoin/js-getFeesForTransaction.js.map +0 -1
- package/lib/families/bitcoin/js-getTransactionStatus.d.ts +0 -5
- package/lib/families/bitcoin/js-getTransactionStatus.d.ts.map +0 -1
- package/lib/families/bitcoin/js-getTransactionStatus.js +0 -131
- package/lib/families/bitcoin/js-getTransactionStatus.js.map +0 -1
- package/lib/families/bitcoin/js-prepareTransaction.d.ts +0 -5
- package/lib/families/bitcoin/js-prepareTransaction.d.ts.map +0 -1
- package/lib/families/bitcoin/js-prepareTransaction.js +0 -80
- package/lib/families/bitcoin/js-prepareTransaction.js.map +0 -1
- package/lib/families/bitcoin/js-signOperation.d.ts +0 -10
- package/lib/families/bitcoin/js-signOperation.d.ts.map +0 -1
- package/lib/families/bitcoin/js-signOperation.js +0 -212
- package/lib/families/bitcoin/js-signOperation.js.map +0 -1
- package/lib/families/bitcoin/js-synchronisation.d.ts +0 -10
- package/lib/families/bitcoin/js-synchronisation.d.ts.map +0 -1
- package/lib/families/bitcoin/js-synchronisation.js +0 -411
- package/lib/families/bitcoin/js-synchronisation.js.map +0 -1
- package/lib/families/bitcoin/logic.d.ts +0 -34
- package/lib/families/bitcoin/logic.d.ts.map +0 -1
- package/lib/families/bitcoin/logic.js +0 -283
- package/lib/families/bitcoin/logic.js.map +0 -1
- package/lib/families/bitcoin/networks.d.ts +0 -3
- package/lib/families/bitcoin/networks.d.ts.map +0 -1
- package/lib/families/bitcoin/networks.js +0 -379
- package/lib/families/bitcoin/networks.js.map +0 -1
- package/lib/families/bitcoin/wallet.d.ts +0 -6
- package/lib/families/bitcoin/wallet.d.ts.map +0 -1
- package/lib/families/bitcoin/wallet.js +0 -66
- package/lib/families/bitcoin/wallet.js.map +0 -1
- package/src/families/bitcoin/bridge/js.ts +0 -76
- package/src/families/bitcoin/cache.ts +0 -76
- package/src/families/bitcoin/getAccountNetworkInfo.test.ts +0 -27
- package/src/families/bitcoin/getAccountNetworkInfo.ts +0 -61
- package/src/families/bitcoin/js-broadcast.ts +0 -30
- package/src/families/bitcoin/js-buildTransaction.ts +0 -57
- package/src/families/bitcoin/js-createTransaction.ts +0 -27
- package/src/families/bitcoin/js-estimateMaxSpendable.ts +0 -36
- package/src/families/bitcoin/js-getFeesForTransaction.ts +0 -59
- package/src/families/bitcoin/js-getTransactionStatus.ts +0 -118
- package/src/families/bitcoin/js-prepareTransaction.ts +0 -35
- package/src/families/bitcoin/js-signOperation.ts +0 -164
- package/src/families/bitcoin/js-synchronisation.ts +0 -362
- package/src/families/bitcoin/logic.ts +0 -243
- package/src/families/bitcoin/networks.ts +0 -360
- 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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
152
|
+
version: "v2",
|
|
153
153
|
},
|
|
154
154
|
},
|
|
155
155
|
stratis: {
|
|
156
156
|
id: "strat",
|
|
157
157
|
stable: {
|
|
158
158
|
base: "EXPLORER",
|
|
159
|
-
version: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
217
|
+
version: "v2",
|
|
218
218
|
},
|
|
219
219
|
experimental: {
|
|
220
220
|
base: "EXPLORER",
|
package/src/apps/polyfill.ts
CHANGED
|
@@ -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] || [];
|
package/src/bridge/jsHelpers.ts
CHANGED
|
@@ -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/
|
|
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-
|
|
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 "./
|
|
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:
|
|
54
|
-
// totalSpent:
|
|
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:
|
|
80
|
-
// totalSpent:
|
|
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:
|
|
106
|
-
// totalSpent:
|
|
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:
|
|
54
|
-
amount: new BigNumber("200000"), // totalSpent:
|
|
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:
|
|
77
|
-
amount: new BigNumber("147200"), // totalSpent:
|
|
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:
|
|
100
|
-
amount: new BigNumber("205273"), // totalSpent:
|
|
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
|
|
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 "./
|
|
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: ["
|
|
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,
|