@bsv/wallet-toolbox 1.2.47 → 1.2.49

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.2.47",
3
+ "version": "1.2.49",
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",
package/src/Wallet.ts CHANGED
@@ -708,7 +708,8 @@ export class Wallet implements WalletInterface, ProtoWallet {
708
708
  sdk.validateOriginator(originator)
709
709
 
710
710
  const { auth, vargs } = this.validateAuthAndArgs(args, sdk.validateSignActionArgs)
711
- const r = await signAction(this, auth, vargs, args.options || {})
711
+ // createAction options are merged with undefined signAction options before validation...
712
+ const r = await signAction(this, auth, args)
712
713
 
713
714
  if (!vargs.isDelayed) throwIfAnyUnsuccessfulSignActions(r)
714
715
 
@@ -5,6 +5,7 @@ import {
5
5
  Beef,
6
6
  Transaction as BsvTransaction,
7
7
  SendWithResult,
8
+ SignActionArgs,
8
9
  SignActionOptions,
9
10
  SignActionResult,
10
11
  SignActionSpend,
@@ -13,6 +14,7 @@ import {
13
14
  import { asBsvSdkScript, PendingSignAction, ScriptTemplateBRC29, sdk, Wallet } from '../../index.client'
14
15
  import { processAction } from './createAction'
15
16
  import { ReviewActionResult } from '../../sdk/WalletStorage.interfaces'
17
+ import { validateSignActionArgs } from '../../sdk'
16
18
 
17
19
  export interface SignActionResultX extends SignActionResult {
18
20
  txid?: TXIDHexString
@@ -24,15 +26,14 @@ export interface SignActionResultX extends SignActionResult {
24
26
  export async function signAction(
25
27
  wallet: Wallet,
26
28
  auth: sdk.AuthId,
27
- vargs: sdk.ValidSignActionArgs,
28
- options: SignActionOptions
29
+ args: SignActionArgs
29
30
  ): Promise<SignActionResultX> {
30
- const prior = wallet.pendingSignActions[vargs.reference]
31
+ const prior = wallet.pendingSignActions[args.reference]
31
32
  if (!prior)
32
33
  throw new sdk.WERR_NOT_IMPLEMENTED('recovery of out-of-session signAction reference data is not yet implemented.')
33
34
  if (!prior.dcr.inputBeef) throw new sdk.WERR_INTERNAL('prior.dcr.inputBeef must be valid')
34
35
 
35
- mergePriorOptions(prior.args, vargs, options)
36
+ const vargs = mergePriorOptions(prior.args, args)
36
37
 
37
38
  prior.tx = await completeSignedTransaction(prior, vargs.spends, wallet)
38
39
 
@@ -111,9 +112,11 @@ export async function completeSignedTransaction(
111
112
  return prior.tx
112
113
  }
113
114
 
114
- function mergePriorOptions(caVargs: sdk.ValidCreateActionArgs, saVargs: sdk.ValidSignActionArgs, saOptions: SignActionOptions ) {
115
+ function mergePriorOptions(caVargs: sdk.ValidCreateActionArgs, saArgs: SignActionArgs) : sdk.ValidSignActionArgs {
116
+ const saOptions = saArgs.options ||= {}
115
117
  if (saOptions.acceptDelayedBroadcast === undefined) saOptions.acceptDelayedBroadcast = caVargs.options.acceptDelayedBroadcast
116
118
  if (saOptions.returnTXIDOnly === undefined) saOptions.returnTXIDOnly = caVargs.options.returnTXIDOnly
117
119
  if (saOptions.noSend === undefined) saOptions.noSend = caVargs.options.noSend
118
120
  if (saOptions.sendWith === undefined) saOptions.sendWith = caVargs.options.sendWith
121
+ return validateSignActionArgs(saArgs)
119
122
  }
@@ -40,7 +40,7 @@ describe('localWallet2 tests', () => {
40
40
 
41
41
  test('1 recover 1 sat outputs', async () => {
42
42
  const setup = await createSetup(chain, options)
43
- await recoverOneSatTestOutputs(setup)
43
+ await recoverOneSatTestOutputs(setup, 1)
44
44
  await setup.wallet.destroy()
45
45
  })
46
46
 
@@ -184,19 +184,24 @@ export async function createOneSatTestOutput(
184
184
  return car
185
185
  }
186
186
 
187
- export async function recoverOneSatTestOutputs(setup: LocalTestWalletSetup): Promise<void> {
187
+ export async function recoverOneSatTestOutputs(setup: LocalTestWalletSetup, testOptionsMode?: 1): Promise<void> {
188
188
  const outputs = await setup.wallet.listOutputs({
189
189
  basket: 'test-output',
190
190
  include: 'entire transactions',
191
191
  limit: 1000
192
192
  })
193
193
 
194
- if (outputs.outputs.length > 8) {
194
+ if (outputs.outputs.length > 0) {
195
195
  const args: CreateActionArgs = {
196
196
  inputBEEF: outputs.BEEF!,
197
197
  inputs: [],
198
198
  description: 'recover test output'
199
199
  }
200
+ if (testOptionsMode === 1) {
201
+ args.options = {
202
+ acceptDelayedBroadcast: false
203
+ }
204
+ }
200
205
  const p2pkh = new P2PKH()
201
206
  for (const o of outputs.outputs) {
202
207
  args.inputs!.push({