@bsv/wallet-toolbox 1.6.29 → 1.6.31
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 +9 -1
- package/mobile/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts.map +1 -1
- package/mobile/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js +13 -4
- package/mobile/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js.map +1 -1
- package/mobile/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/createAction.js +15 -1
- package/mobile/out/src/storage/methods/createAction.js.map +1 -1
- package/mobile/package-lock.json +2 -2
- package/mobile/package.json +1 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js +13 -4
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js.map +1 -1
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +15 -1
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -1
- package/out/src/storage/schema/KnexMigrations.js +12 -0
- package/out/src/storage/schema/KnexMigrations.js.map +1 -1
- package/out/test/storage/KnexMigrations.test.js +1 -1
- package/out/test/storage/KnexMigrations.test.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/services/chaintracker/chaintracks/util/ChaintracksFetch.ts +13 -4
- package/src/storage/methods/createAction.ts +18 -2
- package/src/storage/schema/KnexMigrations.ts +13 -0
- package/test/storage/KnexMigrations.test.ts +2 -1
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defaultHttpClient, HttpClient } from '@bsv/sdk'
|
|
2
2
|
import { ChaintracksFetchApi } from '../Api/ChaintracksFetchApi'
|
|
3
|
+
import { wait } from '../../../../utility/utilityHelpers'
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* This class implements the ChaintracksFetchApi
|
|
@@ -34,11 +35,19 @@ export class ChaintracksFetch implements ChaintracksFetchApi {
|
|
|
34
35
|
Accept: 'application/json'
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
let json: R
|
|
39
|
+
for (let retry = 0; ; retry++) {
|
|
40
|
+
const response = await fetch(url, requestJsonOptions)
|
|
41
|
+
if (!response.ok) {
|
|
42
|
+
if (response.statusText === 'Too Many Requests' && retry < 3) {
|
|
43
|
+
await wait(1000 * (retry + 1))
|
|
44
|
+
continue
|
|
45
|
+
}
|
|
46
|
+
throw new Error(`Failed to fetch JSON from ${url}: ${response.statusText}`)
|
|
47
|
+
}
|
|
48
|
+
json = (await response.json()) as R
|
|
49
|
+
break
|
|
40
50
|
}
|
|
41
|
-
const json = (await response.json()) as R
|
|
42
51
|
return json
|
|
43
52
|
}
|
|
44
53
|
|
|
@@ -8,8 +8,10 @@ import {
|
|
|
8
8
|
PubKeyHex,
|
|
9
9
|
PublicKey,
|
|
10
10
|
Random,
|
|
11
|
+
ReviewActionResult,
|
|
11
12
|
Script,
|
|
12
|
-
Utils
|
|
13
|
+
Utils,
|
|
14
|
+
WERR_REVIEW_ACTIONS
|
|
13
15
|
} from '@bsv/sdk'
|
|
14
16
|
import {
|
|
15
17
|
generateChangeSdk,
|
|
@@ -224,11 +226,25 @@ async function createNewInputs(
|
|
|
224
226
|
if (o) {
|
|
225
227
|
await storage.transaction(async trx => {
|
|
226
228
|
const o2 = verifyOne(await storage.findOutputs({ partial: { outputId: o.outputId }, trx }))
|
|
227
|
-
if (o2.
|
|
229
|
+
if (o2.spentBy !== undefined) {
|
|
230
|
+
const spendingTx = await storage.findTransactionById(verifyId(o2.spentBy), trx)
|
|
231
|
+
if (spendingTx && spendingTx.txid) {
|
|
232
|
+
const beef = await storage.getBeefForTransaction(spendingTx.txid, {})
|
|
233
|
+
const rar: ReviewActionResult = {
|
|
234
|
+
txid: '',
|
|
235
|
+
status: 'doubleSpend',
|
|
236
|
+
competingTxs: [spendingTx.txid!],
|
|
237
|
+
competingBeef: beef.toBinary()
|
|
238
|
+
}
|
|
239
|
+
throw new WERR_REVIEW_ACTIONS([rar], [])
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (o2.spendable != true) {
|
|
228
243
|
throw new WERR_INVALID_PARAMETER(
|
|
229
244
|
`inputs[${i.vin}]`,
|
|
230
245
|
`spendable output. output ${o.txid}:${o.vout} appears to have been spent.`
|
|
231
246
|
)
|
|
247
|
+
}
|
|
232
248
|
await storage.updateOutput(
|
|
233
249
|
o.outputId!,
|
|
234
250
|
{
|
|
@@ -73,6 +73,19 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
migrations['2025-10-18-002 add proven_tx_reqs txid index'] = {
|
|
77
|
+
async up(knex) {
|
|
78
|
+
await knex.schema.alterTable('proven_tx_reqs', table => {
|
|
79
|
+
table.index('txid')
|
|
80
|
+
})
|
|
81
|
+
},
|
|
82
|
+
async down(knex) {
|
|
83
|
+
await knex.schema.alterTable('proven_tx_reqs', table => {
|
|
84
|
+
table.dropIndex('txid')
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
76
89
|
migrations['2025-10-18-001 add transactions txid index'] = {
|
|
77
90
|
async up(knex) {
|
|
78
91
|
await knex.schema.alterTable('transactions', table => {
|
|
@@ -61,7 +61,8 @@ describe('KnexMigrations tests', () => {
|
|
|
61
61
|
const latest = await KnexMigrations.latestMigration()
|
|
62
62
|
await knex.migrate.latest(config)
|
|
63
63
|
const version = await knex.migrate.currentVersion(config)
|
|
64
|
-
|
|
64
|
+
|
|
65
|
+
expect(version).toBe(latest.split('_')[0])
|
|
65
66
|
}
|
|
66
67
|
done1 = true
|
|
67
68
|
})
|