@bsv/wallet-toolbox 1.7.11 → 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/CHANGELOG.md +15 -0
- package/docs/client.md +213 -52
- package/docs/wallet.md +213 -52
- package/mobile/out/src/WalletPermissionsManager.d.ts +60 -0
- package/mobile/out/src/WalletPermissionsManager.d.ts.map +1 -1
- package/mobile/out/src/WalletPermissionsManager.js +200 -35
- package/mobile/out/src/WalletPermissionsManager.js.map +1 -1
- package/mobile/out/src/storage/methods/createAction.js +1 -1
- package/mobile/out/src/storage/methods/createAction.js.map +1 -1
- package/mobile/out/src/storage/methods/generateChange.d.ts +2 -1
- package/mobile/out/src/storage/methods/generateChange.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/generateChange.js +4 -2
- package/mobile/out/src/storage/methods/generateChange.js.map +1 -1
- package/mobile/package-lock.json +2 -2
- package/mobile/package.json +1 -1
- package/out/src/WalletPermissionsManager.d.ts +60 -0
- package/out/src/WalletPermissionsManager.d.ts.map +1 -1
- package/out/src/WalletPermissionsManager.js +200 -35
- package/out/src/WalletPermissionsManager.js.map +1 -1
- package/out/src/__tests/WalletPermissionsManager.fixtures.d.ts.map +1 -1
- package/out/src/__tests/WalletPermissionsManager.fixtures.js.map +1 -1
- package/out/src/__tests/WalletPermissionsManager.pmodules.test.d.ts +2 -0
- package/out/src/__tests/WalletPermissionsManager.pmodules.test.d.ts.map +1 -0
- package/out/src/__tests/WalletPermissionsManager.pmodules.test.js +624 -0
- package/out/src/__tests/WalletPermissionsManager.pmodules.test.js.map +1 -0
- package/out/src/__tests/WalletPermissionsManager.proxying.test.js.map +1 -1
- package/out/src/storage/methods/createAction.js +1 -1
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/methods/generateChange.d.ts +2 -1
- package/out/src/storage/methods/generateChange.d.ts.map +1 -1
- package/out/src/storage/methods/generateChange.js +4 -2
- package/out/src/storage/methods/generateChange.js.map +1 -1
- package/out/src/storage/remoting/StorageServer.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageServer.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/Wallet.ts +2 -2
- package/src/WalletLogger.ts +1 -1
- package/src/WalletPermissionsManager.ts +350 -42
- package/src/__tests/WalletPermissionsManager.fixtures.ts +1 -2
- package/src/__tests/WalletPermissionsManager.pmodules.test.ts +798 -0
- package/src/__tests/WalletPermissionsManager.proxying.test.ts +2 -2
- package/src/storage/methods/createAction.ts +1 -1
- package/src/storage/methods/generateChange.ts +7 -3
- package/src/storage/remoting/StorageServer.ts +0 -2
|
@@ -107,8 +107,8 @@ describe('WalletPermissionsManager - Regression & Integration with Underlying Wa
|
|
|
107
107
|
// but we also set them here in case it cross-references them. We'll keep it consistent (2 outputs with total 1000).
|
|
108
108
|
mockTx.outputs = [{ satoshis: 600 }, { satoshis: 400 }]
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
// Now override fromAtomicBEEF to return our mockTx:
|
|
111
|
+
;(MockedBSV_SDK.Transaction.fromAtomicBEEF as jest.Mock).mockReturnValue(mockTx)
|
|
112
112
|
|
|
113
113
|
// Attempt to create an action from a non-admin origin
|
|
114
114
|
await manager.createAction(
|
|
@@ -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
|
|
283
|
+
throw werr
|
|
280
284
|
}
|
|
281
285
|
|
|
282
286
|
/**
|
|
@@ -49,7 +49,6 @@ export class StorageServer {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
private setupRoutes(): void {
|
|
52
|
-
|
|
53
52
|
this.app.use(express.json({ limit: '30mb' }))
|
|
54
53
|
|
|
55
54
|
// This allows the API to be used everywhere when CORS is enforced
|
|
@@ -92,7 +91,6 @@ export class StorageServer {
|
|
|
92
91
|
|
|
93
92
|
// A single POST endpoint for JSON-RPC:
|
|
94
93
|
this.app.post('/', async (req: Request, res: Response) => {
|
|
95
|
-
|
|
96
94
|
let { jsonrpc, method, params, id } = req.body
|
|
97
95
|
|
|
98
96
|
// Basic JSON-RPC protocol checks:
|