@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/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +2 -1
- package/out/src/Wallet.js.map +1 -1
- package/out/src/signer/methods/signAction.d.ts +2 -2
- package/out/src/signer/methods/signAction.d.ts.map +1 -1
- package/out/src/signer/methods/signAction.js +7 -4
- package/out/src/signer/methods/signAction.js.map +1 -1
- package/out/test/Wallet/local/localWallet2.man.test.js +1 -1
- package/out/test/Wallet/local/localWallet2.man.test.js.map +1 -1
- package/out/test/utils/localWalletMethods.d.ts +1 -1
- package/out/test/utils/localWalletMethods.d.ts.map +1 -1
- package/out/test/utils/localWalletMethods.js +7 -2
- package/out/test/utils/localWalletMethods.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/Wallet.ts +2 -1
- package/src/signer/methods/signAction.ts +8 -5
- package/test/Wallet/local/localWallet2.man.test.ts +1 -1
- package/test/utils/localWalletMethods.ts +7 -2
package/package.json
CHANGED
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
|
-
|
|
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
|
-
|
|
28
|
-
options: SignActionOptions
|
|
29
|
+
args: SignActionArgs
|
|
29
30
|
): Promise<SignActionResultX> {
|
|
30
|
-
const prior = wallet.pendingSignActions[
|
|
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,
|
|
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,
|
|
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 >
|
|
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({
|