@bsv/wallet-toolbox 1.7.1 → 1.7.3
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 +11 -0
- package/docs/client.md +489 -1334
- package/docs/services.md +5 -5
- package/docs/storage.md +64 -61
- package/docs/wallet.md +489 -1334
- package/mobile/out/src/Wallet.d.ts +21 -4
- package/mobile/out/src/Wallet.d.ts.map +1 -1
- package/mobile/out/src/Wallet.js +93 -57
- package/mobile/out/src/Wallet.js.map +1 -1
- package/mobile/out/src/WalletLogger.d.ts +33 -0
- package/mobile/out/src/WalletLogger.d.ts.map +1 -0
- package/mobile/out/src/WalletLogger.js +157 -0
- package/mobile/out/src/WalletLogger.js.map +1 -0
- package/mobile/out/src/WalletPermissionsManager.d.ts.map +1 -1
- package/mobile/out/src/WalletPermissionsManager.js +1 -2
- package/mobile/out/src/WalletPermissionsManager.js.map +1 -1
- package/mobile/out/src/index.mobile.d.ts +1 -0
- package/mobile/out/src/index.mobile.d.ts.map +1 -1
- package/mobile/out/src/index.mobile.js +1 -0
- package/mobile/out/src/index.mobile.js.map +1 -1
- package/mobile/out/src/sdk/WERR_errors.d.ts.map +1 -1
- package/mobile/out/src/sdk/WERR_errors.js.map +1 -1
- package/mobile/out/src/sdk/WalletError.d.ts.map +1 -1
- package/mobile/out/src/sdk/WalletError.js +0 -2
- package/mobile/out/src/sdk/WalletError.js.map +1 -1
- package/mobile/out/src/sdk/WalletServices.interfaces.d.ts +3 -3
- package/mobile/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
- package/mobile/out/src/sdk/WalletStorage.interfaces.d.ts +9 -10
- package/mobile/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/mobile/out/src/sdk/index.d.ts +1 -1
- package/mobile/out/src/sdk/index.d.ts.map +1 -1
- package/mobile/out/src/sdk/index.js +3 -1
- package/mobile/out/src/sdk/index.js.map +1 -1
- package/mobile/out/src/services/Services.d.ts +5 -5
- package/mobile/out/src/services/Services.d.ts.map +1 -1
- package/mobile/out/src/services/Services.js +18 -4
- package/mobile/out/src/services/Services.js.map +1 -1
- package/mobile/out/src/services/providers/WhatsOnChain.d.ts.map +1 -1
- package/mobile/out/src/services/providers/WhatsOnChain.js +1 -2
- package/mobile/out/src/services/providers/WhatsOnChain.js.map +1 -1
- package/mobile/out/src/services/providers/getBeefForTxid.d.ts.map +1 -1
- package/mobile/out/src/services/providers/getBeefForTxid.js.map +1 -1
- package/mobile/out/src/signer/methods/acquireDirectCertificate.d.ts +2 -3
- package/mobile/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -1
- package/mobile/out/src/signer/methods/acquireDirectCertificate.js.map +1 -1
- package/mobile/out/src/signer/methods/buildSignableTransaction.d.ts +3 -4
- package/mobile/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
- package/mobile/out/src/signer/methods/buildSignableTransaction.js +1 -2
- package/mobile/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
- package/mobile/out/src/signer/methods/createAction.d.ts +3 -4
- package/mobile/out/src/signer/methods/createAction.d.ts.map +1 -1
- package/mobile/out/src/signer/methods/createAction.js +17 -6
- package/mobile/out/src/signer/methods/createAction.js.map +1 -1
- package/mobile/out/src/signer/methods/internalizeAction.d.ts.map +1 -1
- package/mobile/out/src/signer/methods/internalizeAction.js +1 -2
- package/mobile/out/src/signer/methods/internalizeAction.js.map +1 -1
- package/mobile/out/src/signer/methods/proveCertificate.d.ts +2 -3
- package/mobile/out/src/signer/methods/proveCertificate.d.ts.map +1 -1
- package/mobile/out/src/signer/methods/proveCertificate.js.map +1 -1
- package/mobile/out/src/signer/methods/signAction.d.ts.map +1 -1
- package/mobile/out/src/signer/methods/signAction.js +1 -2
- package/mobile/out/src/signer/methods/signAction.js.map +1 -1
- package/mobile/out/src/storage/StorageIdb.d.ts +3 -4
- package/mobile/out/src/storage/StorageIdb.d.ts.map +1 -1
- package/mobile/out/src/storage/StorageIdb.js.map +1 -1
- package/mobile/out/src/storage/StorageProvider.d.ts +6 -7
- package/mobile/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/mobile/out/src/storage/StorageProvider.js +5 -6
- package/mobile/out/src/storage/StorageProvider.js.map +1 -1
- package/mobile/out/src/storage/WalletStorageManager.d.ts +5 -5
- package/mobile/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/mobile/out/src/storage/WalletStorageManager.js +5 -4
- package/mobile/out/src/storage/WalletStorageManager.js.map +1 -1
- package/mobile/out/src/storage/methods/ListActionsSpecOp.d.ts +2 -2
- package/mobile/out/src/storage/methods/ListActionsSpecOp.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/ListActionsSpecOp.js.map +1 -1
- package/mobile/out/src/storage/methods/ListOutputsSpecOp.d.ts +4 -5
- package/mobile/out/src/storage/methods/ListOutputsSpecOp.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/ListOutputsSpecOp.js.map +1 -1
- package/mobile/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +2 -2
- package/mobile/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/attemptToPostReqsToNetwork.js +11 -7
- package/mobile/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
- package/mobile/out/src/storage/methods/createAction.d.ts +3 -4
- package/mobile/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/createAction.js +18 -5
- package/mobile/out/src/storage/methods/createAction.js.map +1 -1
- package/mobile/out/src/storage/methods/generateChange.js +10 -10
- package/mobile/out/src/storage/methods/generateChange.js.map +1 -1
- package/mobile/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/internalizeAction.js +1 -2
- package/mobile/out/src/storage/methods/internalizeAction.js.map +1 -1
- package/mobile/out/src/storage/methods/listActionsIdb.d.ts +2 -3
- package/mobile/out/src/storage/methods/listActionsIdb.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/listActionsIdb.js.map +1 -1
- package/mobile/out/src/storage/methods/listCertificates.d.ts +3 -3
- package/mobile/out/src/storage/methods/listCertificates.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/listCertificates.js.map +1 -1
- package/mobile/out/src/storage/methods/listOutputsIdb.d.ts +2 -3
- package/mobile/out/src/storage/methods/listOutputsIdb.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/listOutputsIdb.js.map +1 -1
- package/mobile/out/src/storage/methods/processAction.d.ts +2 -2
- package/mobile/out/src/storage/methods/processAction.d.ts.map +1 -1
- package/mobile/out/src/storage/methods/processAction.js +15 -10
- package/mobile/out/src/storage/methods/processAction.js.map +1 -1
- package/mobile/out/src/storage/remoting/StorageClient.d.ts +5 -6
- package/mobile/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
- package/mobile/out/src/storage/remoting/StorageClient.js +22 -0
- package/mobile/out/src/storage/remoting/StorageClient.js.map +1 -1
- package/mobile/out/src/storage/remoting/StorageMobile.d.ts +5 -6
- package/mobile/out/src/storage/remoting/StorageMobile.d.ts.map +1 -1
- package/mobile/out/src/storage/remoting/StorageMobile.js.map +1 -1
- package/mobile/package-lock.json +6 -6
- package/mobile/package.json +2 -2
- package/out/src/Wallet.d.ts +21 -4
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +93 -57
- package/out/src/Wallet.js.map +1 -1
- package/out/src/WalletLogger.d.ts +33 -0
- package/out/src/WalletLogger.d.ts.map +1 -0
- package/out/src/WalletLogger.js +157 -0
- package/out/src/WalletLogger.js.map +1 -0
- package/out/src/WalletPermissionsManager.d.ts.map +1 -1
- package/out/src/WalletPermissionsManager.js +1 -2
- package/out/src/WalletPermissionsManager.js.map +1 -1
- package/out/src/__tests/WalletPermissionsManager.fixtures.d.ts +1 -0
- package/out/src/__tests/WalletPermissionsManager.fixtures.d.ts.map +1 -1
- package/out/src/__tests/WalletPermissionsManager.fixtures.js +15 -4
- package/out/src/__tests/WalletPermissionsManager.fixtures.js.map +1 -1
- package/out/src/__tests/WalletPermissionsManager.proxying.test.js +79 -74
- package/out/src/__tests/WalletPermissionsManager.proxying.test.js.map +1 -1
- package/out/src/index.mobile.d.ts +1 -0
- package/out/src/index.mobile.d.ts.map +1 -1
- package/out/src/index.mobile.js +1 -0
- package/out/src/index.mobile.js.map +1 -1
- package/out/src/sdk/WERR_errors.d.ts.map +1 -1
- package/out/src/sdk/WERR_errors.js.map +1 -1
- package/out/src/sdk/WalletError.d.ts.map +1 -1
- package/out/src/sdk/WalletError.js +0 -2
- package/out/src/sdk/WalletError.js.map +1 -1
- package/out/src/sdk/WalletServices.interfaces.d.ts +3 -3
- package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts +9 -10
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/sdk/__test/validationHelpers.test.js +4 -4
- package/out/src/sdk/__test/validationHelpers.test.js.map +1 -1
- package/out/src/sdk/index.d.ts +1 -1
- package/out/src/sdk/index.d.ts.map +1 -1
- package/out/src/sdk/index.js +3 -1
- package/out/src/sdk/index.js.map +1 -1
- package/out/src/services/Services.d.ts +5 -5
- package/out/src/services/Services.d.ts.map +1 -1
- package/out/src/services/Services.js +18 -4
- package/out/src/services/Services.js.map +1 -1
- package/out/src/services/providers/WhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/WhatsOnChain.js +1 -2
- package/out/src/services/providers/WhatsOnChain.js.map +1 -1
- package/out/src/services/providers/getBeefForTxid.d.ts.map +1 -1
- package/out/src/services/providers/getBeefForTxid.js.map +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.d.ts +2 -3
- package/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.d.ts +3 -4
- package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.js +1 -2
- package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
- package/out/src/signer/methods/createAction.d.ts +3 -4
- package/out/src/signer/methods/createAction.d.ts.map +1 -1
- package/out/src/signer/methods/createAction.js +17 -6
- package/out/src/signer/methods/createAction.js.map +1 -1
- package/out/src/signer/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/signer/methods/internalizeAction.js +1 -2
- package/out/src/signer/methods/internalizeAction.js.map +1 -1
- package/out/src/signer/methods/proveCertificate.d.ts +2 -3
- package/out/src/signer/methods/proveCertificate.d.ts.map +1 -1
- package/out/src/signer/methods/proveCertificate.js.map +1 -1
- package/out/src/signer/methods/signAction.d.ts.map +1 -1
- package/out/src/signer/methods/signAction.js +1 -2
- package/out/src/signer/methods/signAction.js.map +1 -1
- package/out/src/storage/StorageIdb.d.ts +3 -4
- package/out/src/storage/StorageIdb.d.ts.map +1 -1
- package/out/src/storage/StorageIdb.js.map +1 -1
- package/out/src/storage/StorageKnex.d.ts +3 -4
- package/out/src/storage/StorageKnex.d.ts.map +1 -1
- package/out/src/storage/StorageKnex.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +6 -7
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +5 -6
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts +5 -5
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +5 -4
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/__test/getBeefForTransaction.test.js.map +1 -1
- package/out/src/storage/methods/ListActionsSpecOp.d.ts +2 -2
- package/out/src/storage/methods/ListActionsSpecOp.d.ts.map +1 -1
- package/out/src/storage/methods/ListActionsSpecOp.js.map +1 -1
- package/out/src/storage/methods/ListOutputsSpecOp.d.ts +4 -5
- package/out/src/storage/methods/ListOutputsSpecOp.d.ts.map +1 -1
- package/out/src/storage/methods/ListOutputsSpecOp.js.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +2 -2
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js +11 -7
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
- package/out/src/storage/methods/createAction.d.ts +3 -4
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +18 -5
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/methods/generateChange.js +10 -10
- package/out/src/storage/methods/generateChange.js.map +1 -1
- package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/storage/methods/internalizeAction.js +1 -2
- package/out/src/storage/methods/internalizeAction.js.map +1 -1
- package/out/src/storage/methods/listActionsIdb.d.ts +2 -3
- package/out/src/storage/methods/listActionsIdb.d.ts.map +1 -1
- package/out/src/storage/methods/listActionsIdb.js.map +1 -1
- package/out/src/storage/methods/listActionsKnex.d.ts +2 -3
- package/out/src/storage/methods/listActionsKnex.d.ts.map +1 -1
- package/out/src/storage/methods/listActionsKnex.js.map +1 -1
- package/out/src/storage/methods/listCertificates.d.ts +3 -3
- package/out/src/storage/methods/listCertificates.d.ts.map +1 -1
- package/out/src/storage/methods/listCertificates.js.map +1 -1
- package/out/src/storage/methods/listOutputsIdb.d.ts +2 -3
- package/out/src/storage/methods/listOutputsIdb.d.ts.map +1 -1
- package/out/src/storage/methods/listOutputsIdb.js.map +1 -1
- package/out/src/storage/methods/listOutputsKnex.d.ts +2 -3
- package/out/src/storage/methods/listOutputsKnex.d.ts.map +1 -1
- package/out/src/storage/methods/listOutputsKnex.js.map +1 -1
- package/out/src/storage/methods/processAction.d.ts +2 -2
- package/out/src/storage/methods/processAction.d.ts.map +1 -1
- package/out/src/storage/methods/processAction.js +15 -10
- package/out/src/storage/methods/processAction.js.map +1 -1
- package/out/src/storage/remoting/StorageClient.d.ts +5 -6
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClient.js +22 -0
- package/out/src/storage/remoting/StorageClient.js.map +1 -1
- package/out/src/storage/remoting/StorageMobile.d.ts +5 -6
- package/out/src/storage/remoting/StorageMobile.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageMobile.js.map +1 -1
- package/out/src/storage/remoting/StorageServer.d.ts +5 -0
- package/out/src/storage/remoting/StorageServer.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageServer.js +38 -5
- package/out/src/storage/remoting/StorageServer.js.map +1 -1
- package/out/src/storage/remoting/__test/StorageClient.test.d.ts +2 -0
- package/out/src/storage/remoting/__test/StorageClient.test.d.ts.map +1 -0
- package/out/src/storage/remoting/__test/StorageClient.test.js +98 -0
- package/out/src/storage/remoting/__test/StorageClient.test.js.map +1 -0
- package/out/src/storage/sync/StorageMySQLDojoReader.d.ts.map +1 -1
- package/out/src/storage/sync/StorageMySQLDojoReader.js +1 -2
- package/out/src/storage/sync/StorageMySQLDojoReader.js.map +1 -1
- package/out/test/Wallet/certificate/listCertificates.test.js.map +1 -1
- package/out/test/Wallet/local/localWallet2.man.test.js.map +1 -1
- package/out/test/Wallet/signAction/mountaintop.man.test.js +2 -2
- package/out/test/Wallet/signAction/mountaintop.man.test.js.map +1 -1
- package/out/test/Wallet/support/operations.man.test.js +46 -1
- package/out/test/Wallet/support/operations.man.test.js.map +1 -1
- package/out/test/Wallet/support/reqErrorReview.2025.05.06.man.test.js.map +1 -1
- package/out/test/WalletClient/WERR.man.test.js +1 -1
- package/out/test/WalletClient/WERR.man.test.js.map +1 -1
- package/out/test/utils/localWalletMethods.d.ts.map +1 -1
- package/out/test/utils/localWalletMethods.js +2 -3
- package/out/test/utils/localWalletMethods.js.map +1 -1
- package/out/test/wallet/action/createAction.test.js +3 -0
- package/out/test/wallet/action/createAction.test.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Wallet.ts +114 -79
- package/src/WalletLogger.ts +167 -0
- package/src/WalletPermissionsManager.ts +3 -5
- package/src/__tests/WalletPermissionsManager.fixtures.ts +14 -1
- package/src/__tests/WalletPermissionsManager.proxying.test.ts +89 -85
- package/src/index.mobile.ts +1 -0
- package/src/sdk/WERR_errors.ts +6 -3
- package/src/sdk/WalletError.ts +0 -4
- package/src/sdk/WalletServices.interfaces.ts +14 -3
- package/src/sdk/WalletStorage.interfaces.ts +11 -16
- package/src/sdk/__test/validationHelpers.test.ts +4 -5
- package/src/sdk/index.ts +1 -1
- package/src/services/Services.ts +23 -5
- package/src/services/providers/WhatsOnChain.ts +2 -3
- package/src/services/providers/getBeefForTxid.ts +3 -5
- package/src/signer/methods/acquireDirectCertificate.ts +2 -3
- package/src/signer/methods/buildSignableTransaction.ts +5 -6
- package/src/signer/methods/createAction.ts +24 -18
- package/src/signer/methods/internalizeAction.ts +4 -5
- package/src/signer/methods/proveCertificate.ts +3 -4
- package/src/signer/methods/signAction.ts +6 -4
- package/src/storage/StorageIdb.ts +3 -4
- package/src/storage/StorageKnex.ts +3 -4
- package/src/storage/StorageProvider.ts +16 -20
- package/src/storage/WalletStorageManager.ts +10 -11
- package/src/storage/__test/getBeefForTransaction.test.ts +3 -4
- package/src/storage/methods/ListActionsSpecOp.ts +4 -4
- package/src/storage/methods/ListOutputsSpecOp.ts +7 -8
- package/src/storage/methods/attemptToPostReqsToNetwork.ts +15 -8
- package/src/storage/methods/createAction.ts +39 -23
- package/src/storage/methods/generateChange.ts +10 -10
- package/src/storage/methods/internalizeAction.ts +4 -4
- package/src/storage/methods/listActionsIdb.ts +3 -3
- package/src/storage/methods/listActionsKnex.ts +3 -3
- package/src/storage/methods/listCertificates.ts +7 -6
- package/src/storage/methods/listOutputsIdb.ts +2 -3
- package/src/storage/methods/listOutputsKnex.ts +2 -3
- package/src/storage/methods/processAction.ts +30 -11
- package/src/storage/remoting/StorageClient.ts +31 -12
- package/src/storage/remoting/StorageMobile.ts +6 -12
- package/src/storage/remoting/StorageServer.ts +45 -6
- package/src/storage/remoting/__test/StorageClient.test.ts +113 -0
- package/src/storage/sync/StorageMySQLDojoReader.ts +2 -3
- package/test/Wallet/certificate/listCertificates.test.ts +2 -2
- package/test/Wallet/local/localWallet2.man.test.ts +5 -5
- package/test/Wallet/signAction/mountaintop.man.test.ts +3 -2
- package/test/Wallet/support/operations.man.test.ts +65 -6
- package/test/Wallet/support/reqErrorReview.2025.05.06.man.test.ts +2 -14
- package/test/WalletClient/WERR.man.test.ts +3 -3
- package/test/utils/localWalletMethods.ts +5 -5
- package/test/wallet/action/createAction.test.ts +3 -0
- package/mobile/out/src/sdk/validationHelpers.d.ts +0 -322
- package/mobile/out/src/sdk/validationHelpers.d.ts.map +0 -1
- package/mobile/out/src/sdk/validationHelpers.js +0 -691
- package/mobile/out/src/sdk/validationHelpers.js.map +0 -1
- package/out/src/sdk/validationHelpers.d.ts +0 -322
- package/out/src/sdk/validationHelpers.d.ts.map +0 -1
- package/out/src/sdk/validationHelpers.js +0 -691
- package/out/src/sdk/validationHelpers.js.map +0 -1
- package/src/sdk/validationHelpers.ts +0 -1034
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Beef,
|
|
3
|
+
OriginatorDomainNameStringUnder250Bytes,
|
|
4
|
+
Random,
|
|
5
|
+
ReviewActionResult,
|
|
6
|
+
Script,
|
|
7
|
+
Utils,
|
|
8
|
+
Validation
|
|
9
|
+
} from '@bsv/sdk'
|
|
2
10
|
import {
|
|
3
11
|
generateChangeSdk,
|
|
4
12
|
GenerateChangeSdkChangeInput,
|
|
@@ -15,12 +23,6 @@ import {
|
|
|
15
23
|
StorageGetBeefOptions,
|
|
16
24
|
StorageProvidedBy
|
|
17
25
|
} from '../../sdk/WalletStorage.interfaces'
|
|
18
|
-
import {
|
|
19
|
-
ValidCreateActionArgs,
|
|
20
|
-
ValidCreateActionInput,
|
|
21
|
-
ValidCreateActionOutput,
|
|
22
|
-
validateSatoshis
|
|
23
|
-
} from '../../sdk/validationHelpers'
|
|
24
26
|
import { WERR_INTERNAL, WERR_INVALID_PARAMETER, WERR_REVIEW_ACTIONS } from '../../sdk/WERR_errors'
|
|
25
27
|
import {
|
|
26
28
|
randomBytesBase64,
|
|
@@ -48,9 +50,11 @@ export function setDisableDoubleSpendCheckForTest(v: boolean) {
|
|
|
48
50
|
export async function createAction(
|
|
49
51
|
storage: StorageProvider,
|
|
50
52
|
auth: AuthId,
|
|
51
|
-
vargs: ValidCreateActionArgs,
|
|
53
|
+
vargs: Validation.ValidCreateActionArgs,
|
|
52
54
|
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
53
55
|
): Promise<StorageCreateActionResult> {
|
|
56
|
+
const logger = vargs.logger
|
|
57
|
+
logger?.group(`storage createAction`)
|
|
54
58
|
//stampLog(vargs, `start storage createTransactionSdk`)
|
|
55
59
|
|
|
56
60
|
if (vargs.isTestWerrReviewActions) throwDummyReviewActions()
|
|
@@ -77,7 +81,9 @@ export async function createAction(
|
|
|
77
81
|
|
|
78
82
|
const userId = auth.userId!
|
|
79
83
|
const { storageBeef, beef, xinputs } = await validateRequiredInputs(storage, userId, vargs)
|
|
84
|
+
logger?.log('validated required inputs')
|
|
80
85
|
const xoutputs = validateRequiredOutputs(storage, userId, vargs)
|
|
86
|
+
logger?.log('validated required outputs')
|
|
81
87
|
|
|
82
88
|
const changeBasketName = 'default'
|
|
83
89
|
const changeBasket = verifyOne(
|
|
@@ -86,14 +92,19 @@ export async function createAction(
|
|
|
86
92
|
}),
|
|
87
93
|
`Invalid outputGeneration basket "${changeBasketName}"`
|
|
88
94
|
)
|
|
95
|
+
logger?.log('found change basket')
|
|
89
96
|
|
|
90
97
|
const noSendChangeIn = await validateNoSendChange(storage, userId, vargs, changeBasket)
|
|
98
|
+
logger?.log('validated noSendChange')
|
|
91
99
|
|
|
92
100
|
const availableChangeCount = await storage.countChangeInputs(userId, changeBasket.basketId, !vargs.isDelayed)
|
|
101
|
+
logger?.log(`counted change inputs ${availableChangeCount}`)
|
|
93
102
|
|
|
94
103
|
const feeModel = validateStorageFeeModel(storage.feeModel)
|
|
104
|
+
logger?.log(`validated fee model ${JSON.stringify(feeModel)}`)
|
|
95
105
|
|
|
96
106
|
const newTx = await createNewTxRecord(storage, userId, vargs, storageBeef)
|
|
107
|
+
logger?.log(`created new transaction record`)
|
|
97
108
|
|
|
98
109
|
const ctx: CreateTransactionSdkContext = {
|
|
99
110
|
xinputs,
|
|
@@ -107,11 +118,13 @@ export async function createAction(
|
|
|
107
118
|
|
|
108
119
|
const { allocatedChange, changeOutputs, derivationPrefix, maxPossibleSatoshisAdjustment } =
|
|
109
120
|
await fundNewTransactionSdk(storage, userId, vargs, ctx)
|
|
121
|
+
logger?.log(`funded new transaction`)
|
|
110
122
|
|
|
111
123
|
if (maxPossibleSatoshisAdjustment) {
|
|
112
124
|
const a = maxPossibleSatoshisAdjustment
|
|
113
125
|
if (ctx.xoutputs[a.fixedOutputIndex].satoshis !== maxPossibleSatoshis) throw new WERR_INTERNAL()
|
|
114
126
|
ctx.xoutputs[a.fixedOutputIndex].satoshis = a.satoshis
|
|
127
|
+
logger?.log(`adjusted change outputs to max possible`)
|
|
115
128
|
}
|
|
116
129
|
|
|
117
130
|
// The satoshis of the transaction is the satoshis we get back in change minus the satoshis we spend.
|
|
@@ -120,10 +133,13 @@ export async function createAction(
|
|
|
120
133
|
await storage.updateTransaction(newTx.transactionId!, { satoshis })
|
|
121
134
|
|
|
122
135
|
const { outputs, changeVouts } = await createNewOutputs(storage, userId, vargs, ctx, changeOutputs)
|
|
136
|
+
logger?.log(`created new output records`)
|
|
123
137
|
|
|
124
138
|
const inputBeef = await mergeAllocatedChangeBeefs(storage, userId, vargs, allocatedChange, beef)
|
|
139
|
+
logger?.log(`merged allocated change beefs`)
|
|
125
140
|
|
|
126
141
|
const inputs = await createNewInputs(storage, userId, vargs, ctx, allocatedChange)
|
|
142
|
+
logger?.log(`created new inputs`)
|
|
127
143
|
|
|
128
144
|
const r: StorageCreateActionResult = {
|
|
129
145
|
reference: newTx.reference!,
|
|
@@ -136,7 +152,7 @@ export async function createAction(
|
|
|
136
152
|
noSendChangeOutputVouts: vargs.isNoSend ? changeVouts : undefined
|
|
137
153
|
}
|
|
138
154
|
|
|
139
|
-
|
|
155
|
+
logger?.groupEnd()
|
|
140
156
|
return r
|
|
141
157
|
}
|
|
142
158
|
|
|
@@ -150,14 +166,14 @@ interface CreateTransactionSdkContext {
|
|
|
150
166
|
transactionId: number
|
|
151
167
|
}
|
|
152
168
|
|
|
153
|
-
interface XValidCreateActionInput extends ValidCreateActionInput {
|
|
169
|
+
interface XValidCreateActionInput extends Validation.ValidCreateActionInput {
|
|
154
170
|
vin: number
|
|
155
171
|
lockingScript: Script
|
|
156
172
|
satoshis: number
|
|
157
173
|
output?: TableOutput
|
|
158
174
|
}
|
|
159
175
|
|
|
160
|
-
export interface XValidCreateActionOutput extends ValidCreateActionOutput {
|
|
176
|
+
export interface XValidCreateActionOutput extends Validation.ValidCreateActionOutput {
|
|
161
177
|
vout: number
|
|
162
178
|
providedBy: StorageProvidedBy
|
|
163
179
|
purpose?: string
|
|
@@ -198,7 +214,7 @@ function makeDefaultOutput(userId: number, transactionId: number, satoshis: numb
|
|
|
198
214
|
async function createNewInputs(
|
|
199
215
|
storage: StorageProvider,
|
|
200
216
|
userId: number,
|
|
201
|
-
vargs: ValidCreateActionArgs,
|
|
217
|
+
vargs: Validation.ValidCreateActionArgs,
|
|
202
218
|
ctx: CreateTransactionSdkContext,
|
|
203
219
|
allocatedChange: TableOutput[]
|
|
204
220
|
): Promise<StorageCreateTransactionSdkInput[]> {
|
|
@@ -302,7 +318,7 @@ async function createNewInputs(
|
|
|
302
318
|
async function createNewOutputs(
|
|
303
319
|
storage: StorageProvider,
|
|
304
320
|
userId: number,
|
|
305
|
-
vargs: ValidCreateActionArgs,
|
|
321
|
+
vargs: Validation.ValidCreateActionArgs,
|
|
306
322
|
ctx: CreateTransactionSdkContext,
|
|
307
323
|
changeOutputs: TableOutput[]
|
|
308
324
|
): Promise<{
|
|
@@ -427,7 +443,7 @@ async function createNewOutputs(
|
|
|
427
443
|
|
|
428
444
|
const ro: StorageCreateTransactionSdkOutput = {
|
|
429
445
|
vout: verifyInteger(o.vout),
|
|
430
|
-
satoshis: validateSatoshis(o.satoshis, 'o.satoshis'),
|
|
446
|
+
satoshis: Validation.validateSatoshis(o.satoshis, 'o.satoshis'),
|
|
431
447
|
lockingScript: !o.lockingScript ? '' : asString(o.lockingScript),
|
|
432
448
|
providedBy: verifyTruthy(o.providedBy) as StorageProvidedBy,
|
|
433
449
|
purpose: o.purpose || undefined,
|
|
@@ -446,7 +462,7 @@ async function createNewOutputs(
|
|
|
446
462
|
async function createNewTxRecord(
|
|
447
463
|
storage: StorageProvider,
|
|
448
464
|
userId: number,
|
|
449
|
-
vargs: ValidCreateActionArgs,
|
|
465
|
+
vargs: Validation.ValidCreateActionArgs,
|
|
450
466
|
storageBeef: Beef
|
|
451
467
|
): Promise<TableTransaction> {
|
|
452
468
|
const now = new Date()
|
|
@@ -501,7 +517,7 @@ async function createNewTxRecord(
|
|
|
501
517
|
function validateRequiredOutputs(
|
|
502
518
|
storage: StorageProvider,
|
|
503
519
|
userId: number,
|
|
504
|
-
vargs: ValidCreateActionArgs
|
|
520
|
+
vargs: Validation.ValidCreateActionArgs
|
|
505
521
|
): XValidCreateActionOutput[] {
|
|
506
522
|
const xoutputs: XValidCreateActionOutput[] = []
|
|
507
523
|
let vout = -1
|
|
@@ -562,7 +578,7 @@ function validateRequiredOutputs(
|
|
|
562
578
|
async function validateRequiredInputs(
|
|
563
579
|
storage: StorageProvider,
|
|
564
580
|
userId: number,
|
|
565
|
-
vargs: ValidCreateActionArgs
|
|
581
|
+
vargs: Validation.ValidCreateActionArgs
|
|
566
582
|
): Promise<{
|
|
567
583
|
storageBeef: Beef
|
|
568
584
|
beef: Beef
|
|
@@ -640,7 +656,7 @@ async function validateRequiredInputs(
|
|
|
640
656
|
if (!disableDoubleSpendCheckForTest && !output.spendable && !vargs.isNoSend)
|
|
641
657
|
throw new WERR_INVALID_PARAMETER(`${txid}.${vout}`, 'spendable output unless noSend is true')
|
|
642
658
|
// input is spending an existing user output which has an lockingScript
|
|
643
|
-
input.satoshis = validateSatoshis(output.satoshis, 'output.satoshis')
|
|
659
|
+
input.satoshis = Validation.validateSatoshis(output.satoshis, 'output.satoshis')
|
|
644
660
|
input.lockingScript = Script.fromBinary(asArray(output.lockingScript!))
|
|
645
661
|
} else {
|
|
646
662
|
let btx = beef.findTxid(txid)!
|
|
@@ -654,7 +670,7 @@ async function validateRequiredInputs(
|
|
|
654
670
|
// btx is valid has parsed transaction data.
|
|
655
671
|
if (vout >= btx.tx!.outputs.length) throw new WERR_INVALID_PARAMETER(`${txid}.${vout}`, 'valid outpoint')
|
|
656
672
|
const so = btx.tx!.outputs[vout]
|
|
657
|
-
input.satoshis = validateSatoshis(so.satoshis, 'so.satoshis')
|
|
673
|
+
input.satoshis = Validation.validateSatoshis(so.satoshis, 'so.satoshis')
|
|
658
674
|
input.lockingScript = so.lockingScript
|
|
659
675
|
}
|
|
660
676
|
}
|
|
@@ -685,7 +701,7 @@ async function verifyBeefFixOrhpans(beef: Beef, storage: StorageProvider): Promi
|
|
|
685
701
|
async function validateNoSendChange(
|
|
686
702
|
storage: StorageProvider,
|
|
687
703
|
userId: number,
|
|
688
|
-
vargs: ValidCreateActionArgs,
|
|
704
|
+
vargs: Validation.ValidCreateActionArgs,
|
|
689
705
|
changeBasket: TableOutputBasket
|
|
690
706
|
): Promise<TableOutput[]> {
|
|
691
707
|
const r: TableOutput[] = []
|
|
@@ -725,7 +741,7 @@ async function validateNoSendChange(
|
|
|
725
741
|
async function fundNewTransactionSdk(
|
|
726
742
|
storage: StorageProvider,
|
|
727
743
|
userId: number,
|
|
728
|
-
vargs: ValidCreateActionArgs,
|
|
744
|
+
vargs: Validation.ValidCreateActionArgs,
|
|
729
745
|
ctx: CreateTransactionSdkContext
|
|
730
746
|
): Promise<{
|
|
731
747
|
allocatedChange: TableOutput[]
|
|
@@ -897,7 +913,7 @@ async function fundNewTransactionSdk(
|
|
|
897
913
|
* in the `beef` to txidOnly.
|
|
898
914
|
* @returns undefined if `vargs.options.returnTXIDOnly` or trimmed `Beef`
|
|
899
915
|
*/
|
|
900
|
-
function trimInputBeef(beef: Beef, vargs: ValidCreateActionArgs): number[] | undefined {
|
|
916
|
+
function trimInputBeef(beef: Beef, vargs: Validation.ValidCreateActionArgs): number[] | undefined {
|
|
901
917
|
if (vargs.options.returnTXIDOnly) return undefined
|
|
902
918
|
const knownTxids: Record<string, boolean> = {}
|
|
903
919
|
for (const txid of vargs.options.knownTxids) knownTxids[txid] = true
|
|
@@ -908,7 +924,7 @@ function trimInputBeef(beef: Beef, vargs: ValidCreateActionArgs): number[] | und
|
|
|
908
924
|
async function mergeAllocatedChangeBeefs(
|
|
909
925
|
storage: StorageProvider,
|
|
910
926
|
userId: number,
|
|
911
|
-
vargs: ValidCreateActionArgs,
|
|
927
|
+
vargs: Validation.ValidCreateActionArgs,
|
|
912
928
|
allocatedChange: TableOutput[],
|
|
913
929
|
beef: Beef
|
|
914
930
|
): Promise<number[] | undefined> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Validation } 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'
|
|
@@ -445,14 +445,14 @@ export function validateGenerateChangeSdkParams(
|
|
|
445
445
|
const r: ValidateGenerateChangeSdkParamsResult = {}
|
|
446
446
|
|
|
447
447
|
params.fixedInputs.forEach((x, i) => {
|
|
448
|
-
validateSatoshis(x.satoshis, `fixedInputs[${i}].satoshis`)
|
|
449
|
-
validateInteger(x.unlockingScriptLength, `fixedInputs[${i}].unlockingScriptLength`, undefined, 0)
|
|
448
|
+
Validation.validateSatoshis(x.satoshis, `fixedInputs[${i}].satoshis`)
|
|
449
|
+
Validation.validateInteger(x.unlockingScriptLength, `fixedInputs[${i}].unlockingScriptLength`, undefined, 0)
|
|
450
450
|
})
|
|
451
451
|
|
|
452
452
|
if (!Array.isArray(params.fixedOutputs)) throw new WERR_INVALID_PARAMETER('fixedOutputs', 'an array of objects')
|
|
453
453
|
params.fixedOutputs.forEach((x, i) => {
|
|
454
|
-
validateSatoshis(x.satoshis, `fixedOutputs[${i}].satoshis`)
|
|
455
|
-
validateInteger(x.lockingScriptLength, `fixedOutputs[${i}].lockingScriptLength`, undefined, 0)
|
|
454
|
+
Validation.validateSatoshis(x.satoshis, `fixedOutputs[${i}].satoshis`)
|
|
455
|
+
Validation.validateInteger(x.lockingScriptLength, `fixedOutputs[${i}].lockingScriptLength`, undefined, 0)
|
|
456
456
|
if (x.satoshis === maxPossibleSatoshis) {
|
|
457
457
|
if (r.hasMaxPossibleOutput !== undefined)
|
|
458
458
|
throw new WERR_INVALID_PARAMETER(
|
|
@@ -466,13 +466,13 @@ export function validateGenerateChangeSdkParams(
|
|
|
466
466
|
params.feeModel = validateStorageFeeModel(params.feeModel)
|
|
467
467
|
if (params.feeModel.model !== 'sat/kb') throw new WERR_INVALID_PARAMETER('feeModel.model', `'sat/kb'`)
|
|
468
468
|
|
|
469
|
-
validateOptionalInteger(params.targetNetCount, `targetNetCount`)
|
|
469
|
+
Validation.validateOptionalInteger(params.targetNetCount, `targetNetCount`)
|
|
470
470
|
|
|
471
|
-
validateSatoshis(params.changeFirstSatoshis, 'changeFirstSatoshis', 1)
|
|
472
|
-
validateSatoshis(params.changeInitialSatoshis, 'changeInitialSatoshis', 1)
|
|
471
|
+
Validation.validateSatoshis(params.changeFirstSatoshis, 'changeFirstSatoshis', 1)
|
|
472
|
+
Validation.validateSatoshis(params.changeInitialSatoshis, 'changeInitialSatoshis', 1)
|
|
473
473
|
|
|
474
|
-
validateInteger(params.changeLockingScriptLength, `changeLockingScriptLength`)
|
|
475
|
-
validateInteger(params.changeUnlockingScriptLength, `changeUnlockingScriptLength`)
|
|
474
|
+
Validation.validateInteger(params.changeLockingScriptLength, `changeLockingScriptLength`)
|
|
475
|
+
Validation.validateInteger(params.changeUnlockingScriptLength, `changeUnlockingScriptLength`)
|
|
476
476
|
|
|
477
477
|
return r
|
|
478
478
|
}
|
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
BasketInsertion,
|
|
5
5
|
InternalizeActionArgs,
|
|
6
6
|
TransactionOutput,
|
|
7
|
-
Beef
|
|
7
|
+
Beef,
|
|
8
|
+
Validation
|
|
8
9
|
} from '@bsv/sdk'
|
|
9
10
|
import { GetReqsAndBeefResult, shareReqsWithWorld } from './processAction'
|
|
10
11
|
import { StorageProvider } from '../StorageProvider'
|
|
@@ -12,7 +13,6 @@ import { AuthId, StorageInternalizeActionResult, StorageProvenOrReq } from '../.
|
|
|
12
13
|
import { TableOutput } from '../schema/tables/TableOutput'
|
|
13
14
|
import { TableOutputBasket } from '../schema/tables/TableOutputBasket'
|
|
14
15
|
import { TableTransaction } from '../schema/tables/TableTransaction'
|
|
15
|
-
import { validateInternalizeActionArgs, ValidInternalizeActionArgs } from '../../sdk/validationHelpers'
|
|
16
16
|
import { WERR_INTERNAL, WERR_INVALID_PARAMETER } from '../../sdk/WERR_errors'
|
|
17
17
|
import { randomBytesBase64, verifyId, verifyOne, verifyOneOrNone } from '../../utility/utilityHelpers'
|
|
18
18
|
import { TransactionStatus } from '../../sdk/types'
|
|
@@ -100,14 +100,14 @@ class InternalizeActionContext {
|
|
|
100
100
|
/** all the wallet payments from incoming outputs array */
|
|
101
101
|
walletPayments: WalletPaymentX[]
|
|
102
102
|
userId: number
|
|
103
|
-
vargs: ValidInternalizeActionArgs
|
|
103
|
+
vargs: Validation.ValidInternalizeActionArgs
|
|
104
104
|
|
|
105
105
|
constructor(
|
|
106
106
|
public storage: StorageProvider,
|
|
107
107
|
public auth: AuthId,
|
|
108
108
|
public args: InternalizeActionArgs
|
|
109
109
|
) {
|
|
110
|
-
this.vargs = validateInternalizeActionArgs(args)
|
|
110
|
+
this.vargs = Validation.validateInternalizeActionArgs(args)
|
|
111
111
|
this.userId = auth.userId!
|
|
112
112
|
this.r = {
|
|
113
113
|
accepted: true,
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
ListActionsResult,
|
|
5
5
|
WalletAction,
|
|
6
6
|
WalletActionOutput,
|
|
7
|
-
WalletActionInput
|
|
7
|
+
WalletActionInput,
|
|
8
|
+
Validation
|
|
8
9
|
} from '@bsv/sdk'
|
|
9
10
|
import { StorageIdb } from '../StorageIdb'
|
|
10
11
|
import { getLabelToSpecOp, ListActionsSpecOp } from './ListActionsSpecOp'
|
|
11
12
|
import { AuthId } from '../../sdk/WalletStorage.interfaces'
|
|
12
|
-
import { ValidListActionsArgs } from '../../sdk/validationHelpers'
|
|
13
13
|
import { isListActionsSpecOp, TransactionStatus } from '../../sdk/types'
|
|
14
14
|
import { TableOutputX } from '../schema/tables/TableOutput'
|
|
15
15
|
import { asString } from '../../utility/utilityHelpers.noBuffer'
|
|
@@ -17,7 +17,7 @@ import { asString } from '../../utility/utilityHelpers.noBuffer'
|
|
|
17
17
|
export async function listActionsIdb(
|
|
18
18
|
storage: StorageIdb,
|
|
19
19
|
auth: AuthId,
|
|
20
|
-
vargs: ValidListActionsArgs
|
|
20
|
+
vargs: Validation.ValidListActionsArgs
|
|
21
21
|
): Promise<ListActionsResult> {
|
|
22
22
|
const limit = vargs.limit
|
|
23
23
|
const offset = vargs.offset
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
ListActionsResult,
|
|
5
5
|
WalletAction,
|
|
6
6
|
WalletActionOutput,
|
|
7
|
-
WalletActionInput
|
|
7
|
+
WalletActionInput,
|
|
8
|
+
Validation
|
|
8
9
|
} from '@bsv/sdk'
|
|
9
10
|
import { StorageKnex } from '../StorageKnex'
|
|
10
11
|
import { getLabelToSpecOp, ListActionsSpecOp } from './ListActionsSpecOp'
|
|
11
12
|
import { AuthId } from '../../sdk/WalletStorage.interfaces'
|
|
12
|
-
import { ValidListActionsArgs } from '../../sdk/validationHelpers'
|
|
13
13
|
import { isListActionsSpecOp } from '../../sdk/types'
|
|
14
14
|
import { TableTxLabel } from '../schema/tables/TableTxLabel'
|
|
15
15
|
import { TableTransaction } from '../schema/tables/TableTransaction'
|
|
@@ -20,7 +20,7 @@ import { asString } from '../../utility/utilityHelpers.noBuffer'
|
|
|
20
20
|
export async function listActions(
|
|
21
21
|
storage: StorageKnex,
|
|
22
22
|
auth: AuthId,
|
|
23
|
-
vargs: ValidListActionsArgs
|
|
23
|
+
vargs: Validation.ValidListActionsArgs
|
|
24
24
|
): Promise<ListActionsResult> {
|
|
25
25
|
const limit = vargs.limit
|
|
26
26
|
const offset = vargs.offset
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { ListCertificatesResult, OriginatorDomainNameStringUnder250Bytes } from '@bsv/sdk'
|
|
1
|
+
import { ListCertificatesResult, OriginatorDomainNameStringUnder250Bytes, Validation } from '@bsv/sdk'
|
|
2
2
|
import { StorageProvider, TableCertificate } from '../index.client'
|
|
3
|
-
import {
|
|
3
|
+
import { AuthId, FindCertificatesArgs } from '../../sdk/WalletStorage.interfaces'
|
|
4
|
+
import { Paged } from '../../sdk/types'
|
|
4
5
|
|
|
5
6
|
export async function listCertificates(
|
|
6
7
|
storage: StorageProvider,
|
|
7
|
-
auth:
|
|
8
|
-
vargs:
|
|
8
|
+
auth: AuthId,
|
|
9
|
+
vargs: Validation.ValidListCertificatesArgs,
|
|
9
10
|
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
10
11
|
): Promise<ListCertificatesResult> {
|
|
11
|
-
const paged:
|
|
12
|
+
const paged: Paged = { limit: vargs.limit, offset: vargs.offset }
|
|
12
13
|
|
|
13
14
|
const partial: Partial<TableCertificate> = {
|
|
14
15
|
userId: auth.userId,
|
|
@@ -26,7 +27,7 @@ export async function listCertificates(
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
const r = await storage.transaction(async trx => {
|
|
29
|
-
const findCertsArgs:
|
|
30
|
+
const findCertsArgs: FindCertificatesArgs = {
|
|
30
31
|
partial,
|
|
31
32
|
certifiers: vargs.certifiers,
|
|
32
33
|
types: vargs.types,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Beef, ListOutputsResult, OriginatorDomainNameStringUnder250Bytes, WalletOutput } from '@bsv/sdk'
|
|
1
|
+
import { Beef, ListOutputsResult, OriginatorDomainNameStringUnder250Bytes, WalletOutput, Validation } from '@bsv/sdk'
|
|
2
2
|
import { getBasketToSpecOp, ListOutputsSpecOp } from './ListOutputsSpecOp'
|
|
3
3
|
import { StorageIdb } from '../StorageIdb'
|
|
4
4
|
import { AuthId, FindOutputsArgs } from '../../sdk/WalletStorage.interfaces'
|
|
5
|
-
import { ValidListOutputsArgs } from '../../sdk/validationHelpers'
|
|
6
5
|
import { verifyId } from '../../utility/utilityHelpers'
|
|
7
6
|
import { WERR_NOT_IMPLEMENTED } from '../../sdk/WERR_errors'
|
|
8
7
|
import { TableOutputBasket } from '../schema/tables/TableOutputBasket'
|
|
@@ -12,7 +11,7 @@ import { asString } from '../../utility/utilityHelpers.noBuffer'
|
|
|
12
11
|
export async function listOutputsIdb(
|
|
13
12
|
storage: StorageIdb,
|
|
14
13
|
auth: AuthId,
|
|
15
|
-
vargs: ValidListOutputsArgs,
|
|
14
|
+
vargs: Validation.ValidListOutputsArgs,
|
|
16
15
|
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
17
16
|
): Promise<ListOutputsResult> {
|
|
18
17
|
const userId = verifyId(auth.userId)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Beef, ListOutputsResult, OriginatorDomainNameStringUnder250Bytes, WalletOutput } from '@bsv/sdk'
|
|
1
|
+
import { Beef, ListOutputsResult, OriginatorDomainNameStringUnder250Bytes, WalletOutput, Validation } from '@bsv/sdk'
|
|
2
2
|
import { StorageKnex } from '../StorageKnex'
|
|
3
3
|
import { getBasketToSpecOp, ListOutputsSpecOp } from './ListOutputsSpecOp'
|
|
4
4
|
import { AuthId, TrxToken } from '../../sdk/WalletStorage.interfaces'
|
|
5
|
-
import { ValidListOutputsArgs } from '../../sdk/validationHelpers'
|
|
6
5
|
import { verifyId, verifyOne } from '../../utility/utilityHelpers'
|
|
7
6
|
import { TableOutputBasket } from '../schema/tables/TableOutputBasket'
|
|
8
7
|
import { TableOutputTag } from '../schema/tables/TableOutputTag'
|
|
@@ -12,7 +11,7 @@ import { asString } from '../../utility/utilityHelpers.noBuffer'
|
|
|
12
11
|
export async function listOutputs(
|
|
13
12
|
dsk: StorageKnex,
|
|
14
13
|
auth: AuthId,
|
|
15
|
-
vargs: ValidListOutputsArgs,
|
|
14
|
+
vargs: Validation.ValidListOutputsArgs,
|
|
16
15
|
originator?: OriginatorDomainNameStringUnder250Bytes
|
|
17
16
|
): Promise<ListOutputsResult> {
|
|
18
17
|
const trx: TrxToken | undefined = undefined
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Beef,
|
|
4
|
+
Transaction as BsvTransaction,
|
|
5
|
+
SendWithResult,
|
|
6
|
+
SendWithResultStatus,
|
|
7
|
+
WalletLoggerInterface
|
|
8
|
+
} from '@bsv/sdk'
|
|
3
9
|
import { aggregateActionResults } from '../../utility/aggregateResults'
|
|
4
10
|
import { StorageProvider } from '../StorageProvider'
|
|
5
11
|
import {
|
|
@@ -33,7 +39,8 @@ export async function processAction(
|
|
|
33
39
|
auth: AuthId,
|
|
34
40
|
args: StorageProcessActionArgs
|
|
35
41
|
): Promise<StorageProcessActionResults> {
|
|
36
|
-
|
|
42
|
+
const logger = args.logger
|
|
43
|
+
logger?.group('storage processAction')
|
|
37
44
|
|
|
38
45
|
const userId = verifyId(auth.userId)
|
|
39
46
|
const r: StorageProcessActionResults = {
|
|
@@ -45,22 +52,32 @@ export async function processAction(
|
|
|
45
52
|
|
|
46
53
|
if (args.isNewTx) {
|
|
47
54
|
const vargs = await validateCommitNewTxToStorageArgs(storage, userId, args)
|
|
48
|
-
|
|
55
|
+
logger?.log(`validated new tx updates to storage`)
|
|
56
|
+
;({ req } = await commitNewTxToStorage(storage, userId, vargs))
|
|
57
|
+
logger?.log(`committed new tx updates to storage `)
|
|
49
58
|
if (!req) throw new WERR_INTERNAL()
|
|
50
59
|
// Add the new txid to sendWith unless there are no others to send and the noSend option is set.
|
|
51
|
-
if (args.isNoSend && !args.isSendWith)
|
|
52
|
-
|
|
60
|
+
if (args.isNoSend && !args.isSendWith) {
|
|
61
|
+
logger?.log(`noSend txid ${req.txid}`)
|
|
62
|
+
} else {
|
|
53
63
|
txidsOfReqsToShareWithWorld.push(req.txid)
|
|
54
|
-
|
|
64
|
+
logger?.log(`sending txid ${req.txid}`)
|
|
55
65
|
}
|
|
56
66
|
}
|
|
57
67
|
|
|
58
|
-
const { swr, ndr } = await shareReqsWithWorld(
|
|
68
|
+
const { swr, ndr } = await shareReqsWithWorld(
|
|
69
|
+
storage,
|
|
70
|
+
userId,
|
|
71
|
+
txidsOfReqsToShareWithWorld,
|
|
72
|
+
args.isDelayed,
|
|
73
|
+
undefined,
|
|
74
|
+
logger
|
|
75
|
+
)
|
|
59
76
|
|
|
60
77
|
r.sendWithResults = swr
|
|
61
78
|
r.notDelayedResults = ndr
|
|
62
79
|
|
|
63
|
-
|
|
80
|
+
logger?.groupEnd()
|
|
64
81
|
|
|
65
82
|
return r
|
|
66
83
|
}
|
|
@@ -114,7 +131,8 @@ export async function shareReqsWithWorld(
|
|
|
114
131
|
userId: number,
|
|
115
132
|
txids: string[],
|
|
116
133
|
isDelayed: boolean,
|
|
117
|
-
r?: GetReqsAndBeefResult
|
|
134
|
+
r?: GetReqsAndBeefResult,
|
|
135
|
+
logger?: WalletLoggerInterface
|
|
118
136
|
): Promise<{ swr: SendWithResult[]; ndr: ReviewActionResult[] | undefined }> {
|
|
119
137
|
let swr: SendWithResult[] = []
|
|
120
138
|
let ndr: ReviewActionResult[] | undefined = undefined
|
|
@@ -147,9 +165,10 @@ export async function shareReqsWithWorld(
|
|
|
147
165
|
if (readyToSendReqs.length > 0) {
|
|
148
166
|
const beefIsValid = await r.beef.verify(await storage.getServices().getChainTracker())
|
|
149
167
|
if (!beefIsValid) {
|
|
150
|
-
|
|
168
|
+
logger?.error(`VERIFY FALSE BEEF: ${r.beef.toLogString()}`)
|
|
151
169
|
throw new WERR_INTERNAL(`merged Beef failed validation.`)
|
|
152
170
|
}
|
|
171
|
+
logger?.log(`beef is valid`)
|
|
153
172
|
}
|
|
154
173
|
|
|
155
174
|
// Set req batch property for the reqs being sent
|
|
@@ -179,7 +198,7 @@ export async function shareReqsWithWorld(
|
|
|
179
198
|
//
|
|
180
199
|
// Handle the NON-DELAYED-SEND-NOW case
|
|
181
200
|
//
|
|
182
|
-
const prtn = await storage.attemptToPostReqsToNetwork(readyToSendReqs)
|
|
201
|
+
const prtn = await storage.attemptToPostReqsToNetwork(readyToSendReqs, undefined, logger)
|
|
183
202
|
|
|
184
203
|
const { swr: swrRes, rar } = await aggregateActionResults(storage, swr, prtn)
|
|
185
204
|
return { swr: swrRes, ndr: rar }
|
|
@@ -2,14 +2,15 @@ import {
|
|
|
2
2
|
AbortActionArgs,
|
|
3
3
|
AbortActionResult,
|
|
4
4
|
InternalizeActionArgs,
|
|
5
|
-
InternalizeActionResult,
|
|
6
5
|
ListActionsResult,
|
|
7
6
|
ListCertificatesResult,
|
|
8
7
|
ListOutputsResult,
|
|
9
8
|
RelinquishCertificateArgs,
|
|
10
9
|
RelinquishOutputArgs,
|
|
11
10
|
WalletInterface,
|
|
12
|
-
AuthFetch
|
|
11
|
+
AuthFetch,
|
|
12
|
+
Validation,
|
|
13
|
+
WalletLoggerInterface
|
|
13
14
|
} from '@bsv/sdk'
|
|
14
15
|
import {
|
|
15
16
|
AuthId,
|
|
@@ -31,12 +32,6 @@ import {
|
|
|
31
32
|
import { TableSettings } from '../schema/tables/TableSettings'
|
|
32
33
|
import { WERR_INVALID_OPERATION } from '../../sdk/WERR_errors'
|
|
33
34
|
import { WalletServices } from '../../sdk/WalletServices.interfaces'
|
|
34
|
-
import {
|
|
35
|
-
ValidCreateActionArgs,
|
|
36
|
-
ValidListActionsArgs,
|
|
37
|
-
ValidListCertificatesArgs,
|
|
38
|
-
ValidListOutputsArgs
|
|
39
|
-
} from '../../sdk/validationHelpers'
|
|
40
35
|
import { TableUser } from '../schema/tables/TableUser'
|
|
41
36
|
import { TableSyncState } from '../schema/tables/TableSyncState'
|
|
42
37
|
import { TableCertificateX } from '../schema/tables/TableCertificate'
|
|
@@ -46,6 +41,7 @@ import { TableProvenTxReq } from '../schema/tables/TableProvenTxReq'
|
|
|
46
41
|
import { EntityTimeStamp } from '../../sdk/types'
|
|
47
42
|
import { WalletError } from '../../sdk/WalletError'
|
|
48
43
|
import { WalletErrorFromJson } from '../../sdk/WalletErrorFromJson'
|
|
44
|
+
import { logWalletError } from '../../WalletLogger'
|
|
49
45
|
|
|
50
46
|
/**
|
|
51
47
|
* `StorageClient` implements the `WalletStorageProvider` interface which allows it to
|
|
@@ -94,8 +90,17 @@ export class StorageClient implements WalletStorageProvider {
|
|
|
94
90
|
* @param params The array of parameters to pass to the method in order.
|
|
95
91
|
*/
|
|
96
92
|
private async rpcCall<T>(method: string, params: unknown[]): Promise<T> {
|
|
93
|
+
let logger: WalletLoggerInterface | undefined = params[1]?.['logger']
|
|
94
|
+
|
|
97
95
|
try {
|
|
98
96
|
const id = this.nextId++
|
|
97
|
+
|
|
98
|
+
if (logger) {
|
|
99
|
+
// Replace logger object with seed json object to continue logging on request server.
|
|
100
|
+
logger.group(`StorageClient ${method}`)
|
|
101
|
+
params[1]!['logger'] = { indent: logger.indent || 0 }
|
|
102
|
+
}
|
|
103
|
+
|
|
99
104
|
const body = {
|
|
100
105
|
jsonrpc: '2.0',
|
|
101
106
|
method,
|
|
@@ -111,6 +116,7 @@ export class StorageClient implements WalletStorageProvider {
|
|
|
111
116
|
body: JSON.stringify(body)
|
|
112
117
|
})
|
|
113
118
|
} catch (eu: unknown) {
|
|
119
|
+
logWalletError(eu, logger, 'error requesting remote service')
|
|
114
120
|
throw eu
|
|
115
121
|
}
|
|
116
122
|
|
|
@@ -120,13 +126,26 @@ export class StorageClient implements WalletStorageProvider {
|
|
|
120
126
|
|
|
121
127
|
const json = await response.json()
|
|
122
128
|
if (json.error) {
|
|
129
|
+
logWalletError(json.error, logger, 'error from remote service')
|
|
123
130
|
const werr = WalletErrorFromJson(json.error)
|
|
124
131
|
throw werr
|
|
125
132
|
}
|
|
126
133
|
|
|
134
|
+
if (logger) {
|
|
135
|
+
// merge log data from request processing
|
|
136
|
+
logger.merge?.(json.result?.['log'])
|
|
137
|
+
logger.groupEnd()
|
|
138
|
+
}
|
|
139
|
+
|
|
127
140
|
return json.result
|
|
128
141
|
} catch (eu: unknown) {
|
|
142
|
+
logWalletError(eu, logger, 'error setting up request to remote service')
|
|
129
143
|
throw eu
|
|
144
|
+
} finally {
|
|
145
|
+
if (logger) {
|
|
146
|
+
// Restore original logger in params
|
|
147
|
+
params[1]!['logger'] = logger
|
|
148
|
+
}
|
|
130
149
|
}
|
|
131
150
|
}
|
|
132
151
|
|
|
@@ -227,7 +246,7 @@ export class StorageClient implements WalletStorageProvider {
|
|
|
227
246
|
* @param args Validated extension of original wallet `createAction` arguments.
|
|
228
247
|
* @returns `StorageCreateActionResults` supporting additional wallet processing to yield `createAction` results.
|
|
229
248
|
*/
|
|
230
|
-
async createAction(auth: AuthId, args: ValidCreateActionArgs): Promise<StorageCreateActionResult> {
|
|
249
|
+
async createAction(auth: AuthId, args: Validation.ValidCreateActionArgs): Promise<StorageCreateActionResult> {
|
|
231
250
|
return this.rpcCall<StorageCreateActionResult>('createAction', [auth, args])
|
|
232
251
|
}
|
|
233
252
|
|
|
@@ -307,7 +326,7 @@ export class StorageClient implements WalletStorageProvider {
|
|
|
307
326
|
* @param args Validated extension of original wallet `listActions` arguments.
|
|
308
327
|
* @returns `listActions` results.
|
|
309
328
|
*/
|
|
310
|
-
async listActions(auth: AuthId, vargs: ValidListActionsArgs): Promise<ListActionsResult> {
|
|
329
|
+
async listActions(auth: AuthId, vargs: Validation.ValidListActionsArgs): Promise<ListActionsResult> {
|
|
311
330
|
const r = await this.rpcCall<ListActionsResult>('listActions', [auth, vargs])
|
|
312
331
|
return r
|
|
313
332
|
}
|
|
@@ -319,7 +338,7 @@ export class StorageClient implements WalletStorageProvider {
|
|
|
319
338
|
* @param args Validated extension of original wallet `listOutputs` arguments.
|
|
320
339
|
* @returns `listOutputs` results.
|
|
321
340
|
*/
|
|
322
|
-
async listOutputs(auth: AuthId, vargs: ValidListOutputsArgs): Promise<ListOutputsResult> {
|
|
341
|
+
async listOutputs(auth: AuthId, vargs: Validation.ValidListOutputsArgs): Promise<ListOutputsResult> {
|
|
323
342
|
const r = await this.rpcCall<ListOutputsResult>('listOutputs', [auth, vargs])
|
|
324
343
|
return r
|
|
325
344
|
}
|
|
@@ -331,7 +350,7 @@ export class StorageClient implements WalletStorageProvider {
|
|
|
331
350
|
* @param args Validated extension of original wallet `listCertificates` arguments.
|
|
332
351
|
* @returns `listCertificates` results.
|
|
333
352
|
*/
|
|
334
|
-
async listCertificates(auth: AuthId, vargs: ValidListCertificatesArgs): Promise<ListCertificatesResult> {
|
|
353
|
+
async listCertificates(auth: AuthId, vargs: Validation.ValidListCertificatesArgs): Promise<ListCertificatesResult> {
|
|
335
354
|
const r = await this.rpcCall<ListCertificatesResult>('listCertificates', [auth, vargs])
|
|
336
355
|
return r
|
|
337
356
|
}
|