@exodus/bitcoin-api 2.3.8 → 2.3.10

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.8",
3
+ "version": "2.3.10",
4
4
  "description": "Exodus bitcoin-api",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -41,5 +41,5 @@
41
41
  "@exodus/bitcoin-meta": "^1.0.1",
42
42
  "jest-when": "^3.5.1"
43
43
  },
44
- "gitHead": "9e53c6305dd83860b2db0ea8bfc261c043d8509b"
44
+ "gitHead": "8d1b4e435fbb69abe1261aba737748d6443b759b"
45
45
  }
@@ -346,13 +346,15 @@ export class BitcoinMonitorScanner {
346
346
  ['bitcoin', 'bitcoinregtest', 'bitcointestnet'].includes(asset.name)
347
347
  ) {
348
348
  txLogItem.data.inputs = UtxoCollection.fromArray(
349
- txItem.vin.map((vin) => ({
350
- address: addrMap[vin.addr],
351
- script: asset.address.toScriptPubKey(vin.addr).toString('hex'),
352
- txId: vin.txid,
353
- vout: vin.vout,
354
- value: currency.defaultUnit(vin.value || 0),
355
- }))
349
+ txItem.vin
350
+ .filter((vin) => addrMap[vin.addr])
351
+ .map((vin) => ({
352
+ address: addrMap[vin.addr],
353
+ script: asset.address.toScriptPubKey(vin.addr).toString('hex'),
354
+ txId: vin.txid,
355
+ vout: vin.vout,
356
+ value: currency.defaultUnit(vin.value || 0),
357
+ }))
356
358
  ).toJSON()
357
359
  }
358
360
 
@@ -514,12 +516,12 @@ export class BitcoinMonitorScanner {
514
516
 
515
517
  const accountState = await aci.getAccountState({ assetName, walletAccount })
516
518
 
517
- const allStoredUtxos = getUtxos({ accountState, asset })
519
+ const storedUtxos = getUtxos({ accountState, asset })
518
520
 
519
521
  const currentTxs = Array.from(await aci.getTxLog({ assetName, walletAccount }))
520
522
 
521
523
  const unconfirmedTxIds = uniq([
522
- ...allStoredUtxos
524
+ ...storedUtxos
523
525
  .toArray()
524
526
  .filter((utxos) => !utxos.confirmations)
525
527
  .map((utxos) => utxos.txId),
@@ -549,12 +551,13 @@ export class BitcoinMonitorScanner {
549
551
  })
550
552
  .filter((tx) => Object.keys(tx).length > 1)
551
553
 
552
- const txConfirmedUtxos = confirmationsList.length
553
- ? allStoredUtxos.updateConfirmations(confirmationsList)
554
+ // Note about storedUtxos.clone(): updateConfirmations mutates the ordinal utxos, it's not possible to perform the equals below if not cloned
555
+ const updatedUtxos = confirmationsList.length
556
+ ? storedUtxos.clone().updateConfirmations(confirmationsList)
554
557
  : null
555
558
 
556
559
  return {
557
- utxos: txConfirmedUtxos,
560
+ utxos: !updatedUtxos || updatedUtxos.equals(storedUtxos) ? null : updatedUtxos,
558
561
  txsToUpdate: updatedPropertiesTxs,
559
562
  }
560
563
  }
@@ -81,7 +81,7 @@ export async function getNonWitnessTxs(asset, utxos, insightClient) {
81
81
  return rawTxs
82
82
  }
83
83
 
84
- export const getSizeAndChangeScriptFactory = ({ bitcoinJsLib = defaultBitcoinjsLib } = {}) => ({
84
+ export const getSizeAndChangeScriptFactory = ({ bitcoinjsLib = defaultBitcoinjsLib } = {}) => ({
85
85
  assetName,
86
86
  tx,
87
87
  rawTx,
@@ -99,11 +99,11 @@ export const getSizeAndChangeScriptFactory = ({ bitcoinJsLib = defaultBitcoinjsL
99
99
  }
100
100
  }
101
101
  // Trezor doesn't return tx!! we need to reparse it!
102
- const parsedTx = bitcoinJsLib.Transaction.fromBuffer(Buffer.from(rawTx, 'hex'))
102
+ const parsedTx = bitcoinjsLib.Transaction.fromBuffer(Buffer.from(rawTx, 'hex'))
103
103
  try {
104
104
  return {
105
105
  script: parsedTx.outs?.[changeUtxoIndex]?.script.toString('hex'),
106
- size: tx.virtualSize?.(),
106
+ size: parsedTx.virtualSize?.(),
107
107
  }
108
108
  } catch (e) {
109
109
  console.warn(