@exodus/bitcoin-api 2.8.0 → 2.8.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.8.
|
|
3
|
+
"version": "2.8.1",
|
|
4
4
|
"description": "Exodus bitcoin-api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@scure/btc-signer": "^1.1.0",
|
|
43
43
|
"jest-when": "^3.5.1"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "652eb821c1fe5b2bd561710d05fcb569d9f4a137"
|
|
46
46
|
}
|
package/src/account-state.js
CHANGED
|
@@ -590,12 +590,19 @@ export class BitcoinMonitorScanner {
|
|
|
590
590
|
})
|
|
591
591
|
|
|
592
592
|
const ordinalAddress = await this.getOrdinalAddress({ walletAccount })
|
|
593
|
+
|
|
594
|
+
// latest account state, in case knownBalanceUtxoIds or mustAvoidUtxoIds gets updated in on another promise
|
|
595
|
+
const latestAccountState = await assetClientInterface.getAccountState({
|
|
596
|
+
assetName,
|
|
597
|
+
walletAccount,
|
|
598
|
+
})
|
|
593
599
|
const utxosData = utxoCol
|
|
594
600
|
? partitionUtxos({
|
|
595
601
|
allUtxos: utxoCol,
|
|
596
602
|
ordinalsEnabled: this.#ordinalsEnabled,
|
|
597
603
|
ordinalAddress,
|
|
598
|
-
knownBalanceUtxoIds:
|
|
604
|
+
knownBalanceUtxoIds: latestAccountState.knownBalanceUtxoIds,
|
|
605
|
+
mustAvoidUtxoIds: latestAccountState.mustAvoidUtxoIds,
|
|
599
606
|
})
|
|
600
607
|
: {}
|
|
601
608
|
|
|
@@ -653,11 +660,20 @@ export class BitcoinMonitorScanner {
|
|
|
653
660
|
|
|
654
661
|
const txConfirmedUtxos = allStoredUtxos.updateConfirmations(confirmationsList)
|
|
655
662
|
|
|
663
|
+
const ordinalAddress = await this.getOrdinalAddress({ walletAccount })
|
|
664
|
+
|
|
665
|
+
// latest account state, in case knownBalanceUtxoIds or mustAvoidUtxoIds gets updated in on another promise
|
|
666
|
+
const latestAccountState = await aci.getAccountState({
|
|
667
|
+
assetName,
|
|
668
|
+
walletAccount,
|
|
669
|
+
})
|
|
670
|
+
|
|
656
671
|
const { utxos, ordinalsUtxos } = partitionUtxos({
|
|
657
672
|
allUtxos: txConfirmedUtxos,
|
|
658
673
|
ordinalsEnabled: this.#ordinalsEnabled,
|
|
659
|
-
ordinalAddress:
|
|
660
|
-
knownBalanceUtxoIds:
|
|
674
|
+
ordinalAddress: ordinalAddress,
|
|
675
|
+
knownBalanceUtxoIds: latestAccountState.knownBalanceUtxoIds,
|
|
676
|
+
mustAvoidUtxoIds: latestAccountState.mustAvoidUtxoIds,
|
|
661
677
|
})
|
|
662
678
|
|
|
663
679
|
return {
|
package/src/utxos-utils.js
CHANGED
|
@@ -83,13 +83,23 @@ export function getValidInscriptions({ utxo }) {
|
|
|
83
83
|
)
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
function isOrdinalUtxo({
|
|
86
|
+
function isOrdinalUtxo({
|
|
87
|
+
utxo,
|
|
88
|
+
ordinalsEnabled,
|
|
89
|
+
knownBalanceUtxoIds,
|
|
90
|
+
ordinalAddress,
|
|
91
|
+
mustAvoidUtxoIds,
|
|
92
|
+
}) {
|
|
87
93
|
if (!ordinalsEnabled) {
|
|
88
94
|
return false
|
|
89
95
|
}
|
|
90
96
|
|
|
91
97
|
const utxoId = `${utxo.txId}:${utxo.vout}`.toLowerCase()
|
|
92
98
|
|
|
99
|
+
if (mustAvoidUtxoIds && mustAvoidUtxoIds.includes(utxoId)) {
|
|
100
|
+
return true
|
|
101
|
+
}
|
|
102
|
+
|
|
93
103
|
if (knownBalanceUtxoIds?.includes(utxoId) && !utxo.inscriptionsIndexed) {
|
|
94
104
|
return false // this allows users see and spend change balance after sending before hiro confirmation
|
|
95
105
|
}
|
|
@@ -112,15 +122,34 @@ function isOrdinalUtxo({ utxo, ordinalsEnabled, knownBalanceUtxoIds, ordinalAddr
|
|
|
112
122
|
return hasOrdinals
|
|
113
123
|
}
|
|
114
124
|
|
|
115
|
-
export function partitionUtxos({
|
|
125
|
+
export function partitionUtxos({
|
|
126
|
+
allUtxos,
|
|
127
|
+
ordinalsEnabled,
|
|
128
|
+
knownBalanceUtxoIds,
|
|
129
|
+
ordinalAddress,
|
|
130
|
+
mustAvoidUtxoIds,
|
|
131
|
+
}) {
|
|
116
132
|
assert(allUtxos, 'allUtxos is required')
|
|
117
133
|
if (ordinalsEnabled) assert(ordinalAddress, 'ordinalAddress is required')
|
|
118
134
|
return {
|
|
119
135
|
utxos: allUtxos.filter(
|
|
120
|
-
(utxo) =>
|
|
136
|
+
(utxo) =>
|
|
137
|
+
!isOrdinalUtxo({
|
|
138
|
+
utxo,
|
|
139
|
+
ordinalsEnabled,
|
|
140
|
+
knownBalanceUtxoIds,
|
|
141
|
+
ordinalAddress,
|
|
142
|
+
mustAvoidUtxoIds,
|
|
143
|
+
})
|
|
121
144
|
),
|
|
122
145
|
ordinalsUtxos: allUtxos.filter((utxo) =>
|
|
123
|
-
isOrdinalUtxo({
|
|
146
|
+
isOrdinalUtxo({
|
|
147
|
+
utxo,
|
|
148
|
+
ordinalsEnabled,
|
|
149
|
+
knownBalanceUtxoIds,
|
|
150
|
+
ordinalAddress,
|
|
151
|
+
mustAvoidUtxoIds,
|
|
152
|
+
})
|
|
124
153
|
),
|
|
125
154
|
}
|
|
126
155
|
}
|