@exodus/bitcoin-api 2.3.4 → 2.3.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/bitcoin-api",
3
- "version": "2.3.4",
3
+ "version": "2.3.6",
4
4
  "description": "Exodus bitcoin-api",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -20,12 +20,14 @@
20
20
  "dependencies": {
21
21
  "@exodus/asset-lib": "^3.7.2",
22
22
  "@exodus/basic-utils": "^2.0.1",
23
+ "@exodus/bip-schnorr": "0.6.6-fork-1",
23
24
  "@exodus/bip44-constants": "^195.0.0",
24
25
  "@exodus/bitcoinjs-lib": "6.0.2-beta.5",
25
26
  "@exodus/models": "^8.10.4",
26
27
  "@exodus/secp256k1": "4.0.2-exodus.0",
27
28
  "@exodus/simple-retry": "0.0.6",
28
29
  "@exodus/timer": "^1.0.0",
30
+ "@noble/secp256k1": "~1.5.3",
29
31
  "bech32": "^1.1.3",
30
32
  "coininfo": "5.1.0",
31
33
  "delay": "4.0.1",
@@ -36,11 +38,7 @@
36
38
  "url-join": "4.0.0"
37
39
  },
38
40
  "devDependencies": {
39
- "@exodus/asset-lib": "^3.7.1",
40
- "@exodus/bcash-meta": "^1.0.0",
41
- "@exodus/bip-schnorr": "0.6.6-fork-1",
42
- "@exodus/bitcoin-meta": "^1.0.1",
43
- "@noble/secp256k1": "~1.5.3"
41
+ "@exodus/bitcoin-meta": "^1.0.1"
44
42
  },
45
- "gitHead": "ae212da85b29d90a3656bcfa034608950f883df1"
43
+ "gitHead": "0ac89c74616ae95eee3c4628ea3babd98dd1495b"
46
44
  }
@@ -91,15 +91,19 @@ export const getSizeAndChangeScriptFactory = ({ bitcoinJsLib = defaultBitcoinjsL
91
91
  assert(assetName, 'assetName is required')
92
92
  assert(rawTx, 'rawTx is required')
93
93
  assert(typeof changeUtxoIndex === 'number', 'changeUtxoIndex must be a number')
94
+
94
95
  if (tx) {
95
- return { script: tx.outs?.[changeUtxoIndex]?.script.toString('hex'), size: tx.virtualSize }
96
+ return {
97
+ script: tx.outs?.[changeUtxoIndex]?.script,
98
+ size: tx.virtualSize,
99
+ }
96
100
  }
97
101
  // Trezor doesn't return tx!! we need to reparse it!
98
102
  const parsedTx = bitcoinJsLib.Transaction.fromBuffer(Buffer.from(rawTx, 'hex'))
99
103
  try {
100
104
  return {
101
105
  script: parsedTx.outs?.[changeUtxoIndex]?.script.toString('hex'),
102
- size: parsedTx.virtualSize(),
106
+ size: tx.virtualSize?.(),
103
107
  }
104
108
  } catch (e) {
105
109
  console.warn(
@@ -24,6 +24,16 @@ const canParseTx = (rawTxBuffer) => {
24
24
  }
25
25
  }
26
26
 
27
+ export const serializeTx = ({ tx }) => {
28
+ // for desktop compatibility
29
+ return {
30
+ virtualSize: tx.virtualSize?.(),
31
+ outs: tx.outs?.map((out) => ({
32
+ script: out.script.toString('hex'),
33
+ })),
34
+ }
35
+ }
36
+
27
37
  export const signTxFactory = ({ assetName, resolvePurpose, keys, coinInfo, network, ecc }) => {
28
38
  assert(assetName, 'assetName is required')
29
39
  assert(resolvePurpose, 'resolvePurpose is required')
@@ -134,6 +144,6 @@ export const signTxFactory = ({ assetName, resolvePurpose, keys, coinInfo, netwo
134
144
  const txId = tx.getId()
135
145
 
136
146
  // tx needs to be serializable for desktop RPC send => sign communication
137
- return { rawTx, txId, tx: { ...tx, virtualSize: tx.virtualSize?.() } }
147
+ return { rawTx, txId, tx: serializeTx({ tx }) }
138
148
  }
139
149
  }
@@ -1 +1 @@
1
- export { signTxFactory } from './default-create-tx'
1
+ export { signTxFactory, serializeTx } from './default-create-tx'
@@ -12,18 +12,12 @@ export function getUtxos({ accountState, asset }) {
12
12
  )
13
13
  }
14
14
 
15
- export function getConfirmedUtxos({ asset, utxos }) {
16
- assert(asset, 'asset is required')
15
+ export function getConfirmedUtxos({ utxos }) {
17
16
  assert(utxos, 'utxos is required')
18
- const currency = asset.currency
19
- return UtxoCollection.fromArray(
20
- utxos.toArray().filter(({ confirmations }) => confirmations > 0),
21
- { currency }
22
- )
17
+ return utxos.filter(({ confirmations }) => confirmations > 0)
23
18
  }
24
19
 
25
- export function getConfirmedOrRfbDisabledUtxos({ asset, utxos, allowUnconfirmedRbfEnabledUtxos }) {
26
- assert(asset, 'asset is required')
20
+ export function getConfirmedOrRfbDisabledUtxos({ utxos, allowUnconfirmedRbfEnabledUtxos }) {
27
21
  assert(utxos, 'utxos is required')
28
22
  assert(
29
23
  allowUnconfirmedRbfEnabledUtxos !== undefined,
@@ -32,11 +26,7 @@ export function getConfirmedOrRfbDisabledUtxos({ asset, utxos, allowUnconfirmedR
32
26
  if (allowUnconfirmedRbfEnabledUtxos) {
33
27
  return utxos
34
28
  }
35
- const currency = asset.currency
36
- return UtxoCollection.fromArray(
37
- utxos.toArray().filter((utxo) => utxo.confirmations > 0 || !utxo.rbfEnabled),
38
- { currency }
39
- )
29
+ return utxos.filter((utxo) => utxo.confirmations > 0 || !utxo.rbfEnabled)
40
30
  }
41
31
 
42
32
  export function getUsableUtxos({ asset, utxos, feeData, txSet }) {
@@ -58,8 +48,5 @@ export function getUsableUtxos({ asset, utxos, feeData, txSet }) {
58
48
  })
59
49
  return largeUnconfirmedTxs.size === 0
60
50
  ? utxos
61
- : UtxoCollection.fromArray(
62
- utxos.toArray().filter((utxo) => !largeUnconfirmedTxs.has(utxo.txId)),
63
- { currency: asset.currency }
64
- )
51
+ : utxos.filter((utxo) => !largeUnconfirmedTxs.has(utxo.txId))
65
52
  }