@exodus/bitcoin-plugin 1.16.4 → 1.17.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/bitcoin-plugin",
3
- "version": "1.16.4",
3
+ "version": "1.17.0",
4
4
  "description": "Exodus bitcoin-plugin",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -22,7 +22,7 @@
22
22
  "@exodus/basic-utils": "^2.1.0",
23
23
  "@exodus/bip32": "^1.1.2",
24
24
  "@exodus/bip44-constants": "^195.0.0",
25
- "@exodus/bitcoin-api": "^2.14.0",
25
+ "@exodus/bitcoin-api": "^2.15.0",
26
26
  "@exodus/bitcoin-lib": "^2.3.0",
27
27
  "@exodus/bitcoin-meta": "^1.0.2",
28
28
  "@exodus/bitcoinjs-lib": "^6.1.5-exodus.1",
@@ -31,6 +31,7 @@
31
31
  "@exodus/models": "^11.13.0",
32
32
  "@exodus/text-encoding-utf8": "^1.0.2",
33
33
  "@exodus/web3-bitcoin-utils": "^1.12.0",
34
+ "bip32-path": "0.4.2",
34
35
  "coininfo": "5.1.0",
35
36
  "create-hash": "^1.2.0",
36
37
  "lodash": "^4.17.21",
@@ -45,9 +46,14 @@
45
46
  "@exodus/bitcointestnet-meta": "^1.0.0",
46
47
  "@exodus/currency": "^2.3.2",
47
48
  "@exodus/hdkey": "^2.1.0-exodus.0",
49
+ "@exodus/key-identifier": "^1.1.1",
50
+ "@exodus/key-utils": "3.2.1",
51
+ "@exodus/keychain": "^6.4.0",
48
52
  "@exodus/nfts-proxy": "^2.10.1",
53
+ "@exodus/tx-signer": "^2.3.1",
49
54
  "@scure/btc-signer": "^1.1.0",
55
+ "bip39": "^2.6.0",
50
56
  "jest-when": "^3.5.1"
51
57
  },
52
- "gitHead": "b78e98b2a63dfce6b64b45869cba86fb36022a5e"
58
+ "gitHead": "364ffb79577938023d87e78e7d24a8e6413af060"
53
59
  }
@@ -106,6 +106,7 @@ export const createBitcoinAssetFactory =
106
106
  nfts: ordinalsEnabled,
107
107
  customTokens: brc20Enabled,
108
108
  isTestnet,
109
+ signWithSigner: true,
109
110
  }
110
111
 
111
112
  const getFeeEstimator = getFeeEstimatorFactory({
@@ -180,10 +181,18 @@ export const createBitcoinAssetFactory =
180
181
  coinInfo,
181
182
  })
182
183
 
184
+ const getKeyIdentifier = createGetKeyIdentifier({
185
+ bip44,
186
+ allowedPurposes,
187
+ allowedChainIndices: [0, 1, 2],
188
+ assetName: asset.name,
189
+ })
190
+
183
191
  const signTx = signTxFactory({
184
192
  assetName: asset.name,
185
193
  resolvePurpose: address.resolvePurpose,
186
194
  coinInfo,
195
+ getKeyIdentifier,
187
196
  })
188
197
 
189
198
  const signHardware = signHardwareFactory({
@@ -322,19 +331,17 @@ export const createBitcoinAssetFactory =
322
331
  getFeeData: () => feeData,
323
332
  getBalances,
324
333
  getBalanceForAddress,
325
- getKeyIdentifier: createGetKeyIdentifier({
326
- bip44,
327
- allowedPurposes,
328
- allowedChainIndices: [0, 1, 2],
329
- assetName: asset.name,
330
- }),
334
+ getKeyIdentifier,
331
335
  getSupportedPurposes: createGetSupportedPurposes({ omitPurposes: omitSupportedPurposes }),
332
336
  hasFeature: (feature) => !!features[feature], // @deprecated use api.features instead
333
337
  createAccountState: () => accountStateClass,
334
338
  parseUnsignedTx,
335
339
  signUnsignedTx: (unsignedTx, privateKey, opts) => signTx({ unsignedTx, privateKey, ...opts }), // legacy
336
340
  sendTx,
337
- signTx,
341
+ signTx: ({ unsignedTx, hdkeys, privateKeysAddressMap, signer }) =>
342
+ signer
343
+ ? signTx({ unsignedTx, signer })
344
+ : signTx({ unsignedTx, hdkeys, privateKeysAddressMap }),
338
345
  signHardware,
339
346
  signMessage,
340
347
  getFee,
@@ -2,6 +2,8 @@ import assert from 'minimalistic-assert'
2
2
  import { BumpType } from '@exodus/bitcoin-lib'
3
3
  import { brc20Utils } from './brc-20-utils'
4
4
  import { createBrc20Command } from './create-brc-20-command'
5
+ import { Address, UtxoCollection } from '@exodus/models'
6
+ import { getOrdinalsUtxos } from '@exodus/bitcoin-api'
5
7
 
6
8
  export const brc20BalancesAndFeeAdapterFactory = ({
7
9
  assetClientInterface,
@@ -26,13 +28,13 @@ export const brc20BalancesAndFeeAdapterFactory = ({
26
28
  const { isToken, getTokenBalance } = brc20Utils
27
29
 
28
30
  const isInscription = ({ options }) => {
29
- return !options.feeOpts.inscriptionIds?.length
31
+ return !options?.feeOpts?.inscriptionIds?.length
30
32
  }
31
33
 
32
34
  const sendBrc20 = async ({ asset: token, walletAccount, address, amount, options }) => {
33
35
  const { broadcastInscription, createBrc20Inscription } = inscriptionsService
34
36
 
35
- const { customFee, isSendAll } = options
37
+ const { customFee, isSendAll } = options || {}
36
38
 
37
39
  const asset = token.baseAsset
38
40
  const accountState = await assetClientInterface.getAccountState({
@@ -120,6 +122,7 @@ export const brc20BalancesAndFeeAdapterFactory = ({
120
122
 
121
123
  const newInscriptionFees = []
122
124
 
125
+ let index = 0
123
126
  for (const newInscription of newInscriptions) {
124
127
  const inscription = createBrc20Inscription({
125
128
  op: 'transfer',
@@ -136,12 +139,35 @@ export const brc20BalancesAndFeeAdapterFactory = ({
136
139
  feeData,
137
140
  })
138
141
  newInscriptionFees.push(newInscriptionFee)
139
- inscriptionIds.push(`new_inscription`) // this is just to count how many utxos needs to be send in the last txs
142
+ const inscriptionId = `new_inscription_${index++}`
143
+ newInscription.inscriptionId = inscriptionId
144
+ inscriptionIds.push(inscriptionId) // this is just to count how many utxos needs to be send in the last txs
140
145
  }
141
146
 
147
+ const ordinalsUtxos = getOrdinalsUtxos({ accountState, asset })
148
+
149
+ const mockedOrdinalsUtxos = ordinalsUtxos.union(
150
+ UtxoCollection.fromArray(
151
+ newInscriptions.map(({ address, inscriptionId }, index) => {
152
+ return {
153
+ address: Address.create(address),
154
+ txId: inscriptionId,
155
+ confirmations: 1,
156
+ value: '600 satoshis',
157
+ vout: 0,
158
+ script: '5120d96a4516786abc536ac4445887262770134f2ab139012856c1f3fdd13c1b02ac', // dummy taproot script
159
+ inscriptions: [{ inscriptionId, offset: 0 }],
160
+ }
161
+ }),
162
+ { currency: asset.currency }
163
+ )
164
+ )
142
165
  const { fee: lastSendingFee } = getFee({
143
166
  asset,
144
- accountState,
167
+ accountState: {
168
+ ...accountState,
169
+ ordinalsUtxos: mockedOrdinalsUtxos,
170
+ },
145
171
  txSet,
146
172
  feeData,
147
173
  amount: asset.currency.ZERO,