@bsv/wallet-toolbox 1.6.21 → 1.6.22

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.6.21",
3
+ "version": "1.6.22",
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",
@@ -5,7 +5,7 @@ import {
5
5
  StorageCreateTransactionSdkInput,
6
6
  StorageCreateTransactionSdkOutput
7
7
  } from '../../sdk/WalletStorage.interfaces'
8
- import { ValidCreateActionArgs, ValidCreateActionInput } from '../../sdk/validationHelpers'
8
+ import { validateSatoshis, ValidCreateActionArgs, ValidCreateActionInput } from '../../sdk/validationHelpers'
9
9
  import { WERR_INVALID_PARAMETER } from '../../sdk/WERR_errors'
10
10
  import { asBsvSdkScript, verifyTruthy } from '../../utility/utilityHelpers'
11
11
  import { KeyPair } from '../../sdk/types'
@@ -143,7 +143,7 @@ export function buildSignableTransaction(
143
143
  sequence: 0xffffffff
144
144
  }
145
145
  tx.addInput(inputToAdd)
146
- totalChangeInputs += verifyTruthy(storageInput.sourceSatoshis)
146
+ totalChangeInputs += validateSatoshis(storageInput.sourceSatoshis, 'storageInput.sourceSatoshis')
147
147
  }
148
148
  }
149
149
 
@@ -27,7 +27,7 @@ import {
27
27
  StorageGetBeefOptions,
28
28
  StorageProvidedBy
29
29
  } from '../../sdk/WalletStorage.interfaces'
30
- import { ValidCreateActionArgs, ValidCreateActionInput, ValidCreateActionOutput } from '../../sdk/validationHelpers'
30
+ import { ValidCreateActionArgs, ValidCreateActionInput, ValidCreateActionOutput, validateSatoshis } from '../../sdk/validationHelpers'
31
31
  import { WERR_INTERNAL, WERR_INVALID_PARAMETER } from '../../sdk/WERR_errors'
32
32
  import {
33
33
  randomBytesBase64,
@@ -417,7 +417,7 @@ async function createNewOutputs(
417
417
 
418
418
  const ro: StorageCreateTransactionSdkOutput = {
419
419
  vout: verifyInteger(o.vout),
420
- satoshis: verifyTruthy(o.satoshis),
420
+ satoshis: validateSatoshis(o.satoshis, 'o.satoshis'),
421
421
  lockingScript: !o.lockingScript ? '' : asString(o.lockingScript),
422
422
  providedBy: verifyTruthy(o.providedBy) as StorageProvidedBy,
423
423
  purpose: o.purpose || undefined,
@@ -630,7 +630,7 @@ async function validateRequiredInputs(
630
630
  if (!disableDoubleSpendCheckForTest && !output.spendable && !vargs.isNoSend)
631
631
  throw new WERR_INVALID_PARAMETER(`${txid}.${vout}`, 'spendable output unless noSend is true')
632
632
  // input is spending an existing user output which has an lockingScript
633
- input.satoshis = verifyNumber(output.satoshis)
633
+ input.satoshis = validateSatoshis(output.satoshis, 'output.satoshis')
634
634
  input.lockingScript = Script.fromBinary(asArray(output.lockingScript!))
635
635
  } else {
636
636
  let btx = beef.findTxid(txid)!
@@ -644,7 +644,7 @@ async function validateRequiredInputs(
644
644
  // btx is valid has parsed transaction data.
645
645
  if (vout >= btx.tx!.outputs.length) throw new WERR_INVALID_PARAMETER(`${txid}.${vout}`, 'valid outpoint')
646
646
  const so = btx.tx!.outputs[vout]
647
- input.satoshis = verifyTruthy(so.satoshis)
647
+ input.satoshis = validateSatoshis(so.satoshis, 'so.satoshis')
648
648
  input.lockingScript = so.lockingScript
649
649
  }
650
650
  }