@exodus/bitcoin-api 2.29.2 → 2.29.3
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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.29.3](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.29.2...@exodus/bitcoin-api@2.29.3) (2024-11-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* fix: track coinbase confirmation depth until maturity (#4522)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
6
16
|
## [2.29.2](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.29.1...@exodus/bitcoin-api@2.29.2) (2024-11-19)
|
|
7
17
|
|
|
8
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/bitcoin-api",
|
|
3
|
-
"version": "2.29.
|
|
3
|
+
"version": "2.29.3",
|
|
4
4
|
"description": "Exodus bitcoin-api",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"type": "git",
|
|
57
57
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "3d9da782c98f837d61fb67987dde5c2a009294bf"
|
|
60
60
|
}
|
|
@@ -14,6 +14,8 @@ const { compact, isEqual, uniq } = lodash
|
|
|
14
14
|
// Time to check whether to drop a sent tx
|
|
15
15
|
const SENT_TIME_TO_DROP = ms('2m')
|
|
16
16
|
|
|
17
|
+
const COINBASE_MATURITY_HEIGHT = 100
|
|
18
|
+
|
|
17
19
|
export class BitcoinMonitorScanner {
|
|
18
20
|
#asset
|
|
19
21
|
#insightClient
|
|
@@ -403,12 +405,18 @@ export class BitcoinMonitorScanner {
|
|
|
403
405
|
const existingTxs = []
|
|
404
406
|
|
|
405
407
|
allTxs.forEach((txItem) => {
|
|
408
|
+
const isCoinbase = txItem.vin.length === 0
|
|
409
|
+
|
|
406
410
|
const txLogItem = {
|
|
407
411
|
txId: txItem.txid,
|
|
408
412
|
coinAmount: currency.ZERO,
|
|
409
413
|
date: txItem.time ? new Date(txItem.time * 1000) : new Date(),
|
|
410
414
|
coinName: assetName,
|
|
411
|
-
confirmations: txItem.confirmations
|
|
415
|
+
confirmations: txItem.confirmations
|
|
416
|
+
? isCoinbase
|
|
417
|
+
? Math.min(COINBASE_MATURITY_HEIGHT + 1, txItem.confirmations)
|
|
418
|
+
: 1
|
|
419
|
+
: 0, // we don't care about a count - this should really be block height based if we want a count
|
|
412
420
|
addresses: [],
|
|
413
421
|
error: null,
|
|
414
422
|
dropped: false,
|
|
@@ -418,7 +426,7 @@ export class BitcoinMonitorScanner {
|
|
|
418
426
|
feePerKB: txItem.fees ? (txItem.fees / txItem.vsize) * 1000 * 1e8 : null,
|
|
419
427
|
rbfEnabled: txItem.rbf,
|
|
420
428
|
blocksSeen: 0,
|
|
421
|
-
...(
|
|
429
|
+
...(isCoinbase ? { isCoinbase: true } : undefined),
|
|
422
430
|
},
|
|
423
431
|
currencies: { [assetName]: currency },
|
|
424
432
|
}
|
|
@@ -546,7 +554,7 @@ export class BitcoinMonitorScanner {
|
|
|
546
554
|
value: val,
|
|
547
555
|
rbfEnabled: txItem.rbf,
|
|
548
556
|
derivationPath: address.meta.keyIdentifier?.derivationPath,
|
|
549
|
-
...(
|
|
557
|
+
...(isCoinbase ? { isCoinbase: true } : undefined),
|
|
550
558
|
}
|
|
551
559
|
|
|
552
560
|
if (this.#ordinalsEnabled) {
|
|
@@ -690,9 +698,20 @@ export class BitcoinMonitorScanner {
|
|
|
690
698
|
const unconfirmedTxIds = uniq([
|
|
691
699
|
...storedUtxos
|
|
692
700
|
.toArray()
|
|
693
|
-
.filter(
|
|
701
|
+
.filter(
|
|
702
|
+
(utxos) =>
|
|
703
|
+
!utxos.confirmations ||
|
|
704
|
+
(utxos.isCoinbase && utxos.confirmations < COINBASE_MATURITY_HEIGHT)
|
|
705
|
+
)
|
|
694
706
|
.map((utxos) => utxos.txId),
|
|
695
|
-
...currentTxs
|
|
707
|
+
...currentTxs
|
|
708
|
+
.filter(
|
|
709
|
+
(tx) =>
|
|
710
|
+
!tx.dropped &&
|
|
711
|
+
(!tx.confirmations ||
|
|
712
|
+
(tx.data.isCoinbase && tx.confirmations < COINBASE_MATURITY_HEIGHT))
|
|
713
|
+
)
|
|
714
|
+
.map((tx) => tx.txId),
|
|
696
715
|
])
|
|
697
716
|
|
|
698
717
|
const maybeConfirmationList = await Promise.all(
|
|
@@ -711,8 +730,8 @@ export class BitcoinMonitorScanner {
|
|
|
711
730
|
.map((tx) => {
|
|
712
731
|
const updatedProperties = {}
|
|
713
732
|
const confirmations = confirmationsList.find(({ txId }) => tx.txId === txId)?.confirmations
|
|
714
|
-
if (!tx.dropped && !tx.confirmations && confirmations > 0) {
|
|
715
|
-
updatedProperties.confirmations = confirmations
|
|
733
|
+
if (!tx.dropped && (!tx.confirmations || tx.data.isCoinbase) && confirmations > 0) {
|
|
734
|
+
updatedProperties.confirmations = Math.min(COINBASE_MATURITY_HEIGHT + 1, confirmations)
|
|
716
735
|
}
|
|
717
736
|
|
|
718
737
|
return { txId: tx.txId, ...updatedProperties }
|
|
@@ -230,6 +230,12 @@ export class Monitor extends BaseMonitor {
|
|
|
230
230
|
this.#runningByWalletAccount[walletAccount] = { refresh, promise }
|
|
231
231
|
try {
|
|
232
232
|
await promise
|
|
233
|
+
|
|
234
|
+
if (!refresh) {
|
|
235
|
+
try {
|
|
236
|
+
await this.onNewBlock()
|
|
237
|
+
} catch {}
|
|
238
|
+
}
|
|
233
239
|
} finally {
|
|
234
240
|
delete this.#runningByWalletAccount[walletAccount]
|
|
235
241
|
}
|