@bsv/wallet-toolbox 2.1.26 → 2.1.28

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +8 -17
  3. package/docs/client.md +441 -181
  4. package/docs/monitor.md +69 -1
  5. package/docs/storage.md +107 -31
  6. package/docs/wallet.md +379 -142
  7. package/out/src/Wallet.d.ts +46 -2
  8. package/out/src/Wallet.d.ts.map +1 -1
  9. package/out/src/Wallet.js +65 -4
  10. package/out/src/Wallet.js.map +1 -1
  11. package/out/src/monitor/Monitor.d.ts.map +1 -1
  12. package/out/src/monitor/Monitor.js +12 -0
  13. package/out/src/monitor/Monitor.js.map +1 -1
  14. package/out/src/monitor/tasks/TaskCheckNoSends.d.ts +59 -1
  15. package/out/src/monitor/tasks/TaskCheckNoSends.d.ts.map +1 -1
  16. package/out/src/monitor/tasks/TaskCheckNoSends.js +93 -4
  17. package/out/src/monitor/tasks/TaskCheckNoSends.js.map +1 -1
  18. package/out/src/services/__tests/getFiatExchangeRate.test.js +25 -0
  19. package/out/src/services/__tests/getFiatExchangeRate.test.js.map +1 -1
  20. package/out/src/services/__tests/getMerklePath.test.js +8 -0
  21. package/out/src/services/__tests/getMerklePath.test.js.map +1 -1
  22. package/out/src/services/__tests/verifyBeef.test.js +37 -0
  23. package/out/src/services/__tests/verifyBeef.test.js.map +1 -1
  24. package/out/src/services/chaintracker/__tests/ChaintracksChainTracker.test.js +36 -0
  25. package/out/src/services/chaintracker/__tests/ChaintracksChainTracker.test.js.map +1 -1
  26. package/out/src/services/chaintracker/__tests/ChaintracksServiceClient.test.js +34 -0
  27. package/out/src/services/chaintracker/__tests/ChaintracksServiceClient.test.js.map +1 -1
  28. package/out/src/signer/methods/internalizeAction.d.ts +8 -1
  29. package/out/src/signer/methods/internalizeAction.d.ts.map +1 -1
  30. package/out/src/signer/methods/internalizeAction.js +8 -1
  31. package/out/src/signer/methods/internalizeAction.js.map +1 -1
  32. package/out/src/storage/StorageProvider.d.ts.map +1 -1
  33. package/out/src/storage/StorageProvider.js +80 -2
  34. package/out/src/storage/StorageProvider.js.map +1 -1
  35. package/out/src/storage/methods/ListActionsSpecOp.d.ts.map +1 -1
  36. package/out/src/storage/methods/ListActionsSpecOp.js +68 -5
  37. package/out/src/storage/methods/ListActionsSpecOp.js.map +1 -1
  38. package/out/src/storage/methods/createAction.js +27 -13
  39. package/out/src/storage/methods/createAction.js.map +1 -1
  40. package/out/src/storage/methods/internalizeAction.d.ts +69 -2
  41. package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
  42. package/out/src/storage/methods/internalizeAction.js +206 -26
  43. package/out/src/storage/methods/internalizeAction.js.map +1 -1
  44. package/out/src/storage/portable/index.d.ts.map +1 -1
  45. package/out/src/storage/portable/index.js +160 -114
  46. package/out/src/storage/portable/index.js.map +1 -1
  47. package/out/src/utility/identityUtils.d.ts +12 -6
  48. package/out/src/utility/identityUtils.d.ts.map +1 -1
  49. package/out/src/utility/identityUtils.js +78 -30
  50. package/out/src/utility/identityUtils.js.map +1 -1
  51. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -6,6 +6,23 @@ attention to changes that materially alter behavior or extend functionality.
6
6
 
7
7
  ## wallet-toolbox (unreleased)
8
8
 
9
+ - **Public API change**: `AbortActionResult.aborted` is now typed `boolean` (was the literal `true`). The wallet returns `aborted: false` when it positively confirms the underlying transaction is already on chain (mined or known to mempool) and the abort therefore should not proceed. Callers branching on `result.aborted` should treat `false` as "refused due to on-chain confirmation" and typically follow up with `internalizeAction`. Service-unreachable conditions return `aborted: true` (with an `abortAction-offline-fallback` history note) — refusal is reserved for positive on-chain confirmation, per BRC-100.
10
+
11
+ - Fix: close the nosend orphan-output failure mode. A `nosend` transaction (created via `createAction({noSend:true})`) could be externally broadcast and confirmed on chain before any `internalizeAction` or `Monitor.TaskCheckNoSends` cycle retired its `nosend` status. Before this change, two paths could then destroy the wallet's bookkeeping for the chain-confirmed tx: `StorageProvider.abortAction` unconditionally promoted `transactions.status` to `'failed'` and `proven_tx_reqs.status` to terminal `'invalid'`, hiding every output the tx produced (including the wallet's own auto-fund change) from the `listOutputsKnex` `txStatusAllowed` filter; and `specOpNoSendActions.postProcess` (bulk-abort path) blanket-set `tx.status = 'failed'` regardless of per-row outcome. Additionally `mergedInternalize` never advanced `transactions.status` or `proven_tx_reqs.status` out of `nosend`, so even a correctly-issued post-broadcast `internalizeAction` silently no-op'd on the lifecycle. Four fixes in defense-in-depth: (1) `mergedInternalize` retires the nosend lifecycle (transition to `unproven` + req `unmined`, or all the way to `completed` if the BEEF carries a BUMP); (2) `Monitor.processNewBlockHeader` now nudges `TaskCheckNoSends.checkNow` alongside the existing `TaskCheckForProofs.checkNow` nudge, wiring up the documented-but-orphaned per-block trigger; (3) `StorageProvider.abortAction` chain-checks signed `nosend` txs via `services.getStatusForTxids` and returns `aborted: false` for `mined` or `known` (mempool-aware) txs without throwing; (4) `specOpNoSendActions.postProcess` pre-filters chain-known rows before bulk-abort and honors per-row `aborted: false` returns so race-window rows that became chain-known mid-page leave their status as `nosend` rather than being blanket-set to `failed`. Service-unreachable handling proceeds with the abort and writes an `abortAction-offline-fallback` history note for forensic audit — abort must remain possible when network confirmation is impossible. One residual edge case (backend returns success+`unknown` for a tx that is actually on chain) is documented in the PR; mitigations include the per-block `TaskCheckNoSends` nudge eventually self-healing and caller-side multi-source chain verification.
12
+
13
+ - Optimization: `TaskCheckNoSends` aging schedule on the block-triggered `checkNow` path. The unfiltered per-block scan would do an unbounded number of external `getMerklePath` lookups per block as a wallet's `nosend` set grows (escrow, un-aborted tests, abandoned batches). The new schedule keys on row age: rows fresher than 5 min are skipped entirely (protecting in-flight batched-tx workflows that chain `createAction({noSend:true, sendWith:[...]})` builds); 5 min – 1 hr rows check on every trigger; older rows progress to `~hourly` (block-height % 6), `~daily` (% 144), and `~weekly` (% 1008) cadences. Each row's modulo offset is keyed by its `provenTxReqId` so same-tier rows are staggered across the cycle (`(blockHeight + provenTxReqId) % tierInterval === 0`) rather than all firing on the same block. The scheduled daily (no-`checkNow`) cadence is unchanged and still scans every row, providing a safety net for externally-broadcast unmined `nosend` txs regardless of age.
14
+
15
+ ## wallet-toolbox 2.1.27
16
+
17
+ - Add optional `contactSource` (and exported `ContactSource` / `ContactRecord` interfaces) on `WalletArgs` and the `Wallet` class. When provided, `Wallet.discoverByIdentityKey` consults the local contacts source **before** the in-process `_overlayCache` and before any network call; on a hit, the overlay is not queried at all. `Wallet.discoverByAttributes` consults the contact source's optional `findByAttributes` when present. Contact-source failures are swallowed and fall through to the existing network path so the network is never gated on a flaky contact store.
18
+ - `Wallet.discoverByIdentityKey` and `Wallet.discoverByAttributes` accept `forceRefresh?: boolean`. When `true`, both the contacts short-circuit and the 2-minute `_overlayCache` are bypassed so the network is consulted fresh — useful for a manual refresh action.
19
+ - `identityUtils.parseResults` now yields to the host runtime between certificates on UI runtimes (browser / React Native, detected at call time). On Node the yield is skipped to avoid timer overhead. Same total work; the JS thread no longer owns the frame for the duration of the loop, so menu taps and scroll keep working while a large identity result is parsed.
20
+ - `identityUtils.parseResults$` — new async-iterable form that emits each successfully parsed `VerifiableCertificate` as soon as it's ready, for callers that want progressive rendering.
21
+ - `queryOverlay` widens the per-call grace window for `ls_identity` queries to 300 ms via the new `LookupQueryOptions.graceMs`, so more in-sync identity hosts contribute outputs before the query resolves.
22
+ - `@bsv/sdk` dependency switched to the local workspace via `workspace:^2.1.1` so SDK changes flow through without an intermediate publish. Publish-time tooling rewrites `workspace:` ranges to concrete versions.
23
+
24
+ ## wallet-toolbox 2.1.26
25
+
9
26
  - Fix: auto-evict confirmed-stale inputs after any failed broadcast, regardless of how the broadcaster classifies the failure. When a tx is marked failed, `updateTransactionStatus(failed)` previously restored ALL consumed inputs to `spendable: true` to support transient retry. That's correct for fee/script/malformed failures where inputs are still UTXOs, but wrong for cases where the input has been spent on chain by a different tx — the wallet then picks the same already-spent UTXO on the next createAction → infinite missing-inputs broadcast loop. The new `markStaleInputsAsSpent` helper runs after `updateTransactionsStatus(failed)` and queries `services.isUtxo` per consumed input (concurrently across inputs via `Promise.all`), overriding `spendable: false` only for inputs the chain authoritatively confirms are spent. Inputs still on chain (transient/false-positive failures) keep the existing retry semantics. Service errors leave inputs untouched (eviction is opt-in based on positive evidence). Helper is broadcaster-agnostic — applies to ARC's `doubleSpend` (`SEEN_IN_ORPHAN_MEMPOOL`) and to WhatsOnChain/Bitails `invalidTx` (`missing-inputs`) classifications alike. Pre-broadcast races where concurrent createActions reach the same UTXO across separate app processes remain out of scope; that's a separate class of double-spend with its own design space (TaskReviewUtxos enqueue, locked-input semantics).
10
27
 
11
28
  ## wallet-toolbox 2.1.21
package/README.md CHANGED
@@ -1,19 +1,10 @@
1
1
  # BSV Wallet Toolbox
2
2
 
3
- [![Build Status](https://img.shields.io/github/actions/workflow/status/bsv-blockchain/wallet-toolbox/push.yaml?branch=master&label=build)](https://github.com/bsv-blockchain/wallet-toolbox/actions)
3
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/bsv-blockchain/ts-stack/ci.yml?branch=main&label=build)](https://github.com/bsv-blockchain/ts-stack/actions/workflows/ci.yml)
4
4
  [![npm version](https://img.shields.io/npm/v/@bsv/wallet-toolbox)](https://www.npmjs.com/package/@bsv/wallet-toolbox)
5
5
  [![npm downloads](https://img.shields.io/npm/dm/@bsv/wallet-toolbox)](https://www.npmjs.com/package/@bsv/wallet-toolbox)
6
- [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=bsv-blockchain_wallet-toolbox&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=bsv-blockchain_wallet-toolbox)
7
- [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=bsv-blockchain_wallet-toolbox&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=bsv-blockchain_wallet-toolbox)
8
- [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=bsv-blockchain_wallet-toolbox&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=bsv-blockchain_wallet-toolbox)
9
- [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=bsv-blockchain_wallet-toolbox&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=bsv-blockchain_wallet-toolbox)
10
- [![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=bsv-blockchain_wallet-toolbox&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=bsv-blockchain_wallet-toolbox)
11
- [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=bsv-blockchain_wallet-toolbox&metric=bugs)](https://sonarcloud.io/summary/new_code?id=bsv-blockchain_wallet-toolbox)
12
- [![CodeQL](https://github.com/bsv-blockchain/wallet-toolbox/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/bsv-blockchain/wallet-toolbox/actions/workflows/github-code-scanning/codeql)
13
- [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=bsv-blockchain_wallet-toolbox&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=bsv-blockchain_wallet-toolbox)
14
- [![License](https://img.shields.io/github/license/bsv-blockchain/wallet-toolbox)](./LICENSE.txt)
15
-
16
- A [BRC-100](https://github.com/bitcoin-sv/BRCs/blob/master/wallet/0100.md) conforming wallet implementation for the BSV blockchain, built on the [BSV SDK](https://bsv-blockchain.github.io/ts-sdk). Provides persistent storage, protocol-based key derivation, transaction monitoring, chain tracking, and signing — everything needed to build wallet-powered applications on BSV.
6
+
7
+ A [BRC-100](https://github.com/bitcoin-sv/BRCs/blob/master/wallet/0100.md) conforming wallet implementation for the BSV blockchain, built on the [BSV SDK](https://bsv-blockchain.github.io/ts-stack/packages/sdk/). Provides persistent storage, protocol-based key derivation, transaction monitoring, chain tracking, and signing — everything needed to build wallet-powered applications on BSV.
17
8
 
18
9
  ## Overview
19
10
 
@@ -89,11 +80,11 @@ The codebase has detailed JSDoc annotations throughout — these will surface in
89
80
  ## Development
90
81
 
91
82
  ```bash
92
- git clone https://github.com/bsv-blockchain/wallet-toolbox.git
93
- cd wallet-toolbox
94
- npm install
95
- npm run build
96
- npm test
83
+ git clone https://github.com/bsv-blockchain/ts-stack.git
84
+ cd ts-stack
85
+ pnpm install
86
+ pnpm --filter @bsv/wallet-toolbox run build
87
+ pnpm --filter @bsv/wallet-toolbox test
97
88
  ```
98
89
 
99
90
  Tests use Jest. Files named `*.man.test.ts` are manual/integration tests excluded from CI — they require network access or long runtimes and are run locally by developers.