@exodus/bitcoin-api 2.7.6 → 2.7.7-taprootpatch
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 -3
- package/src/tx-log/bitcoin-monitor.js +6 -0
- package/src/utxos-utils.js +15 -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.7-taprootpatch",
|
|
4
4
|
"description": "Exodus bitcoin-api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -42,6 +42,5 @@
|
|
|
42
42
|
"@scure/base": "^1.1.3",
|
|
43
43
|
"@scure/btc-signer": "^1.1.0",
|
|
44
44
|
"jest-when": "^3.5.1"
|
|
45
|
-
}
|
|
46
|
-
"gitHead": "63ebb228622ae9643c57538d64c1d0d4c2f9c37d"
|
|
45
|
+
}
|
|
47
46
|
}
|
|
@@ -22,6 +22,7 @@ export class Monitor extends BaseMonitor {
|
|
|
22
22
|
#insightClient
|
|
23
23
|
#yieldToUI
|
|
24
24
|
#scanner
|
|
25
|
+
#webSocketEnabled
|
|
25
26
|
|
|
26
27
|
constructor({
|
|
27
28
|
asset,
|
|
@@ -34,6 +35,7 @@ export class Monitor extends BaseMonitor {
|
|
|
34
35
|
insightClient,
|
|
35
36
|
apiUrl,
|
|
36
37
|
scanner,
|
|
38
|
+
webSocketEnabled = true,
|
|
37
39
|
...extraScannerParams
|
|
38
40
|
}) {
|
|
39
41
|
super({ asset, interval, assetClientInterface, logger, runner })
|
|
@@ -44,6 +46,7 @@ export class Monitor extends BaseMonitor {
|
|
|
44
46
|
this.#ws = null
|
|
45
47
|
this.#apiUrl = apiUrl
|
|
46
48
|
this.#yieldToUI = yieldToUI
|
|
49
|
+
this.#webSocketEnabled = webSocketEnabled
|
|
47
50
|
this.#wsUrl = null
|
|
48
51
|
this.#runningByWalletAccount = Object.create(null)
|
|
49
52
|
this.#addressesByWalletAccount = Object.create(null)
|
|
@@ -95,6 +98,9 @@ export class Monitor extends BaseMonitor {
|
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
#connectWS = async (wsUrl) => {
|
|
101
|
+
if (!this.#webSocketEnabled) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
98
104
|
if (this.#ws) {
|
|
99
105
|
this.#ws.close()
|
|
100
106
|
this.#ws = null
|
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,27 @@ 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
|
+
// ordinalAddress is the taproot address
|
|
92
|
+
if (!hasOrdinals) {
|
|
93
|
+
console.log('Excluding utxo from btc spending:', utxo.address.toString(), utxo)
|
|
94
|
+
}
|
|
95
|
+
return true // assume is ordinal just in case
|
|
96
|
+
}
|
|
97
|
+
return hasOrdinals
|
|
89
98
|
}
|
|
90
99
|
|
|
91
|
-
export function partitionUtxos({ allUtxos, ordinalsEnabled, knownBalanceUtxoIds }) {
|
|
100
|
+
export function partitionUtxos({ allUtxos, ordinalsEnabled, knownBalanceUtxoIds, ordinalAddress }) {
|
|
92
101
|
assert(allUtxos, 'allUtxos is required')
|
|
93
|
-
|
|
102
|
+
if (ordinalsEnabled) assert(ordinalAddress, 'ordinalAddress is required') // not used atm we may need to tune by ordinalAddress when unconfirmed or rubbish inscriptions
|
|
94
103
|
return {
|
|
95
104
|
utxos: allUtxos.filter(
|
|
96
|
-
(utxo) => !isOrdinalUtxo({ utxo, ordinalsEnabled, knownBalanceUtxoIds })
|
|
105
|
+
(utxo) => !isOrdinalUtxo({ utxo, ordinalsEnabled, knownBalanceUtxoIds, ordinalAddress })
|
|
97
106
|
),
|
|
98
107
|
ordinalsUtxos: allUtxos.filter((utxo) =>
|
|
99
|
-
isOrdinalUtxo({ utxo, ordinalsEnabled, knownBalanceUtxoIds })
|
|
108
|
+
isOrdinalUtxo({ utxo, ordinalsEnabled, knownBalanceUtxoIds, ordinalAddress })
|
|
100
109
|
),
|
|
101
110
|
}
|
|
102
111
|
}
|