@bsv/wallet-toolbox 1.7.0 → 1.7.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/wallet-toolbox",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "BRC100 conforming wallet, wallet storage and wallet signer components",
5
5
  "main": "./out/src/index.js",
6
6
  "types": "./out/src/index.d.ts",
@@ -390,6 +390,8 @@ export interface StorageGetBeefOptions {
390
390
  minProofLevel?: number
391
391
  /** optional. If valid, any merkleRoot that fails to validate will result in an exception without merging to `mergeToBeef`. */
392
392
  chainTracker?: ChainTracker
393
+ /** optional. Default is false. If chainTracker is valid and an invalid proof is found: if true, pursues deeper beef. If false, throws WERR_INVALID_MERKLE_ROOT. */
394
+ skipInvalidProofs?: boolean
393
395
  }
394
396
 
395
397
  export interface StorageSyncReaderOptions {
@@ -107,12 +107,18 @@ async function mergeBeefForTransactionRecurse(
107
107
  const root = mp.computeRoot()
108
108
  const isValid = await options.chainTracker.isValidRootForHeight(root, r.proven.height)
109
109
  if (!isValid) {
110
- throw new WERR_INVALID_MERKLE_ROOT(r.proven.blockHash, r.proven.height, root, txid)
110
+ if (!options.skipInvalidProofs) {
111
+ throw new WERR_INVALID_MERKLE_ROOT(r.proven.blockHash, r.proven.height, root, txid)
112
+ }
113
+ // ignore this currently invalid proof and try to recurse deeper
114
+ r.proven = undefined
111
115
  }
112
116
  }
113
- beef.mergeRawTx(r.proven.rawTx)
114
- beef.mergeBump(mp)
115
- return beef
117
+ if (r.proven) {
118
+ beef.mergeRawTx(r.proven.rawTx)
119
+ beef.mergeBump(mp)
120
+ return beef
121
+ }
116
122
  }
117
123
 
118
124
  if (!r.rawTx) throw new WERR_INVALID_PARAMETER(`txid ${txid}`, `valid transaction on chain ${storage.chain}`)