@exodus/bitcoin-api 2.6.8-hiro.0 → 2.6.8-hiro.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
package/src/account-state.js
CHANGED
|
@@ -533,16 +533,6 @@ export class BitcoinMonitorScanner {
|
|
|
533
533
|
// Keep new utxos when they intersect with the stored utxos.
|
|
534
534
|
utxoCol = utxoCol.union(currentStoredUtxos).difference(utxosToRemoveCol)
|
|
535
535
|
|
|
536
|
-
if (this.#ordinalsEnabled) {
|
|
537
|
-
// copy ordinalsChange over
|
|
538
|
-
utxoCol.toArray().forEach((utxo) => {
|
|
539
|
-
const storedUtxo = currentStoredUtxos
|
|
540
|
-
.toArray()
|
|
541
|
-
.find((u2) => u2.txid === utxos.txid && u2.vout === utxo.vout)
|
|
542
|
-
utxo.ordinalsChange = storedUtxo?.ordinalsChange
|
|
543
|
-
})
|
|
544
|
-
}
|
|
545
|
-
|
|
546
536
|
for (let tx of Object.values(unconfirmedTxsToCheck)) {
|
|
547
537
|
existingTxs.push({ ...tx, dropped: true }) // TODO: this will decrease the chain index, it shouldn't be an issue considering the gap limit
|
|
548
538
|
utxoCol = utxoCol.difference(utxoCol.getTxIdUtxos(tx.txId))
|
|
@@ -581,6 +571,7 @@ export class BitcoinMonitorScanner {
|
|
|
581
571
|
allUtxos: utxoCol,
|
|
582
572
|
ordinalsEnabled: this.#ordinalsEnabled,
|
|
583
573
|
ordinalAddress,
|
|
574
|
+
knownBalanceUtxoIds: accountState.knownBalanceUtxoIds,
|
|
584
575
|
})
|
|
585
576
|
: {}
|
|
586
577
|
|
|
@@ -642,6 +633,7 @@ export class BitcoinMonitorScanner {
|
|
|
642
633
|
allUtxos: txConfirmedUtxos,
|
|
643
634
|
ordinalsEnabled: this.#ordinalsEnabled,
|
|
644
635
|
ordinalAddress: await this.getOrdinalAddress({ walletAccount }),
|
|
636
|
+
knownBalanceUtxoIds: accountState.knownBalanceUtxoIds,
|
|
645
637
|
})
|
|
646
638
|
|
|
647
639
|
return {
|
package/src/tx-send/index.js
CHANGED
|
@@ -428,6 +428,8 @@ export const createAndBroadcastTXFactory = ({
|
|
|
428
428
|
|
|
429
429
|
const { script, size } = getSizeAndChangeScript({ assetName, tx, rawTx, changeUtxoIndex, txId })
|
|
430
430
|
|
|
431
|
+
// for ordinals, used to allow users spending change utxos even when unconfirmed and ordinals are unknown
|
|
432
|
+
const knownBalanceUtxoIds = accountState.knownBalanceUtxoIds || []
|
|
431
433
|
let remainingUtxos = usableUtxos.difference(selectedUtxos)
|
|
432
434
|
if (changeUtxoIndex !== -1) {
|
|
433
435
|
const address = Address.create(ourAddress.address, ourAddress.meta)
|
|
@@ -439,8 +441,9 @@ export const createAndBroadcastTXFactory = ({
|
|
|
439
441
|
value: change,
|
|
440
442
|
confirmations: 0,
|
|
441
443
|
rbfEnabled,
|
|
442
|
-
ordinalsChange: ordinalsEnabled ? true : undefined,
|
|
443
444
|
}
|
|
445
|
+
|
|
446
|
+
knownBalanceUtxoIds.push(`${changeUtxo.txId}:${changeUtxo.vout}`.toLowerCase())
|
|
444
447
|
remainingUtxos = remainingUtxos.addUtxo(changeUtxo)
|
|
445
448
|
}
|
|
446
449
|
if (replaceTx) {
|
|
@@ -457,6 +460,7 @@ export const createAndBroadcastTXFactory = ({
|
|
|
457
460
|
newData: {
|
|
458
461
|
utxos: remainingUtxos,
|
|
459
462
|
ordinalsUtxos: remainingOrdinalsUtxos,
|
|
463
|
+
knownBalanceUtxoIds,
|
|
460
464
|
},
|
|
461
465
|
})
|
|
462
466
|
|
package/src/utxos-utils.js
CHANGED
|
@@ -69,12 +69,14 @@ export function getValidInscriptions({ utxo }) {
|
|
|
69
69
|
)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
function isOrdinalUtxo({ utxo, ordinalsEnabled }) {
|
|
72
|
+
function isOrdinalUtxo({ utxo, ordinalsEnabled, knownBalanceUtxoIds }) {
|
|
73
73
|
if (!ordinalsEnabled) {
|
|
74
74
|
return false
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
const utxoId = `${utxo.txId}:${utxo.vout}`.toLowerCase()
|
|
78
|
+
|
|
79
|
+
if (knownBalanceUtxoIds?.includes(utxoId) && !utxo.inscriptionsIndexed) {
|
|
78
80
|
return false // this allows users see and spend change balance after sending before hiro confirmation
|
|
79
81
|
}
|
|
80
82
|
|
|
@@ -86,13 +88,16 @@ function isOrdinalUtxo({ utxo, ordinalsEnabled }) {
|
|
|
86
88
|
return validInscriptions.length > 0
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
export function partitionUtxos({ allUtxos, ordinalsEnabled }) {
|
|
90
|
-
assert(allUtxos, 'allUtxos is required')
|
|
91
|
+
export function partitionUtxos({ allUtxos, ordinalsEnabled, knownBalanceUtxoIds }) {
|
|
91
92
|
assert(allUtxos, 'allUtxos is required')
|
|
92
93
|
// assert(ordinalAddress, 'ordinalAddress is required') // not used atm we may need to tune by ordinalAddress when unconfirmed or rubbish inscriptions
|
|
93
94
|
return {
|
|
94
|
-
utxos: allUtxos.filter(
|
|
95
|
-
|
|
95
|
+
utxos: allUtxos.filter(
|
|
96
|
+
(utxo) => !isOrdinalUtxo({ utxo, ordinalsEnabled, knownBalanceUtxoIds })
|
|
97
|
+
),
|
|
98
|
+
ordinalsUtxos: allUtxos.filter((utxo) =>
|
|
99
|
+
isOrdinalUtxo({ utxo, ordinalsEnabled, knownBalanceUtxoIds })
|
|
100
|
+
),
|
|
96
101
|
}
|
|
97
102
|
}
|
|
98
103
|
|