@bsv/wallet-toolbox 1.7.1 → 1.7.2
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 +7 -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/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/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/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
|
@@ -74,98 +74,102 @@ describe('WalletPermissionsManager - Regression & Integration with Underlying Wa
|
|
|
74
74
|
* ----------------------------------------------------------------------- */
|
|
75
75
|
|
|
76
76
|
it('should pass createAction calls through, label them, handle metadata encryption, and check spending authorization', async () => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
77
|
+
try {
|
|
78
|
+
// We'll mock the "netSpent" scenario to be >0 by returning some mock input & output satoshis from the signableTransaction.
|
|
79
|
+
// The underlying mock createAction returns a signableTransaction with tx = []
|
|
80
|
+
// We can stub out the mock so that the manager sees inputs/outputs with certain sat amounts.
|
|
81
|
+
// But we have to remember the manager is parsing the signableTransaction via fromAtomicBEEF(…).
|
|
82
|
+
// We'll control that by adjusting the mock signableTransaction in the underlying.
|
|
83
|
+
|
|
84
|
+
// let's set a custom signableTransaction that returns 500 sat in inputs, 1000 in outputs, and 100 in fee
|
|
85
|
+
underlying.createAction.mockResolvedValueOnce({
|
|
86
|
+
signableTransaction: {
|
|
87
|
+
// The manager calls Transaction.fromAtomicBEEF() on this
|
|
88
|
+
tx: [0xde, 0xad], // not used in detail, but let's just pass some array
|
|
89
|
+
reference: 'test-ref'
|
|
90
|
+
}
|
|
91
|
+
})
|
|
91
92
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
93
|
+
// We also need to configure the fromAtomicBEEF mock so it returns a transaction with the specified inputs/outputs
|
|
94
|
+
const mockTx = new MockTransaction()
|
|
95
|
+
mockTx.fee = 100
|
|
96
|
+
// We'll define exactly one input we consider "originator-provided" with 500 sat
|
|
97
|
+
mockTx.inputs = [
|
|
98
|
+
{
|
|
99
|
+
sourceTXID: 'aaa',
|
|
100
|
+
sourceOutputIndex: 0,
|
|
101
|
+
sourceTransaction: {
|
|
102
|
+
outputs: [{ satoshis: 500 }]
|
|
103
|
+
}
|
|
102
104
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
mockTx.outputs = [{ satoshis: 600 }, { satoshis: 400 }]
|
|
105
|
+
]
|
|
106
|
+
// We'll define 2 outputs. The manager will read the output amounts from the createAction call's "args.outputs" too,
|
|
107
|
+
// but we also set them here in case it cross-references them. We'll keep it consistent (2 outputs with total 1000).
|
|
108
|
+
mockTx.outputs = [{ satoshis: 600 }, { satoshis: 400 }]
|
|
108
109
|
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
// Now override fromAtomicBEEF to return our mockTx:
|
|
111
|
+
; (MockedBSV_SDK.Transaction.fromAtomicBEEF as jest.Mock).mockReturnValue(mockTx)
|
|
111
112
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
113
|
+
// Attempt to create an action from a non-admin origin
|
|
114
|
+
await manager.createAction(
|
|
115
|
+
{
|
|
116
|
+
description: 'User purchase',
|
|
117
|
+
inputs: [
|
|
118
|
+
{
|
|
119
|
+
outpoint: 'aaa.0',
|
|
120
|
+
unlockingScriptLength: 73,
|
|
121
|
+
inputDescription: 'My input'
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
outputs: [
|
|
125
|
+
{
|
|
126
|
+
lockingScript: '00abcd',
|
|
127
|
+
satoshis: 1000,
|
|
128
|
+
outputDescription: 'Purchase output',
|
|
129
|
+
basket: 'my-basket'
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
labels: ['user-label', 'something-else']
|
|
133
|
+
},
|
|
134
|
+
'shop.example.com'
|
|
135
|
+
)
|
|
135
136
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
137
|
+
// The manager should have:
|
|
138
|
+
// 1) Called underlying.createAction
|
|
139
|
+
// 2) Inserted "admin originator shop.example.com" & "admin month YYYY-MM" into labels
|
|
140
|
+
// 3) Encrypted the metadata fields (description, inputDescription, outputDescription)
|
|
141
|
+
// 4) Ensured we needed spending permission for netSpent= (1000 + fee100) - 500 = 600
|
|
142
|
+
// The onSpendingAuthorizationRequested callback ephemeral-granted it.
|
|
143
|
+
expect(underlying.createAction).toHaveBeenCalledTimes(1)
|
|
144
|
+
const callArgs = underlying.createAction.mock.calls[0][0]
|
|
145
|
+
expect(callArgs.labels).toContain('admin originator shop.example.com')
|
|
146
|
+
expect(callArgs.labels).toEqual(
|
|
147
|
+
expect.arrayContaining([
|
|
148
|
+
expect.stringContaining('admin month'),
|
|
149
|
+
'user-label',
|
|
150
|
+
'something-else',
|
|
151
|
+
'admin originator shop.example.com'
|
|
152
|
+
])
|
|
153
|
+
)
|
|
154
|
+
// Confirm the metadata was replaced with some ciphertext array in createAction call
|
|
155
|
+
expect(callArgs.description).not.toBe('User purchase') // manager encrypts it
|
|
156
|
+
if (callArgs.inputs[0].inputDescription) {
|
|
157
|
+
expect(callArgs.inputs[0].inputDescription).not.toBe('My input')
|
|
158
|
+
}
|
|
159
|
+
if (callArgs.outputs[0].outputDescription) {
|
|
160
|
+
expect(callArgs.outputs[0].outputDescription).not.toBe('Purchase output')
|
|
161
|
+
}
|
|
161
162
|
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
// Also confirm we set signAndProcess to false if origin is non-admin
|
|
164
|
+
expect(callArgs.options.signAndProcess).toBe(false)
|
|
164
165
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
// The manager will parse the resulting signableTransaction, see netSpent=600, and request spending permission.
|
|
167
|
+
// Our callback ephemeral-granted. So everything should proceed with no error.
|
|
168
|
+
// The manager returns the partial result from underlying
|
|
169
|
+
// We don't have a final sign call from the manager because signAndProcess is forcibly false.
|
|
170
|
+
} catch (eu) {
|
|
171
|
+
expect(true).toBe(false)
|
|
172
|
+
}
|
|
169
173
|
})
|
|
170
174
|
|
|
171
175
|
it('should abort the action if spending permission is denied', async () => {
|
package/src/sdk/WERR_errors.ts
CHANGED
|
@@ -64,7 +64,7 @@ export class WERR_INVALID_PARAMETER extends WalletError {
|
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Invalid merkleRoot ${merkleRoot} for block ${blockHash} at height ${blockHeight}${txid ? ` for txid ${txid}` : ''}.
|
|
67
|
-
*
|
|
67
|
+
*
|
|
68
68
|
* Typically thrown when a chain tracker fails to validate a merkle root.
|
|
69
69
|
*/
|
|
70
70
|
export class WERR_INVALID_MERKLE_ROOT extends WalletError {
|
|
@@ -72,9 +72,12 @@ export class WERR_INVALID_MERKLE_ROOT extends WalletError {
|
|
|
72
72
|
public blockHash: string,
|
|
73
73
|
public blockHeight: number,
|
|
74
74
|
public merkleRoot: string,
|
|
75
|
-
public txid?: string
|
|
75
|
+
public txid?: string
|
|
76
76
|
) {
|
|
77
|
-
super(
|
|
77
|
+
super(
|
|
78
|
+
'WERR_INVALID_MERKLE_ROOT',
|
|
79
|
+
`Invalid merkleRoot ${merkleRoot} for block ${blockHash} at height ${blockHeight}${txid ? ` for txid ${txid}` : ''}.`
|
|
80
|
+
)
|
|
78
81
|
}
|
|
79
82
|
override toJson(): string {
|
|
80
83
|
const obj = JSON.parse(super.toJson())
|
package/src/sdk/WalletError.ts
CHANGED
|
@@ -156,9 +156,6 @@ export class WalletError extends Error implements WalletErrorObject {
|
|
|
156
156
|
t === 'object' && error !== null && typeof (error as any).toJson === 'function'
|
|
157
157
|
? (error as any).toJson
|
|
158
158
|
: undefined
|
|
159
|
-
console.log(
|
|
160
|
-
`WalletError.unknownToJson: error type=${t} ctor=${ctor} name=${name} message=${message} hasToJson=${toJson ? 'yes' : 'no'}`
|
|
161
|
-
)
|
|
162
159
|
if (ctor && ctor.startsWith('WERR_') && toJson !== undefined) {
|
|
163
160
|
json = (error as WalletError).toJson()
|
|
164
161
|
} else if (name && message) {
|
|
@@ -168,7 +165,6 @@ export class WalletError extends Error implements WalletErrorObject {
|
|
|
168
165
|
e = new WalletError('WERR_UNKNOWN', String(error))
|
|
169
166
|
json = e.toJson()
|
|
170
167
|
}
|
|
171
|
-
console.log(`WalletError.unknownToJson: json=${json}`)
|
|
172
168
|
return json
|
|
173
169
|
}
|
|
174
170
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ArcConfig,
|
|
3
|
+
Beef,
|
|
4
|
+
Transaction as BsvTransaction,
|
|
5
|
+
ChainTracker,
|
|
6
|
+
MerklePath,
|
|
7
|
+
WalletLoggerInterface
|
|
8
|
+
} from '@bsv/sdk'
|
|
2
9
|
import { Chain, ReqHistoryNote } from './types'
|
|
3
10
|
import { WalletError } from './WalletError'
|
|
4
11
|
import { TableOutput } from '../storage/schema/tables/TableOutput'
|
|
@@ -92,7 +99,7 @@ export interface WalletServices {
|
|
|
92
99
|
* @param chain
|
|
93
100
|
* @returns
|
|
94
101
|
*/
|
|
95
|
-
postBeef(beef: Beef, txids: string[]): Promise<PostBeefResult[]>
|
|
102
|
+
postBeef(beef: Beef, txids: string[], logger?: WalletLoggerInterface): Promise<PostBeefResult[]>
|
|
96
103
|
|
|
97
104
|
/**
|
|
98
105
|
* @param script Output script to be hashed for `getUtxoStatus` default `outputFormat`
|
|
@@ -143,7 +150,11 @@ export interface WalletServices {
|
|
|
143
150
|
useNext?: boolean
|
|
144
151
|
): Promise<GetUtxoStatusResult>
|
|
145
152
|
|
|
146
|
-
getScriptHashHistory(
|
|
153
|
+
getScriptHashHistory(
|
|
154
|
+
hash: string,
|
|
155
|
+
useNext?: boolean,
|
|
156
|
+
logger?: WalletLoggerInterface
|
|
157
|
+
): Promise<GetScriptHashHistoryResult>
|
|
147
158
|
|
|
148
159
|
/**
|
|
149
160
|
* @returns a block header
|
|
@@ -13,7 +13,9 @@ import {
|
|
|
13
13
|
RelinquishCertificateArgs,
|
|
14
14
|
RelinquishOutputArgs,
|
|
15
15
|
SendWithResult,
|
|
16
|
-
TXIDHexString
|
|
16
|
+
TXIDHexString,
|
|
17
|
+
Validation,
|
|
18
|
+
WalletLoggerInterface
|
|
17
19
|
} from '@bsv/sdk'
|
|
18
20
|
import {
|
|
19
21
|
TableCertificate,
|
|
@@ -35,13 +37,6 @@ import {
|
|
|
35
37
|
TableUser
|
|
36
38
|
} from '../storage/schema/tables'
|
|
37
39
|
import { WalletServices } from './WalletServices.interfaces'
|
|
38
|
-
import {
|
|
39
|
-
ValidCreateActionArgs,
|
|
40
|
-
ValidCreateActionOutput,
|
|
41
|
-
ValidListActionsArgs,
|
|
42
|
-
ValidListCertificatesArgs,
|
|
43
|
-
ValidListOutputsArgs
|
|
44
|
-
} from './validationHelpers'
|
|
45
40
|
import { Chain, Paged, ProvenTxReqStatus, TransactionStatus } from './types'
|
|
46
41
|
import { WalletError } from './WalletError'
|
|
47
42
|
|
|
@@ -72,7 +67,7 @@ export interface WalletStorage {
|
|
|
72
67
|
findOrInsertUser(identityKey: string): Promise<{ user: TableUser; isNew: boolean }>
|
|
73
68
|
|
|
74
69
|
abortAction(args: AbortActionArgs): Promise<AbortActionResult>
|
|
75
|
-
createAction(args: ValidCreateActionArgs): Promise<StorageCreateActionResult>
|
|
70
|
+
createAction(args: Validation.ValidCreateActionArgs): Promise<StorageCreateActionResult>
|
|
76
71
|
processAction(args: StorageProcessActionArgs): Promise<StorageProcessActionResults>
|
|
77
72
|
internalizeAction(args: InternalizeActionArgs): Promise<InternalizeActionResult>
|
|
78
73
|
|
|
@@ -82,7 +77,7 @@ export interface WalletStorage {
|
|
|
82
77
|
findProvenTxReqs(args: FindProvenTxReqsArgs): Promise<TableProvenTxReq[]>
|
|
83
78
|
|
|
84
79
|
listActions(args: ListActionsArgs): Promise<ListActionsResult>
|
|
85
|
-
listCertificates(args: ValidListCertificatesArgs): Promise<ListCertificatesResult>
|
|
80
|
+
listCertificates(args: Validation.ValidListCertificatesArgs): Promise<ListCertificatesResult>
|
|
86
81
|
listOutputs(args: ListOutputsArgs): Promise<ListOutputsResult>
|
|
87
82
|
|
|
88
83
|
insertCertificate(certificate: TableCertificateX): Promise<number>
|
|
@@ -154,7 +149,7 @@ export interface WalletStorageWriter extends WalletStorageReader {
|
|
|
154
149
|
findOrInsertUser(identityKey: string): Promise<{ user: TableUser; isNew: boolean }>
|
|
155
150
|
|
|
156
151
|
abortAction(auth: AuthId, args: AbortActionArgs): Promise<AbortActionResult>
|
|
157
|
-
createAction(auth: AuthId, args: ValidCreateActionArgs): Promise<StorageCreateActionResult>
|
|
152
|
+
createAction(auth: AuthId, args: Validation.ValidCreateActionArgs): Promise<StorageCreateActionResult>
|
|
158
153
|
processAction(auth: AuthId, args: StorageProcessActionArgs): Promise<StorageProcessActionResults>
|
|
159
154
|
internalizeAction(auth: AuthId, args: InternalizeActionArgs): Promise<StorageInternalizeActionResult>
|
|
160
155
|
|
|
@@ -175,9 +170,9 @@ export interface WalletStorageReader {
|
|
|
175
170
|
findOutputsAuth(auth: AuthId, args: FindOutputsArgs): Promise<TableOutput[]>
|
|
176
171
|
findProvenTxReqs(args: FindProvenTxReqsArgs): Promise<TableProvenTxReq[]>
|
|
177
172
|
|
|
178
|
-
listActions(auth: AuthId, vargs: ValidListActionsArgs): Promise<ListActionsResult>
|
|
179
|
-
listCertificates(auth: AuthId, vargs: ValidListCertificatesArgs): Promise<ListCertificatesResult>
|
|
180
|
-
listOutputs(auth: AuthId, vargs: ValidListOutputsArgs): Promise<ListOutputsResult>
|
|
173
|
+
listActions(auth: AuthId, vargs: Validation.ValidListActionsArgs): Promise<ListActionsResult>
|
|
174
|
+
listCertificates(auth: AuthId, vargs: Validation.ValidListCertificatesArgs): Promise<ListCertificatesResult>
|
|
175
|
+
listOutputs(auth: AuthId, vargs: Validation.ValidListOutputsArgs): Promise<ListOutputsResult>
|
|
181
176
|
}
|
|
182
177
|
|
|
183
178
|
export interface AuthId {
|
|
@@ -243,7 +238,7 @@ export interface StorageCreateTransactionSdkInput {
|
|
|
243
238
|
senderIdentityKey?: string
|
|
244
239
|
}
|
|
245
240
|
|
|
246
|
-
export interface StorageCreateTransactionSdkOutput extends ValidCreateActionOutput {
|
|
241
|
+
export interface StorageCreateTransactionSdkOutput extends Validation.ValidCreateActionOutput {
|
|
247
242
|
vout: number
|
|
248
243
|
providedBy: StorageProvidedBy
|
|
249
244
|
purpose?: string
|
|
@@ -270,7 +265,7 @@ export interface StorageProcessActionArgs {
|
|
|
270
265
|
txid?: string
|
|
271
266
|
rawTx?: number[]
|
|
272
267
|
sendWith: string[]
|
|
273
|
-
|
|
268
|
+
logger?: WalletLoggerInterface
|
|
274
269
|
}
|
|
275
270
|
|
|
276
271
|
export interface StorageInternalizeActionResult extends InternalizeActionResult {
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { Utils } from '@bsv/sdk'
|
|
2
|
-
import { validateBase64String } from '../validationHelpers'
|
|
1
|
+
import { Utils, Validation as V } from '@bsv/sdk'
|
|
3
2
|
describe('validationHelpers tests', () => {
|
|
4
3
|
jest.setTimeout(99999999)
|
|
5
4
|
|
|
6
5
|
test('0 validateBase64String', async () => {
|
|
7
6
|
const validB64 = 'SGVsbG8gV29ybGQh' // "Hello World!"
|
|
8
7
|
|
|
9
|
-
const s = validateBase64String(validB64, 'testParam', 1, 20)
|
|
8
|
+
const s = V.validateBase64String(validB64, 'testParam', 1, 20)
|
|
10
9
|
expect(s).toBe(validB64)
|
|
11
10
|
|
|
12
11
|
{
|
|
13
12
|
const invalidB64 = 'SGVsbG8g29ybGQh'
|
|
14
|
-
expect(() => validateBase64String(invalidB64, 'testParam', 1, 20)).toThrow()
|
|
13
|
+
expect(() => V.validateBase64String(invalidB64, 'testParam', 1, 20)).toThrow()
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
{
|
|
18
17
|
const invalidB64 = 'SGVsbG8gV29ybGQh='
|
|
19
|
-
expect(() => validateBase64String(invalidB64, 'testParam', 1, 20)).toThrow()
|
|
18
|
+
expect(() => V.validateBase64String(invalidB64, 'testParam', 1, 20)).toThrow()
|
|
20
19
|
}
|
|
21
20
|
})
|
|
22
21
|
})
|
package/src/sdk/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ export * from './WalletErrorFromJson'
|
|
|
3
3
|
export * from './WalletSigner.interfaces'
|
|
4
4
|
export * from './WalletStorage.interfaces'
|
|
5
5
|
export * from './WERR_errors'
|
|
6
|
-
export
|
|
6
|
+
export { Validation } from '@bsv/sdk'
|
|
7
7
|
export * from './CertOpsWallet'
|
|
8
8
|
export * from './types'
|
|
9
9
|
export * from './WalletServices.interfaces'
|
package/src/services/Services.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transaction as BsvTransaction, Beef, ChainTracker, Utils } from '@bsv/sdk'
|
|
1
|
+
import { Transaction as BsvTransaction, Beef, ChainTracker, Utils, WalletLoggerInterface } from '@bsv/sdk'
|
|
2
2
|
import { ServiceCollection, ServiceToCall } from './ServiceCollection'
|
|
3
3
|
import { createDefaultWalletServicesOptions } from './createDefaultWalletServicesOptions'
|
|
4
4
|
import { WhatsOnChain } from './providers/WhatsOnChain'
|
|
@@ -216,7 +216,8 @@ export class Services implements WalletServices {
|
|
|
216
216
|
output: string,
|
|
217
217
|
outputFormat?: GetUtxoStatusOutputFormat,
|
|
218
218
|
outpoint?: string,
|
|
219
|
-
useNext?: boolean
|
|
219
|
+
useNext?: boolean,
|
|
220
|
+
logger?: WalletLoggerInterface
|
|
220
221
|
): Promise<GetUtxoStatusResult> {
|
|
221
222
|
const services = this.getUtxoStatusServices
|
|
222
223
|
if (useNext) services.next()
|
|
@@ -228,11 +229,13 @@ export class Services implements WalletServices {
|
|
|
228
229
|
details: []
|
|
229
230
|
}
|
|
230
231
|
|
|
232
|
+
logger?.group(`services getUtxoStatus`)
|
|
231
233
|
for (let retry = 0; retry < 2; retry++) {
|
|
232
234
|
for (let tries = 0; tries < services.count; tries++) {
|
|
233
235
|
const stc = services.serviceToCall
|
|
234
236
|
try {
|
|
235
237
|
const r = await stc.service(output, outputFormat, outpoint)
|
|
238
|
+
logger?.log(`${stc.providerName} status ${r.status}`)
|
|
236
239
|
if (r.status === 'success') {
|
|
237
240
|
services.addServiceCallSuccess(stc)
|
|
238
241
|
r0 = r
|
|
@@ -250,10 +253,15 @@ export class Services implements WalletServices {
|
|
|
250
253
|
if (r0.status === 'success') break
|
|
251
254
|
await wait(2000)
|
|
252
255
|
}
|
|
256
|
+
logger?.groupEnd()
|
|
253
257
|
return r0
|
|
254
258
|
}
|
|
255
259
|
|
|
256
|
-
async getScriptHashHistory(
|
|
260
|
+
async getScriptHashHistory(
|
|
261
|
+
hash: string,
|
|
262
|
+
useNext?: boolean,
|
|
263
|
+
logger?: WalletLoggerInterface
|
|
264
|
+
): Promise<GetScriptHashHistoryResult> {
|
|
257
265
|
const services = this.getScriptHashHistoryServices
|
|
258
266
|
if (useNext) services.next()
|
|
259
267
|
|
|
@@ -264,10 +272,12 @@ export class Services implements WalletServices {
|
|
|
264
272
|
history: []
|
|
265
273
|
}
|
|
266
274
|
|
|
275
|
+
logger?.group(`services getScriptHashHistory`)
|
|
267
276
|
for (let tries = 0; tries < services.count; tries++) {
|
|
268
277
|
const stc = services.serviceToCall
|
|
269
278
|
try {
|
|
270
279
|
const r = await stc.service(hash)
|
|
280
|
+
logger?.log(`${stc.providerName} status ${r.status}`)
|
|
271
281
|
if (r.status === 'success') {
|
|
272
282
|
r0 = r
|
|
273
283
|
break
|
|
@@ -281,6 +291,7 @@ export class Services implements WalletServices {
|
|
|
281
291
|
}
|
|
282
292
|
services.next()
|
|
283
293
|
}
|
|
294
|
+
logger?.groupEnd()
|
|
284
295
|
return r0
|
|
285
296
|
}
|
|
286
297
|
|
|
@@ -292,15 +303,17 @@ export class Services implements WalletServices {
|
|
|
292
303
|
* @param chain
|
|
293
304
|
* @returns
|
|
294
305
|
*/
|
|
295
|
-
async postBeef(beef: Beef, txids: string[]): Promise<PostBeefResult[]> {
|
|
306
|
+
async postBeef(beef: Beef, txids: string[], logger?: WalletLoggerInterface): Promise<PostBeefResult[]> {
|
|
296
307
|
let rs: PostBeefResult[] = []
|
|
297
308
|
const services = this.postBeefServices
|
|
298
309
|
const stcs = services.allServicesToCall
|
|
310
|
+
logger?.group(`services postBeef`)
|
|
299
311
|
switch (this.postBeefMode) {
|
|
300
312
|
case 'UntilSuccess':
|
|
301
313
|
{
|
|
302
314
|
for (const stc of stcs) {
|
|
303
315
|
const r = await callService(stc)
|
|
316
|
+
logger?.log(`${stc.providerName} status ${r.status}`)
|
|
304
317
|
rs.push(r)
|
|
305
318
|
if (r.status === 'success') break
|
|
306
319
|
if (r.txidResults && r.txidResults.every(txr => txr.serviceError)) {
|
|
@@ -321,6 +334,7 @@ export class Services implements WalletServices {
|
|
|
321
334
|
}
|
|
322
335
|
break
|
|
323
336
|
}
|
|
337
|
+
logger?.groupEnd()
|
|
324
338
|
return rs
|
|
325
339
|
|
|
326
340
|
async function callService(stc: ServiceToCall<PostBeefService>) {
|
|
@@ -423,12 +437,13 @@ export class Services implements WalletServices {
|
|
|
423
437
|
return header
|
|
424
438
|
}
|
|
425
439
|
|
|
426
|
-
async getMerklePath(txid: string, useNext?: boolean): Promise<GetMerklePathResult> {
|
|
440
|
+
async getMerklePath(txid: string, useNext?: boolean, logger?: WalletLoggerInterface): Promise<GetMerklePathResult> {
|
|
427
441
|
const services = this.getMerklePathServices
|
|
428
442
|
if (useNext) services.next()
|
|
429
443
|
|
|
430
444
|
const r0: GetMerklePathResult = { notes: [] }
|
|
431
445
|
|
|
446
|
+
logger?.group(`services getMerklePath`)
|
|
432
447
|
for (let tries = 0; tries < services.count; tries++) {
|
|
433
448
|
const stc = services.serviceToCall
|
|
434
449
|
try {
|
|
@@ -436,6 +451,7 @@ export class Services implements WalletServices {
|
|
|
436
451
|
if (r.notes) r0.notes!.push(...r.notes)
|
|
437
452
|
if (!r0.name) r0.name = r.name
|
|
438
453
|
if (r.merklePath) {
|
|
454
|
+
logger?.log(`${stc.providerName} has merklePath`)
|
|
439
455
|
// If we have a proof, call it done.
|
|
440
456
|
r0.merklePath = r.merklePath
|
|
441
457
|
r0.header = r.header
|
|
@@ -443,6 +459,8 @@ export class Services implements WalletServices {
|
|
|
443
459
|
r0.error = undefined
|
|
444
460
|
services.addServiceCallSuccess(stc)
|
|
445
461
|
break
|
|
462
|
+
} else {
|
|
463
|
+
logger?.log(`${stc.providerName} no merklePath`)
|
|
446
464
|
}
|
|
447
465
|
|
|
448
466
|
if (r.error) services.addServiceCallError(stc, r.error)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Beef, HexString, Utils, WhatsOnChainConfig } from '@bsv/sdk'
|
|
1
|
+
import { Beef, HexString, Utils, WhatsOnChainConfig, Validation } from '@bsv/sdk'
|
|
2
2
|
import { convertProofToMerklePath } from '../../utility/tscProofToMerklePath'
|
|
3
3
|
import SdkWhatsOnChain from './SdkWhatsOnChain'
|
|
4
4
|
import { Chain, ReqHistoryNote } from '../../sdk/types'
|
|
@@ -20,7 +20,6 @@ import { WalletError } from '../../sdk/WalletError'
|
|
|
20
20
|
import { doubleSha256BE, wait } from '../../utility/utilityHelpers'
|
|
21
21
|
import { asArray, asString } from '../../utility/utilityHelpers.noBuffer'
|
|
22
22
|
import { Services, validateScriptHash } from '../Services'
|
|
23
|
-
import { parseWalletOutpoint } from '../../sdk/validationHelpers'
|
|
24
23
|
|
|
25
24
|
export class WhatsOnChainNoServices extends SdkWhatsOnChain {
|
|
26
25
|
constructor(chain: Chain = 'main', config: WhatsOnChainConfig = {}) {
|
|
@@ -405,7 +404,7 @@ export class WhatsOnChainNoServices extends SdkWhatsOnChain {
|
|
|
405
404
|
})
|
|
406
405
|
}
|
|
407
406
|
if (outpoint) {
|
|
408
|
-
const { txid, vout } = parseWalletOutpoint(outpoint)
|
|
407
|
+
const { txid, vout } = Validation.parseWalletOutpoint(outpoint)
|
|
409
408
|
r.isUtxo = r.details.find(d => d.txid === txid && d.index === vout) !== undefined
|
|
410
409
|
} else r.isUtxo = r.details.length > 0
|
|
411
410
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { Beef, ListActionsResult, ListOutputsResult } from '@bsv/sdk'
|
|
1
|
+
import { Beef, ListActionsResult, ListOutputsResult, Validation } from '@bsv/sdk'
|
|
2
2
|
import {
|
|
3
3
|
TrxToken,
|
|
4
4
|
PurgeParams,
|
|
5
5
|
PurgeResults,
|
|
6
6
|
ProvenOrRawTx,
|
|
7
7
|
AuthId,
|
|
8
|
-
ValidListActionsArgs,
|
|
9
|
-
ValidListOutputsArgs,
|
|
10
8
|
FindCertificatesArgs,
|
|
11
9
|
FindOutputBasketsArgs,
|
|
12
10
|
FindOutputsArgs,
|
|
@@ -114,10 +112,10 @@ class ServicesOnlyStorageProvider extends StorageProvider {
|
|
|
114
112
|
override getTagsForOutputId(outputId: number, trx?: TrxToken): Promise<TableOutputTag[]> {
|
|
115
113
|
throw this.nip
|
|
116
114
|
}
|
|
117
|
-
override listActions(auth: AuthId, args: ValidListActionsArgs): Promise<ListActionsResult> {
|
|
115
|
+
override listActions(auth: AuthId, args: Validation.ValidListActionsArgs): Promise<ListActionsResult> {
|
|
118
116
|
throw this.nip
|
|
119
117
|
}
|
|
120
|
-
override listOutputs(auth: AuthId, args: ValidListOutputsArgs): Promise<ListOutputsResult> {
|
|
118
|
+
override listOutputs(auth: AuthId, args: Validation.ValidListOutputsArgs): Promise<ListOutputsResult> {
|
|
121
119
|
throw this.nip
|
|
122
120
|
}
|
|
123
121
|
override countChangeInputs(userId: number, basketId: number, excludeSending: boolean): Promise<number> {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { AcquireCertificateResult } from '@bsv/sdk'
|
|
1
|
+
import { AcquireCertificateResult, Validation } from '@bsv/sdk'
|
|
2
2
|
import { Wallet } from '../../Wallet'
|
|
3
3
|
import { AuthId } from '../../sdk/WalletStorage.interfaces'
|
|
4
|
-
import { ValidAcquireDirectCertificateArgs } from '../../sdk/validationHelpers'
|
|
5
4
|
import { TableCertificateX } from '../../storage/schema/tables/TableCertificate'
|
|
6
5
|
|
|
7
6
|
export async function acquireDirectCertificate(
|
|
8
7
|
wallet: Wallet,
|
|
9
8
|
auth: AuthId,
|
|
10
|
-
vargs: ValidAcquireDirectCertificateArgs
|
|
9
|
+
vargs: Validation.ValidAcquireDirectCertificateArgs
|
|
11
10
|
): Promise<AcquireCertificateResult> {
|
|
12
11
|
const now = new Date()
|
|
13
12
|
const newCert: TableCertificateX = {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { Beef, Script, Transaction, TransactionInput, TransactionOutput } from '@bsv/sdk'
|
|
1
|
+
import { Beef, Script, Transaction, TransactionInput, TransactionOutput, Validation } from '@bsv/sdk'
|
|
2
2
|
import { Wallet, PendingStorageInput } from '../../Wallet'
|
|
3
3
|
import {
|
|
4
4
|
StorageCreateActionResult,
|
|
5
5
|
StorageCreateTransactionSdkInput,
|
|
6
6
|
StorageCreateTransactionSdkOutput
|
|
7
7
|
} from '../../sdk/WalletStorage.interfaces'
|
|
8
|
-
import { validateSatoshis, ValidCreateActionArgs, ValidCreateActionInput } from '../../sdk/validationHelpers'
|
|
9
8
|
import { WERR_INVALID_PARAMETER } from '../../sdk/WERR_errors'
|
|
10
9
|
import { asBsvSdkScript, verifyTruthy } from '../../utility/utilityHelpers'
|
|
11
10
|
import { KeyPair } from '../../sdk/types'
|
|
@@ -13,7 +12,7 @@ import { ScriptTemplateBRC29 } from '../../utility/ScriptTemplateBRC29'
|
|
|
13
12
|
|
|
14
13
|
export function buildSignableTransaction(
|
|
15
14
|
dctr: StorageCreateActionResult,
|
|
16
|
-
args: ValidCreateActionArgs,
|
|
15
|
+
args: Validation.ValidCreateActionArgs,
|
|
17
16
|
wallet: Wallet
|
|
18
17
|
): {
|
|
19
18
|
tx: Transaction
|
|
@@ -78,7 +77,7 @@ export function buildSignableTransaction(
|
|
|
78
77
|
// Merge and sort INPUTS info by vin order.
|
|
79
78
|
/////////////
|
|
80
79
|
const inputs: {
|
|
81
|
-
argsInput: ValidCreateActionInput | undefined
|
|
80
|
+
argsInput: Validation.ValidCreateActionInput | undefined
|
|
82
81
|
storageInput: StorageCreateTransactionSdkInput
|
|
83
82
|
}[] = []
|
|
84
83
|
for (const storageInput of storageInputs) {
|
|
@@ -143,7 +142,7 @@ export function buildSignableTransaction(
|
|
|
143
142
|
sequence: 0xffffffff
|
|
144
143
|
}
|
|
145
144
|
tx.addInput(inputToAdd)
|
|
146
|
-
totalChangeInputs += validateSatoshis(storageInput.sourceSatoshis, 'storageInput.sourceSatoshis')
|
|
145
|
+
totalChangeInputs += Validation.validateSatoshis(storageInput.sourceSatoshis, 'storageInput.sourceSatoshis')
|
|
147
146
|
}
|
|
148
147
|
}
|
|
149
148
|
|
|
@@ -168,7 +167,7 @@ export function buildSignableTransaction(
|
|
|
168
167
|
export function makeChangeLock(
|
|
169
168
|
out: StorageCreateTransactionSdkOutput,
|
|
170
169
|
dctr: StorageCreateActionResult,
|
|
171
|
-
args: ValidCreateActionArgs,
|
|
170
|
+
args: Validation.ValidCreateActionArgs,
|
|
172
171
|
changeKeys: KeyPair,
|
|
173
172
|
wallet: Wallet
|
|
174
173
|
): Script {
|