@exodus/bitcoin-api 2.12.0 → 2.12.1
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.12.
|
|
3
|
+
"version": "2.12.1",
|
|
4
4
|
"description": "Exodus bitcoin-api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"jest-when": "^3.5.1",
|
|
59
59
|
"safe-buffer": "^5.2.1"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "646b7124b8d80c3e37ac8735fb218061ef24b745"
|
|
62
62
|
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import assert from 'minimalistic-assert'
|
|
2
2
|
import { getUtxosData } from './utxo-selector'
|
|
3
3
|
import { findUnconfirmedSentRbfTxs } from '../tx-utils'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
getInscriptionIds,
|
|
6
|
+
getOrdinalsUtxos,
|
|
7
|
+
getTransferOrdinalsUtxos,
|
|
8
|
+
getUsableUtxos,
|
|
9
|
+
getUtxos,
|
|
10
|
+
} from '../utxos-utils'
|
|
5
11
|
import { canBumpTx } from './can-bump-tx'
|
|
6
12
|
import { getUnconfirmedTxAncestorMap } from '../unconfirmed-ancestor-data'
|
|
7
13
|
|
|
@@ -42,7 +48,7 @@ export class GetFeeResolver {
|
|
|
42
48
|
assert(!nft, 'nft must not be provided when brc20 is provided!!!')
|
|
43
49
|
}
|
|
44
50
|
|
|
45
|
-
const inscriptionIds =
|
|
51
|
+
const inscriptionIds = getInscriptionIds({ nft, brc20 })
|
|
46
52
|
|
|
47
53
|
const { resolvedFee, extraFee } = this.#getUtxosData({
|
|
48
54
|
asset,
|
|
@@ -100,6 +106,12 @@ export class GetFeeResolver {
|
|
|
100
106
|
const utxos = getUtxos({ accountState, asset })
|
|
101
107
|
const unconfirmedTxAncestor = getUnconfirmedTxAncestorMap({ accountState })
|
|
102
108
|
|
|
109
|
+
const ordinalsUtxos = getOrdinalsUtxos({ accountState, asset })
|
|
110
|
+
|
|
111
|
+
const transferOrdinalsUtxos = inscriptionIds
|
|
112
|
+
? getTransferOrdinalsUtxos({ inscriptionIds, ordinalsUtxos })
|
|
113
|
+
: undefined
|
|
114
|
+
|
|
103
115
|
const usableUtxos = getUsableUtxos({
|
|
104
116
|
asset,
|
|
105
117
|
utxos,
|
|
@@ -117,6 +129,7 @@ export class GetFeeResolver {
|
|
|
117
129
|
amount,
|
|
118
130
|
feeRate: feePerKB,
|
|
119
131
|
receiveAddress,
|
|
132
|
+
transferOrdinalsUtxos,
|
|
120
133
|
inscriptionIds,
|
|
121
134
|
isSendAll,
|
|
122
135
|
getFeeEstimator: this.#getFeeEstimator,
|
package/src/fee/utxo-selector.js
CHANGED
|
@@ -34,6 +34,7 @@ export const selectUtxos = ({
|
|
|
34
34
|
allowUnconfirmedRbfEnabledUtxos,
|
|
35
35
|
unconfirmedTxAncestor,
|
|
36
36
|
inscriptionIds, // for each inscription transfer, we need to calculate one more input and one more output
|
|
37
|
+
transferOrdinalsUtxos, // to calculate the size of the input
|
|
37
38
|
}) => {
|
|
38
39
|
const resolvedReceiveAddresses = getBestReceiveAddresses({
|
|
39
40
|
asset,
|
|
@@ -197,7 +198,9 @@ export const selectUtxos = ({
|
|
|
197
198
|
selectedUtxosValue = selectedUtxosValue.add(newUtxo.value)
|
|
198
199
|
}
|
|
199
200
|
|
|
200
|
-
let selectedUtxos = UtxoCollection.
|
|
201
|
+
let selectedUtxos = (transferOrdinalsUtxos || UtxoCollection.createEmpty({ currency })).union(
|
|
202
|
+
UtxoCollection.fromArray(selectedUtxosArray, { currency })
|
|
203
|
+
) // extremelly important, orden must be kept!!! ordinals utxos go first!!!
|
|
201
204
|
|
|
202
205
|
// start figuring out fees
|
|
203
206
|
const outputs =
|
|
@@ -240,6 +243,7 @@ export const getUtxosData = ({
|
|
|
240
243
|
mustSpendUtxos,
|
|
241
244
|
allowUnconfirmedRbfEnabledUtxos,
|
|
242
245
|
inscriptionIds,
|
|
246
|
+
transferOrdinalsUtxos,
|
|
243
247
|
unconfirmedTxAncestor,
|
|
244
248
|
utxosDescendingOrder,
|
|
245
249
|
}) => {
|
|
@@ -257,6 +261,7 @@ export const getUtxosData = ({
|
|
|
257
261
|
allowUnconfirmedRbfEnabledUtxos,
|
|
258
262
|
unconfirmedTxAncestor,
|
|
259
263
|
inscriptionIds,
|
|
264
|
+
transferOrdinalsUtxos,
|
|
260
265
|
utxosDescendingOrder,
|
|
261
266
|
})
|
|
262
267
|
|
package/src/tx-send/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from './dogecoin'
|
|
16
16
|
import { findUnconfirmedSentRbfTxs } from '../tx-utils'
|
|
17
17
|
import {
|
|
18
|
+
getInscriptionIds,
|
|
18
19
|
getOrdinalsUtxos,
|
|
19
20
|
getTransferOrdinalsUtxos,
|
|
20
21
|
getUsableUtxos,
|
|
@@ -258,7 +259,7 @@ export const getPrepareSendTransaction =
|
|
|
258
259
|
}
|
|
259
260
|
|
|
260
261
|
const amount = isToken ? asset.currency.ZERO : tokenAmount
|
|
261
|
-
const inscriptionIds =
|
|
262
|
+
const inscriptionIds = getInscriptionIds({ nft, brc20 })
|
|
262
263
|
|
|
263
264
|
assert(
|
|
264
265
|
ordinalsEnabled || !inscriptionIds,
|
|
@@ -351,6 +352,7 @@ export const getPrepareSendTransaction =
|
|
|
351
352
|
allowUnconfirmedRbfEnabledUtxos,
|
|
352
353
|
unconfirmedTxAncestor,
|
|
353
354
|
inscriptionIds,
|
|
355
|
+
transferOrdinalsUtxos,
|
|
354
356
|
utxosDescendingOrder,
|
|
355
357
|
})
|
|
356
358
|
|
|
@@ -365,10 +367,6 @@ export const getPrepareSendTransaction =
|
|
|
365
367
|
throw new Error(`Unable to bump ${bumpTxId}`)
|
|
366
368
|
}
|
|
367
369
|
|
|
368
|
-
if (transferOrdinalsUtxos) {
|
|
369
|
-
selectedUtxos = transferOrdinalsUtxos.union(selectedUtxos)
|
|
370
|
-
}
|
|
371
|
-
|
|
372
370
|
if (replaceTx) {
|
|
373
371
|
replaceTx = replaceTx.clone()
|
|
374
372
|
replaceTx = replaceTx.update({ data: { ...replaceTx.data } })
|
package/src/utxos-utils.js
CHANGED
|
@@ -9,6 +9,10 @@ export const getInscriptionTxId = (inscriptionId) => {
|
|
|
9
9
|
return inscriptionId.split('i')[0]
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export function getInscriptionIds({ nft, brc20 }) {
|
|
13
|
+
return nft?.tokenId ? [nft?.tokenId] : brc20 ? brc20.inscriptionIds : undefined
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
export function getTransferOrdinalsUtxos({ inscriptionIds, ordinalsUtxos }) {
|
|
13
17
|
const transferOrdinalsUtxos = ordinalsUtxos.filter((utxo) =>
|
|
14
18
|
utxo.inscriptions?.some((i) => inscriptionIds.includes(i.inscriptionId))
|