@bsv/wallet-toolbox 1.7.12 → 1.7.13

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.12",
3
+ "version": "1.7.13",
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",
@@ -825,7 +825,7 @@ async function fundNewTransactionSdk(
825
825
  })
826
826
  }
827
827
 
828
- const gcr = await generateChangeSdk(params, allocateChangeInput, releaseChangeInput)
828
+ const gcr = await generateChangeSdk(params, allocateChangeInput, releaseChangeInput, vargs.logger)
829
829
 
830
830
  const nextRandomVal = (): number => {
831
831
  let val = 0
@@ -1,9 +1,10 @@
1
- import { Validation } from '@bsv/sdk'
1
+ import { Validation, WalletLoggerInterface } from '@bsv/sdk'
2
2
  import { WalletError } from '../../sdk/WalletError'
3
3
  import { StorageFeeModel } from '../../sdk/WalletStorage.interfaces'
4
4
  import { WERR_INSUFFICIENT_FUNDS, WERR_INTERNAL, WERR_INVALID_PARAMETER } from '../../sdk/WERR_errors'
5
5
  import { validateStorageFeeModel } from '../StorageProvider'
6
6
  import { transactionSize } from './utils'
7
+ import { Wallet, WalletLogger } from '../../index.client'
7
8
 
8
9
  /**
9
10
  * An output of this satoshis amount will be adjusted to the largest fundable amount.
@@ -38,7 +39,8 @@ export async function generateChangeSdk(
38
39
  targetSatoshis: number,
39
40
  exactSatoshis?: number
40
41
  ) => Promise<GenerateChangeSdkChangeInput | undefined>,
41
- releaseChangeInput: (outputId: number) => Promise<void>
42
+ releaseChangeInput: (outputId: number) => Promise<void>,
43
+ logger?: WalletLoggerInterface
42
44
  ): Promise<GenerateChangeSdkResult> {
43
45
  if (params.noLogging === false) logGenerateChangeSdkParams(params)
44
46
 
@@ -275,8 +277,10 @@ export async function generateChangeSdk(
275
277
  * Trigger an account funding event if we don't have enough to cover this transaction.
276
278
  */
277
279
  if (feeExcess() < 0) {
280
+ const werr = new WERR_INSUFFICIENT_FUNDS(spending() + feeTarget(), -feeExcessNow)
281
+ logger?.error(`throwing WERR_INSUFFICIENT_FUNDS moreSatoshisNeeded ${werr.moreSatoshisNeeded}`)
278
282
  await releaseAllocatedChangeInputs()
279
- throw new WERR_INSUFFICIENT_FUNDS(spending() + feeTarget(), -feeExcessNow)
283
+ throw werr
280
284
  }
281
285
 
282
286
  /**