@exodus/bitcoin-api 2.6.4 → 2.6.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.6.4",
3
+ "version": "2.6.6",
4
4
  "description": "Exodus bitcoin-api",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -22,13 +22,13 @@
22
22
  "@exodus/basic-utils": "^2.1.0",
23
23
  "@exodus/bip-schnorr": "0.6.6-fork-1",
24
24
  "@exodus/bip44-constants": "^195.0.0",
25
+ "@exodus/bitcoinjs-lib": "^6.1.5-exodus.0",
25
26
  "@exodus/models": "^11.0.0",
26
27
  "@exodus/secp256k1": "4.0.2-exodus.0",
27
28
  "@exodus/simple-retry": "0.0.6",
28
29
  "@exodus/timer": "^1.0.0",
29
30
  "@noble/secp256k1": "~1.7.1",
30
31
  "bech32": "^1.1.3",
31
- "bitcoinjs-lib": "^6.1.5",
32
32
  "coininfo": "5.1.0",
33
33
  "delay": "4.0.1",
34
34
  "ecpair": "2.0.1",
@@ -43,5 +43,5 @@
43
43
  "@scure/btc-signer": "^1.1.0",
44
44
  "jest-when": "^3.5.1"
45
45
  },
46
- "gitHead": "33c832c0c550fa4a885aee9b34f7649bfb5fa464"
46
+ "gitHead": "b2ed2bffe712facdd412df1a0ebc6a8ac92c4d1c"
47
47
  }
@@ -0,0 +1,9 @@
1
+ import ECPairFactory from 'ecpair'
2
+ import { eccFactory } from './ecc'
3
+
4
+ let ECPair
5
+
6
+ export const getECPair = () => {
7
+ ECPair = ECPair || ECPairFactory(eccFactory())
8
+ return ECPair
9
+ }
@@ -1,4 +1,4 @@
1
- import { initEccLib } from 'bitcoinjs-lib'
1
+ import { initEccLib } from '@exodus/bitcoinjs-lib'
2
2
  import { Point, schnorr, sign } from '@noble/secp256k1'
3
3
  import { common, toPubKey } from './common'
4
4
 
@@ -1,4 +1,4 @@
1
- import { initEccLib } from 'bitcoinjs-lib'
1
+ import { initEccLib } from '@exodus/bitcoinjs-lib'
2
2
  import secp256k1 from '@exodus/secp256k1'
3
3
  // TODO: temp import until '@noble/secp256k1' can be used
4
4
  import { isPoint } from 'tiny-secp256k1'
@@ -1,2 +1,3 @@
1
1
  export * from './ecc'
2
2
  export { scriptClassify } from './script-classify'
3
+ export * from './ec-pair'
@@ -1,4 +1,4 @@
1
- import { payments } from 'bitcoinjs-lib'
1
+ import { payments } from '@exodus/bitcoinjs-lib'
2
2
 
3
3
  function isPaymentFactory(payment) {
4
4
  return (script, eccLib) => {
@@ -2,7 +2,7 @@ import bs58check from 'bs58check'
2
2
  import * as bech32 from 'bech32'
3
3
  import assert from 'minimalistic-assert'
4
4
  import { identity, pickBy } from 'lodash'
5
- import * as bitcoinjsOriginal from 'bitcoinjs-lib'
5
+ import * as bitcoinjsOriginal from '@exodus/bitcoinjs-lib'
6
6
 
7
7
  export const createBtcLikeAddress = ({
8
8
  versions,
@@ -3,7 +3,7 @@ import wif from 'wif'
3
3
  import * as bech32 from 'bech32'
4
4
  import assert from 'minimalistic-assert'
5
5
  import { identity, pickBy } from 'lodash'
6
- import * as defaultBitcoinjsLib from 'bitcoinjs-lib'
6
+ import * as defaultBitcoinjsLib from '@exodus/bitcoinjs-lib'
7
7
  import secp256k1 from 'secp256k1'
8
8
  import { hash160 } from './hash-utils'
9
9
  import { toXOnly } from './bitcoinjs-lib/ecc-utils'
@@ -57,12 +57,11 @@ export default class InsightAPIClient {
57
57
  return !!peerStatus.connected
58
58
  }
59
59
 
60
- /*
61
- async fetchBalance (address) {
62
- const addrData = await this.fetchAddress(address)
63
- return (addrData.balanceSat + addrData.unconfirmedBalanceSat) | 0
60
+ async fetchBalance(address) {
61
+ const encodedAddress = encodeURIComponent(address)
62
+ const url = urlJoin(this._baseURL, `/balance/${encodedAddress}`)
63
+ return fetchJson(url)
64
64
  }
65
- */
66
65
 
67
66
  async fetchBlockHeight() {
68
67
  const url = urlJoin(this._baseURL, '/status')
@@ -2,7 +2,7 @@ import assert from 'minimalistic-assert'
2
2
  import BIPPath from 'bip32-path'
3
3
  import BN from 'bn.js'
4
4
  import lodash from 'lodash'
5
- import { Transaction as BitcoinTransactionClass } from 'bitcoinjs-lib'
5
+ import { Transaction as BitcoinTransactionClass } from '@exodus/bitcoinjs-lib'
6
6
 
7
7
  export const parseUnsignedTxFactory = ({ Transaction = BitcoinTransactionClass } = {}) => async ({
8
8
  asset,
@@ -505,8 +505,8 @@ export class BitcoinMonitorScanner {
505
505
  let utxoCol = UtxoCollection.fromArray(utxos, { currency })
506
506
 
507
507
  const utxosToRemoveCol = UtxoCollection.fromArray(utxosToRemove, { currency })
508
- // if something else can update currentStoredUtxos in the meantime, we probably need to grab it from state again
509
- utxoCol = currentStoredUtxos.union(utxoCol).difference(utxosToRemoveCol)
508
+ // Keep new utxos when they intersect with the stored utxos.
509
+ utxoCol = utxoCol.union(currentStoredUtxos).difference(utxosToRemoveCol)
510
510
 
511
511
  for (let tx of Object.values(unconfirmedTxsToCheck)) {
512
512
  existingTxs.push({ ...tx, dropped: true }) // TODO: this will decrease the chain index, it shouldn't be an issue considering the gap limit
@@ -16,7 +16,7 @@ import {
16
16
  import { findUnconfirmedSentRbfTxs } from '../tx-utils'
17
17
  import { getOrdinalsUtxos, getUsableUtxos, getUtxos } from '../utxos-utils'
18
18
 
19
- import * as defaultBitcoinjsLib from 'bitcoinjs-lib'
19
+ import * as defaultBitcoinjsLib from '@exodus/bitcoinjs-lib'
20
20
 
21
21
  const ASSETS_SUPPORTED_BIP_174 = [
22
22
  'bitcoin',
@@ -1,14 +1,13 @@
1
1
  import assert from 'minimalistic-assert'
2
2
  import lodash from 'lodash'
3
- import ECPairFactory from 'ecpair'
4
- import { payments, Psbt, Transaction } from 'bitcoinjs-lib'
3
+ import { payments, Psbt, Transaction } from '@exodus/bitcoinjs-lib'
5
4
  import { getOwnProperty } from '@exodus/basic-utils'
6
5
 
7
6
  import secp256k1 from 'secp256k1'
8
7
 
9
8
  import { toXOnly } from '../bitcoinjs-lib/ecc-utils'
10
9
  import { toAsyncSigner, tweakSigner } from './taproot'
11
- import { eccFactory } from '../bitcoinjs-lib/ecc'
10
+ import { getECPair } from '../bitcoinjs-lib'
12
11
 
13
12
  let ECPair
14
13
 
@@ -100,7 +99,7 @@ export const signTxFactory = ({ assetName, resolvePurpose, keys, coinInfo, netwo
100
99
  const { addressPathsMap } = unsignedTx.txMeta
101
100
  const networkInfo = { ...coinInfo.toBitcoinJS(), messagePrefix: '' }
102
101
 
103
- ECPair = ECPair || ECPairFactory(eccFactory())
102
+ ECPair = getECPair()
104
103
 
105
104
  const getKeyAndPurpose = lodash.memoize((address) => {
106
105
  const purpose = resolvePurpose(address)
@@ -1,4 +1,4 @@
1
- import { crypto } from 'bitcoinjs-lib'
1
+ import { crypto } from '@exodus/bitcoinjs-lib'
2
2
  import assert from 'minimalistic-assert'
3
3
  import { getSchnorrEntropy } from './default-entropy'
4
4
  import { toXOnly } from '../bitcoinjs-lib/ecc-utils'