@exodus/bitcoin-api 2.7.7 → 2.7.8
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 +2 -2
- package/src/utxos-utils.js +16 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/bitcoin-api",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.8",
|
|
4
4
|
"description": "Exodus bitcoin-api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"@scure/btc-signer": "^1.1.0",
|
|
44
44
|
"jest-when": "^3.5.1"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "bcd735ed4e9775e3436257966d80fc524c1fa312"
|
|
47
47
|
}
|
package/src/utxos-utils.js
CHANGED
|
@@ -69,7 +69,7 @@ export function getValidInscriptions({ utxo }) {
|
|
|
69
69
|
)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
function isOrdinalUtxo({ utxo, ordinalsEnabled, knownBalanceUtxoIds }) {
|
|
72
|
+
function isOrdinalUtxo({ utxo, ordinalsEnabled, knownBalanceUtxoIds, ordinalAddress }) {
|
|
73
73
|
if (!ordinalsEnabled) {
|
|
74
74
|
return false
|
|
75
75
|
}
|
|
@@ -85,18 +85,28 @@ function isOrdinalUtxo({ utxo, ordinalsEnabled, knownBalanceUtxoIds }) {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
const validInscriptions = getValidInscriptions({ utxo })
|
|
88
|
-
|
|
88
|
+
const hasOrdinals = validInscriptions.length > 0
|
|
89
|
+
|
|
90
|
+
if (ordinalAddress?.toString() === utxo.address.toString()) {
|
|
91
|
+
// if this condition is true, that means this is taproot
|
|
92
|
+
// so we always return true to ensure we accidentally don't spend an ordinal as btc
|
|
93
|
+
if (!hasOrdinals) {
|
|
94
|
+
console.log('Excluding utxo from btc spending:', utxo.address.toString(), utxo)
|
|
95
|
+
}
|
|
96
|
+
return true // assume is ordinal just in case
|
|
97
|
+
}
|
|
98
|
+
return hasOrdinals
|
|
89
99
|
}
|
|
90
100
|
|
|
91
|
-
export function partitionUtxos({ allUtxos, ordinalsEnabled, knownBalanceUtxoIds }) {
|
|
101
|
+
export function partitionUtxos({ allUtxos, ordinalsEnabled, knownBalanceUtxoIds, ordinalAddress }) {
|
|
92
102
|
assert(allUtxos, 'allUtxos is required')
|
|
93
|
-
|
|
103
|
+
if (ordinalsEnabled) assert(ordinalAddress, 'ordinalAddress is required') // not used atm we may need to tune by ordinalAddress when unconfirmed or rubbish inscriptions
|
|
94
104
|
return {
|
|
95
105
|
utxos: allUtxos.filter(
|
|
96
|
-
(utxo) => !isOrdinalUtxo({ utxo, ordinalsEnabled, knownBalanceUtxoIds })
|
|
106
|
+
(utxo) => !isOrdinalUtxo({ utxo, ordinalsEnabled, knownBalanceUtxoIds, ordinalAddress })
|
|
97
107
|
),
|
|
98
108
|
ordinalsUtxos: allUtxos.filter((utxo) =>
|
|
99
|
-
isOrdinalUtxo({ utxo, ordinalsEnabled, knownBalanceUtxoIds })
|
|
109
|
+
isOrdinalUtxo({ utxo, ordinalsEnabled, knownBalanceUtxoIds, ordinalAddress })
|
|
100
110
|
),
|
|
101
111
|
}
|
|
102
112
|
}
|