@bsv/wallet-toolbox 1.3.3 → 1.3.4
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 +6 -0
- package/docs/client.md +97 -28
- package/docs/services.md +2 -1
- package/docs/setup.md +404 -14
- package/docs/storage.md +720 -42
- package/docs/wallet.md +97 -28
- package/out/src/Setup.d.ts +2 -69
- package/out/src/Setup.d.ts.map +1 -1
- package/out/src/Setup.js.map +1 -1
- package/out/src/SetupClient.d.ts +126 -0
- package/out/src/SetupClient.d.ts.map +1 -0
- package/out/src/SetupClient.js +220 -0
- package/out/src/SetupClient.js.map +1 -0
- package/out/src/SetupWallet.d.ts +100 -0
- package/out/src/SetupWallet.d.ts.map +1 -0
- package/out/src/{storage/schema/tables/Certificate.js → SetupWallet.js} +1 -1
- package/out/src/SetupWallet.js.map +1 -0
- package/out/src/index.all.d.ts +2 -0
- package/out/src/index.all.d.ts.map +1 -1
- package/out/src/index.all.js +2 -0
- package/out/src/index.all.js.map +1 -1
- package/out/src/index.client.d.ts +1 -0
- package/out/src/index.client.d.ts.map +1 -1
- package/out/src/index.client.js +1 -0
- package/out/src/index.client.js.map +1 -1
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js +4 -0
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/MonitorDaemon.d.ts.map +1 -1
- package/out/src/monitor/MonitorDaemon.js +0 -3
- package/out/src/monitor/MonitorDaemon.js.map +1 -1
- package/out/src/monitor/tasks/TaskUnFail.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskUnFail.js +1 -2
- package/out/src/monitor/tasks/TaskUnFail.js.map +1 -1
- package/out/src/sdk/WalletServices.interfaces.d.ts +1 -1
- package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
- package/out/src/services/__tests/postBeef.test.js +1 -1
- package/out/src/services/__tests/postBeef.test.js.map +1 -1
- package/out/src/storage/StorageIdb.d.ts +203 -0
- package/out/src/storage/StorageIdb.d.ts.map +1 -0
- package/out/src/storage/StorageIdb.js +2289 -0
- package/out/src/storage/StorageIdb.js.map +1 -0
- package/out/src/storage/StorageKnex.d.ts +6 -6
- package/out/src/storage/StorageKnex.d.ts.map +1 -1
- package/out/src/storage/StorageKnex.js +9 -29
- package/out/src/storage/StorageKnex.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +3 -1
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +22 -0
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/StorageReader.d.ts +1 -1
- package/out/src/storage/StorageReader.d.ts.map +1 -1
- package/out/src/storage/StorageReader.js +5 -0
- package/out/src/storage/StorageReader.js.map +1 -1
- package/out/src/storage/__test/StorageIdb.test.d.ts +2 -0
- package/out/src/storage/__test/StorageIdb.test.d.ts.map +1 -0
- package/out/src/storage/__test/StorageIdb.test.js +16 -0
- package/out/src/storage/__test/StorageIdb.test.js.map +1 -0
- package/out/src/storage/methods/ListActionsSpecOp.d.ts +16 -0
- package/out/src/storage/methods/ListActionsSpecOp.d.ts.map +1 -0
- package/out/src/storage/methods/ListActionsSpecOp.js +40 -0
- package/out/src/storage/methods/ListActionsSpecOp.js.map +1 -0
- package/out/src/storage/methods/ListOutputsSpecOp.d.ts +26 -0
- package/out/src/storage/methods/ListOutputsSpecOp.d.ts.map +1 -0
- package/out/src/storage/methods/ListOutputsSpecOp.js +71 -0
- package/out/src/storage/methods/ListOutputsSpecOp.js.map +1 -0
- package/out/src/storage/methods/listActionsIdb.d.ts +5 -0
- package/out/src/storage/methods/listActionsIdb.d.ts.map +1 -0
- package/out/src/storage/methods/listActionsIdb.js +155 -0
- package/out/src/storage/methods/listActionsIdb.js.map +1 -0
- package/out/src/storage/methods/{listActions.d.ts → listActionsKnex.d.ts} +1 -1
- package/out/src/storage/methods/listActionsKnex.d.ts.map +1 -0
- package/out/src/storage/methods/{listActions.js → listActionsKnex.js} +3 -34
- package/out/src/storage/methods/listActionsKnex.js.map +1 -0
- package/out/src/storage/methods/listOutputsIdb.d.ts +5 -0
- package/out/src/storage/methods/listOutputsIdb.d.ts.map +1 -0
- package/out/src/storage/methods/listOutputsIdb.js +181 -0
- package/out/src/storage/methods/listOutputsIdb.js.map +1 -0
- package/out/src/storage/methods/{listOutputs.d.ts → listOutputsKnex.d.ts} +1 -1
- package/out/src/storage/methods/listOutputsKnex.d.ts.map +1 -0
- package/out/src/storage/methods/{listOutputs.js → listOutputsKnex.js} +7 -76
- package/out/src/storage/methods/listOutputsKnex.js.map +1 -0
- package/out/src/storage/methods/purgeDataIdb.d.ts +4 -0
- package/out/src/storage/methods/purgeDataIdb.d.ts.map +1 -0
- package/out/src/storage/methods/purgeDataIdb.js +9 -0
- package/out/src/storage/methods/purgeDataIdb.js.map +1 -0
- package/out/src/storage/methods/reviewStatus.d.ts +11 -0
- package/out/src/storage/methods/reviewStatus.d.ts.map +1 -1
- package/out/src/storage/methods/reviewStatus.js +11 -0
- package/out/src/storage/methods/reviewStatus.js.map +1 -1
- package/out/src/storage/methods/reviewStatusIdb.d.ts +20 -0
- package/out/src/storage/methods/reviewStatusIdb.d.ts.map +1 -0
- package/out/src/storage/methods/reviewStatusIdb.js +35 -0
- package/out/src/storage/methods/reviewStatusIdb.js.map +1 -0
- package/out/src/storage/schema/StorageIdbSchema.d.ts +133 -0
- package/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -0
- package/out/src/storage/schema/{tables/CertificateField.js → StorageIdbSchema.js} +1 -1
- package/out/src/storage/schema/StorageIdbSchema.js.map +1 -0
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js +1 -1
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js.map +1 -1
- package/out/src/storage/schema/tables/{Certificate.d.ts → TableCertificate.d.ts} +1 -1
- package/out/src/storage/schema/tables/TableCertificate.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableCertificate.js +3 -0
- package/out/src/storage/schema/tables/TableCertificate.js.map +1 -0
- package/out/src/storage/schema/tables/{CertificateField.d.ts → TableCertificateField.d.ts} +1 -1
- package/out/src/storage/schema/tables/TableCertificateField.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableCertificateField.js +3 -0
- package/out/src/storage/schema/tables/TableCertificateField.js.map +1 -0
- package/out/src/storage/schema/tables/{Commission.d.ts → TableCommission.d.ts} +1 -1
- package/out/src/storage/schema/tables/TableCommission.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableCommission.js +3 -0
- package/out/src/storage/schema/tables/TableCommission.js.map +1 -0
- package/out/src/storage/schema/tables/{MonitorEvent.d.ts → TableMonitorEvent.d.ts} +1 -1
- package/out/src/storage/schema/tables/TableMonitorEvent.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableMonitorEvent.js +3 -0
- package/out/src/storage/schema/tables/TableMonitorEvent.js.map +1 -0
- package/out/src/storage/schema/tables/{Output.d.ts → TableOutput.d.ts} +1 -1
- package/out/src/storage/schema/tables/TableOutput.d.ts.map +1 -0
- package/out/src/storage/schema/tables/{Output.js → TableOutput.js} +1 -1
- package/out/src/storage/schema/tables/TableOutput.js.map +1 -0
- package/out/src/storage/schema/tables/{OutputBasket.d.ts → TableOutputBasket.d.ts} +1 -1
- package/out/src/storage/schema/tables/TableOutputBasket.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableOutputBasket.js +3 -0
- package/out/src/storage/schema/tables/TableOutputBasket.js.map +1 -0
- package/out/src/storage/schema/tables/{OutputTag.d.ts → TableOutputTag.d.ts} +1 -1
- package/out/src/storage/schema/tables/TableOutputTag.d.ts.map +1 -0
- package/out/src/storage/schema/tables/{MonitorEvent.js → TableOutputTag.js} +1 -1
- package/out/src/storage/schema/tables/TableOutputTag.js.map +1 -0
- package/out/src/storage/schema/tables/{OutputTagMap.d.ts → TableOutputTagMap.d.ts} +1 -1
- package/out/src/storage/schema/tables/TableOutputTagMap.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableOutputTagMap.js +3 -0
- package/out/src/storage/schema/tables/TableOutputTagMap.js.map +1 -0
- package/out/src/storage/schema/tables/{ProvenTx.d.ts → TableProvenTx.d.ts} +1 -1
- package/out/src/storage/schema/tables/TableProvenTx.d.ts.map +1 -0
- package/out/src/storage/schema/tables/{Commission.js → TableProvenTx.js} +1 -1
- package/out/src/storage/schema/tables/TableProvenTx.js.map +1 -0
- package/out/src/storage/schema/tables/{ProvenTxReq.d.ts → TableProvenTxReq.d.ts} +1 -1
- package/out/src/storage/schema/tables/TableProvenTxReq.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableProvenTxReq.js +3 -0
- package/out/src/storage/schema/tables/TableProvenTxReq.js.map +1 -0
- package/out/src/storage/schema/tables/TableSettings.d.ts +1 -1
- package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -1
- package/out/src/storage/schema/tables/{SyncState.d.ts → TableSyncState.d.ts} +1 -1
- package/out/src/storage/schema/tables/TableSyncState.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableSyncState.js +3 -0
- package/out/src/storage/schema/tables/TableSyncState.js.map +1 -0
- package/out/src/storage/schema/tables/{Transaction.d.ts → TableTransaction.d.ts} +1 -1
- package/out/src/storage/schema/tables/TableTransaction.d.ts.map +1 -0
- package/out/src/storage/schema/tables/{Transaction.js → TableTransaction.js} +1 -1
- package/out/src/storage/schema/tables/TableTransaction.js.map +1 -0
- package/out/src/storage/schema/tables/{TxLabel.d.ts → TableTxLabel.d.ts} +1 -1
- package/out/src/storage/schema/tables/TableTxLabel.d.ts.map +1 -0
- package/out/src/storage/schema/tables/{OutputBasket.js → TableTxLabel.js} +1 -1
- package/out/src/storage/schema/tables/TableTxLabel.js.map +1 -0
- package/out/src/storage/schema/tables/{TxLabelMap.d.ts → TableTxLabelMap.d.ts} +1 -1
- package/out/src/storage/schema/tables/TableTxLabelMap.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableTxLabelMap.js +3 -0
- package/out/src/storage/schema/tables/TableTxLabelMap.js.map +1 -0
- package/out/src/storage/schema/tables/{User.d.ts → TableUser.d.ts} +1 -1
- package/out/src/storage/schema/tables/TableUser.d.ts.map +1 -0
- package/out/src/storage/schema/tables/{SyncState.js → TableUser.js} +1 -1
- package/out/src/storage/schema/tables/TableUser.js.map +1 -0
- package/out/src/storage/schema/tables/index.d.ts +15 -15
- package/out/src/storage/schema/tables/index.d.ts.map +1 -1
- package/out/src/storage/schema/tables/index.js +15 -15
- package/out/src/storage/schema/tables/index.js.map +1 -1
- package/out/test/Wallet/local/localWallet2.man.test.js +4 -0
- package/out/test/Wallet/local/localWallet2.man.test.js.map +1 -1
- package/out/test/Wallet/support/operations.man.test.d.ts +2 -0
- package/out/test/Wallet/support/operations.man.test.d.ts.map +1 -0
- package/out/test/Wallet/support/{opers1.man.test.js → operations.man.test.js} +39 -4
- package/out/test/Wallet/support/operations.man.test.js.map +1 -0
- package/out/test/storage/find.test.js +1 -1
- package/out/test/storage/find.test.js.map +1 -1
- package/out/test/storage/idb/allocateChange.test.d.ts +2 -0
- package/out/test/storage/idb/allocateChange.test.d.ts.map +1 -0
- package/out/test/storage/idb/allocateChange.test.js +110 -0
- package/out/test/storage/idb/allocateChange.test.js.map +1 -0
- package/out/test/storage/idb/count.test.d.ts +2 -0
- package/out/test/storage/idb/count.test.d.ts.map +1 -0
- package/out/test/storage/idb/count.test.js +129 -0
- package/out/test/storage/idb/count.test.js.map +1 -0
- package/out/test/storage/idb/find.test.d.ts +2 -0
- package/out/test/storage/idb/find.test.d.ts.map +1 -0
- package/out/test/storage/idb/find.test.js +131 -0
- package/out/test/storage/idb/find.test.js.map +1 -0
- package/out/test/storage/idb/idbSpeed.test.d.ts +2 -0
- package/out/test/storage/idb/idbSpeed.test.d.ts.map +1 -0
- package/out/test/storage/idb/idbSpeed.test.js +29 -0
- package/out/test/storage/idb/idbSpeed.test.js.map +1 -0
- package/out/test/storage/idb/insert.test.d.ts +2 -0
- package/out/test/storage/idb/insert.test.d.ts.map +1 -0
- package/out/test/storage/idb/insert.test.js +242 -0
- package/out/test/storage/idb/insert.test.js.map +1 -0
- package/out/test/storage/idb/transactionAbort.test.d.ts +2 -0
- package/out/test/storage/idb/transactionAbort.test.d.ts.map +1 -0
- package/out/test/storage/idb/transactionAbort.test.js +97 -0
- package/out/test/storage/idb/transactionAbort.test.js.map +1 -0
- package/out/test/storage/idb/update.test.d.ts +2 -0
- package/out/test/storage/idb/update.test.d.ts.map +1 -0
- package/out/test/storage/idb/update.test.js +902 -0
- package/out/test/storage/idb/update.test.js.map +1 -0
- package/out/test/storage/update.test.js +2 -2
- package/out/test/storage/update.test.js.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts +24 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.js +147 -3
- package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
- package/out/test/wallet/list/listActions.test.d.ts +1 -1
- package/out/test/wallet/list/listActions.test.d.ts.map +1 -1
- package/out/test/wallet/list/listActions.test.js +9 -3
- package/out/test/wallet/list/listActions.test.js.map +1 -1
- package/out/test/wallet/list/listOutputs.test.d.ts +1 -1
- package/out/test/wallet/list/listOutputs.test.d.ts.map +1 -1
- package/out/test/wallet/list/listOutputs.test.js +34 -219
- package/out/test/wallet/list/listOutputs.test.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +3 -1
- package/src/Setup.ts +1 -71
- package/src/SetupClient.ts +312 -0
- package/src/SetupWallet.ts +105 -0
- package/src/index.all.ts +2 -0
- package/src/index.client.ts +1 -0
- package/src/monitor/Monitor.ts +4 -0
- package/src/monitor/MonitorDaemon.ts +0 -1
- package/src/monitor/tasks/TaskUnFail.ts +3 -4
- package/src/sdk/WalletServices.interfaces.ts +1 -2
- package/src/services/__tests/postBeef.test.ts +1 -1
- package/src/storage/StorageIdb.ts +2298 -0
- package/src/storage/StorageKnex.ts +7 -32
- package/src/storage/StorageProvider.ts +28 -0
- package/src/storage/StorageReader.ts +5 -1
- package/src/storage/__test/StorageIdb.test.ts +15 -0
- package/src/storage/methods/ListActionsSpecOp.ts +68 -0
- package/src/storage/methods/ListOutputsSpecOp.ts +125 -0
- package/src/storage/methods/listActionsIdb.ts +181 -0
- package/src/storage/methods/{listActions.ts → listActionsKnex.ts} +2 -64
- package/src/storage/methods/listOutputsIdb.ts +199 -0
- package/src/storage/methods/{listOutputs.ts → listOutputsKnex.ts} +9 -133
- package/src/storage/methods/purgeDataIdb.ts +15 -0
- package/src/storage/methods/reviewStatus.ts +11 -0
- package/src/storage/methods/reviewStatusIdb.ts +43 -0
- package/src/storage/schema/StorageIdbSchema.ts +150 -0
- package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +1 -1
- package/src/storage/schema/tables/TableSettings.ts +1 -1
- package/src/storage/schema/tables/index.ts +15 -15
- package/test/Wallet/local/localWallet2.man.test.ts +5 -0
- package/test/Wallet/support/{opers1.man.test.ts → operations.man.test.ts} +41 -12
- package/test/storage/find.test.ts +1 -1
- package/test/storage/idb/allocateChange.test.ts +251 -0
- package/test/storage/idb/count.test.ts +158 -0
- package/test/storage/idb/find.test.ts +177 -0
- package/test/storage/idb/idbSpeed.test.ts +34 -0
- package/test/storage/idb/insert.test.ts +268 -0
- package/test/storage/idb/transactionAbort.test.ts +108 -0
- package/test/storage/idb/update.test.ts +1000 -0
- package/test/storage/update.test.ts +2 -2
- package/test/utils/TestUtilsWalletStorage.ts +188 -4
- package/test/wallet/list/listActions.test.ts +15 -5
- package/test/wallet/list/listOutputs.test.ts +29 -214
- package/out/src/storage/methods/listActions.d.ts.map +0 -1
- package/out/src/storage/methods/listActions.js.map +0 -1
- package/out/src/storage/methods/listOutputs.d.ts.map +0 -1
- package/out/src/storage/methods/listOutputs.js.map +0 -1
- package/out/src/storage/schema/tables/Certificate.d.ts.map +0 -1
- package/out/src/storage/schema/tables/Certificate.js.map +0 -1
- package/out/src/storage/schema/tables/CertificateField.d.ts.map +0 -1
- package/out/src/storage/schema/tables/CertificateField.js.map +0 -1
- package/out/src/storage/schema/tables/Commission.d.ts.map +0 -1
- package/out/src/storage/schema/tables/Commission.js.map +0 -1
- package/out/src/storage/schema/tables/MonitorEvent.d.ts.map +0 -1
- package/out/src/storage/schema/tables/MonitorEvent.js.map +0 -1
- package/out/src/storage/schema/tables/Output.d.ts.map +0 -1
- package/out/src/storage/schema/tables/Output.js.map +0 -1
- package/out/src/storage/schema/tables/OutputBasket.d.ts.map +0 -1
- package/out/src/storage/schema/tables/OutputBasket.js.map +0 -1
- package/out/src/storage/schema/tables/OutputTag.d.ts.map +0 -1
- package/out/src/storage/schema/tables/OutputTag.js +0 -3
- package/out/src/storage/schema/tables/OutputTag.js.map +0 -1
- package/out/src/storage/schema/tables/OutputTagMap.d.ts.map +0 -1
- package/out/src/storage/schema/tables/OutputTagMap.js +0 -3
- package/out/src/storage/schema/tables/OutputTagMap.js.map +0 -1
- package/out/src/storage/schema/tables/ProvenTx.d.ts.map +0 -1
- package/out/src/storage/schema/tables/ProvenTx.js +0 -3
- package/out/src/storage/schema/tables/ProvenTx.js.map +0 -1
- package/out/src/storage/schema/tables/ProvenTxReq.d.ts.map +0 -1
- package/out/src/storage/schema/tables/ProvenTxReq.js +0 -3
- package/out/src/storage/schema/tables/ProvenTxReq.js.map +0 -1
- package/out/src/storage/schema/tables/SyncState.d.ts.map +0 -1
- package/out/src/storage/schema/tables/SyncState.js.map +0 -1
- package/out/src/storage/schema/tables/Transaction.d.ts.map +0 -1
- package/out/src/storage/schema/tables/Transaction.js.map +0 -1
- package/out/src/storage/schema/tables/TxLabel.d.ts.map +0 -1
- package/out/src/storage/schema/tables/TxLabel.js +0 -3
- package/out/src/storage/schema/tables/TxLabel.js.map +0 -1
- package/out/src/storage/schema/tables/TxLabelMap.d.ts.map +0 -1
- package/out/src/storage/schema/tables/TxLabelMap.js +0 -3
- package/out/src/storage/schema/tables/TxLabelMap.js.map +0 -1
- package/out/src/storage/schema/tables/User.d.ts.map +0 -1
- package/out/src/storage/schema/tables/User.js +0 -3
- package/out/src/storage/schema/tables/User.js.map +0 -1
- package/out/test/Wallet/support/opers1.man.test.d.ts +0 -2
- package/out/test/Wallet/support/opers1.man.test.d.ts.map +0 -1
- package/out/test/Wallet/support/opers1.man.test.js.map +0 -1
- package/unlock-migrations.sh +0 -41
- /package/src/storage/schema/tables/{Certificate.ts → TableCertificate.ts} +0 -0
- /package/src/storage/schema/tables/{CertificateField.ts → TableCertificateField.ts} +0 -0
- /package/src/storage/schema/tables/{Commission.ts → TableCommission.ts} +0 -0
- /package/src/storage/schema/tables/{MonitorEvent.ts → TableMonitorEvent.ts} +0 -0
- /package/src/storage/schema/tables/{Output.ts → TableOutput.ts} +0 -0
- /package/src/storage/schema/tables/{OutputBasket.ts → TableOutputBasket.ts} +0 -0
- /package/src/storage/schema/tables/{OutputTag.ts → TableOutputTag.ts} +0 -0
- /package/src/storage/schema/tables/{OutputTagMap.ts → TableOutputTagMap.ts} +0 -0
- /package/src/storage/schema/tables/{ProvenTx.ts → TableProvenTx.ts} +0 -0
- /package/src/storage/schema/tables/{ProvenTxReq.ts → TableProvenTxReq.ts} +0 -0
- /package/src/storage/schema/tables/{SyncState.ts → TableSyncState.ts} +0 -0
- /package/src/storage/schema/tables/{Transaction.ts → TableTransaction.ts} +0 -0
- /package/src/storage/schema/tables/{TxLabel.ts → TableTxLabel.ts} +0 -0
- /package/src/storage/schema/tables/{TxLabelMap.ts → TableTxLabelMap.ts} +0 -0
- /package/src/storage/schema/tables/{User.ts → TableUser.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsv/wallet-toolbox",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "BRC100 conforming wallet, wallet storage and wallet signer components",
|
|
5
5
|
"main": "./out/src/index.js",
|
|
6
6
|
"types": "./out/src/index.d.ts",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"@bsv/payment-express-middleware": "^1.0.6",
|
|
35
35
|
"@bsv/sdk": "^1.4.20",
|
|
36
36
|
"express": "^4.21.2",
|
|
37
|
+
"idb": "^8.0.2",
|
|
37
38
|
"knex": "^3.1.0",
|
|
38
39
|
"mysql2": "^3.12.0",
|
|
39
40
|
"sqlite3": "^5.1.7"
|
|
@@ -46,6 +47,7 @@
|
|
|
46
47
|
"@types/node": "^20.8.2",
|
|
47
48
|
"chalk": "^4.1.2",
|
|
48
49
|
"dotenv": "^16.4.7",
|
|
50
|
+
"fake-indexeddb": "^6.0.0",
|
|
49
51
|
"fs-extra": "^11.2.0",
|
|
50
52
|
"jest": "^29.7.0",
|
|
51
53
|
"jest-diff": "^29.7.0",
|
package/src/Setup.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KeyPairAddress, SetupWallet, SetupWalletClient } from './SetupWallet'
|
|
1
2
|
import {
|
|
2
3
|
BEEF,
|
|
3
4
|
CreateActionArgs,
|
|
@@ -513,15 +514,6 @@ export interface SetupWalletKnex extends SetupWallet {
|
|
|
513
514
|
wallet: Wallet
|
|
514
515
|
}
|
|
515
516
|
|
|
516
|
-
/**
|
|
517
|
-
* A private key and associated public key and address.
|
|
518
|
-
*/
|
|
519
|
-
export interface KeyPairAddress {
|
|
520
|
-
privateKey: PrivateKey
|
|
521
|
-
publicKey: PublicKey
|
|
522
|
-
address: string
|
|
523
|
-
}
|
|
524
|
-
|
|
525
517
|
/**
|
|
526
518
|
* `SetupEnv` provides a starting point for managing secrets that
|
|
527
519
|
* must not appear in source code.
|
|
@@ -561,56 +553,6 @@ export interface SetupEnv {
|
|
|
561
553
|
mySQLConnection: string
|
|
562
554
|
}
|
|
563
555
|
|
|
564
|
-
/**
|
|
565
|
-
* When creating a BRC-100 compatible `Wallet`, many components come into play.
|
|
566
|
-
*
|
|
567
|
-
* All of the `createWallet` functions in the `Setup` and `SetupClient` classes return
|
|
568
|
-
* an object with direct access to each component to facilitate experimentation, testing
|
|
569
|
-
* and customization.
|
|
570
|
-
*/
|
|
571
|
-
export interface SetupWallet {
|
|
572
|
-
/**
|
|
573
|
-
* The rootKey of the `KeyDeriver`. The private key from which other keys are derived.
|
|
574
|
-
*/
|
|
575
|
-
rootKey: PrivateKey
|
|
576
|
-
/**
|
|
577
|
-
* The pubilc key associated with the `rootKey` which also serves as the wallet's identity.
|
|
578
|
-
*/
|
|
579
|
-
identityKey: string
|
|
580
|
-
/**
|
|
581
|
-
* The `KeyDeriver` component used by the wallet for key derivation and cryptographic functions.
|
|
582
|
-
*/
|
|
583
|
-
keyDeriver: KeyDeriver
|
|
584
|
-
/**
|
|
585
|
-
* The chain ('main' or 'test') which the wallet accesses.
|
|
586
|
-
*/
|
|
587
|
-
chain: sdk.Chain
|
|
588
|
-
/**
|
|
589
|
-
* The `WalletStorageManager` that manages all the configured storage providers (active and backups)
|
|
590
|
-
* accessed by the wallet.
|
|
591
|
-
*/
|
|
592
|
-
storage: WalletStorageManager
|
|
593
|
-
/**
|
|
594
|
-
* The network `Services` component which provides the wallet with access to external services hosted
|
|
595
|
-
* on the public network.
|
|
596
|
-
*/
|
|
597
|
-
services: Services
|
|
598
|
-
/**
|
|
599
|
-
* The background task `Monitor` component available to the wallet to offload tasks
|
|
600
|
-
* that speed up wallet operations and maintain data integrity.
|
|
601
|
-
*/
|
|
602
|
-
monitor: Monitor
|
|
603
|
-
/**
|
|
604
|
-
* The actual BRC-100 `Wallet` to which all the other properties and components contribute.
|
|
605
|
-
*
|
|
606
|
-
* Note that internally, the wallet is itself linked to all these properties and components.
|
|
607
|
-
* They are included in this interface to facilitate access after wallet construction for
|
|
608
|
-
* experimentation, testing and customization. Any changes made to the configuration of these
|
|
609
|
-
* components after construction may disrupt the normal operation of the wallet.
|
|
610
|
-
*/
|
|
611
|
-
wallet: Wallet
|
|
612
|
-
}
|
|
613
|
-
|
|
614
556
|
/**
|
|
615
557
|
* Extension `SetupWalletClientArgs` of `SetupWalletArgs` is used by `createWalletClient`
|
|
616
558
|
* to construct a `SetupWalletClient`.
|
|
@@ -623,15 +565,3 @@ export interface SetupWalletClientArgs extends SetupWalletArgs {
|
|
|
623
565
|
*/
|
|
624
566
|
endpointUrl?: string
|
|
625
567
|
}
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* Extension `SetupWalletClient` of `SetupWallet` is returned by `createWalletClient`
|
|
629
|
-
*/
|
|
630
|
-
export interface SetupWalletClient extends SetupWallet {
|
|
631
|
-
/**
|
|
632
|
-
* The endpoint URL of the service hosting the `StorageServer` JSON-RPC service to
|
|
633
|
-
* which a `StorageClient` instance is connected to function as
|
|
634
|
-
* the active storage provider of the wallet.
|
|
635
|
-
*/
|
|
636
|
-
endpointUrl: string
|
|
637
|
-
}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BEEF,
|
|
3
|
+
CreateActionArgs,
|
|
4
|
+
CreateActionOptions,
|
|
5
|
+
CreateActionOutput,
|
|
6
|
+
CreateActionResult,
|
|
7
|
+
KeyDeriver,
|
|
8
|
+
LockingScript,
|
|
9
|
+
P2PKH,
|
|
10
|
+
PrivateKey,
|
|
11
|
+
PublicKey,
|
|
12
|
+
WalletInterface
|
|
13
|
+
} from '@bsv/sdk'
|
|
14
|
+
import { Monitor, randomBytesHex, sdk, Services, StorageClient, Wallet, WalletStorageManager } from './index.client'
|
|
15
|
+
import { KeyPairAddress, SetupClientWalletArgs, SetupWallet, SetupWalletClient } from './SetupWallet'
|
|
16
|
+
import { StorageIdb } from './storage/StorageIdb'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The 'Setup` class provides static setup functions to construct BRC-100 compatible
|
|
20
|
+
* wallets in a variety of configurations.
|
|
21
|
+
*
|
|
22
|
+
* It serves as a starting point for experimentation and customization.
|
|
23
|
+
*/
|
|
24
|
+
export abstract class SetupClient {
|
|
25
|
+
/**
|
|
26
|
+
* Create a `Wallet`. Storage can optionally be provided or configured later.
|
|
27
|
+
*
|
|
28
|
+
* The following components are configured: KeyDeriver, WalletStorageManager, WalletService, WalletStorage.
|
|
29
|
+
* Optionally, PrivilegedKeyManager is also configured.
|
|
30
|
+
*
|
|
31
|
+
* @publicbody
|
|
32
|
+
*/
|
|
33
|
+
static async createWallet(args: SetupClientWalletArgs): Promise<SetupWallet> {
|
|
34
|
+
const chain = args.chain
|
|
35
|
+
const rootKey = PrivateKey.fromHex(args.rootKeyHex)
|
|
36
|
+
const identityKey = rootKey.toPublicKey().toString()
|
|
37
|
+
const keyDeriver = new KeyDeriver(rootKey)
|
|
38
|
+
const storage = new WalletStorageManager(identityKey, args.active, args.backups)
|
|
39
|
+
if (storage.canMakeAvailable()) await storage.makeAvailable()
|
|
40
|
+
const serviceOptions = Services.createDefaultOptions(chain)
|
|
41
|
+
serviceOptions.taalApiKey = args.taalApiKey
|
|
42
|
+
const services = new Services(serviceOptions)
|
|
43
|
+
const monopts = Monitor.createDefaultWalletMonitorOptions(chain, storage, services)
|
|
44
|
+
const monitor = new Monitor(monopts)
|
|
45
|
+
monitor.addDefaultTasks()
|
|
46
|
+
const privilegedKeyManager = args.privilegedKeyGetter
|
|
47
|
+
? new sdk.PrivilegedKeyManager(args.privilegedKeyGetter)
|
|
48
|
+
: undefined
|
|
49
|
+
const wallet = new Wallet({
|
|
50
|
+
chain,
|
|
51
|
+
keyDeriver,
|
|
52
|
+
storage,
|
|
53
|
+
services,
|
|
54
|
+
monitor,
|
|
55
|
+
privilegedKeyManager
|
|
56
|
+
})
|
|
57
|
+
const r: SetupWallet = {
|
|
58
|
+
rootKey,
|
|
59
|
+
identityKey,
|
|
60
|
+
keyDeriver,
|
|
61
|
+
chain,
|
|
62
|
+
storage,
|
|
63
|
+
services,
|
|
64
|
+
monitor,
|
|
65
|
+
wallet
|
|
66
|
+
}
|
|
67
|
+
return r
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Setup a new `Wallet` without requiring a .env file.
|
|
72
|
+
*
|
|
73
|
+
* @param args.chain - 'main' or 'test'
|
|
74
|
+
* @param args.rootKeyHex - Root private key for wallet's key deriver.
|
|
75
|
+
* @param args.storageUrl - Optional. `StorageClient` and `chain` compatible endpoint URL.
|
|
76
|
+
* @param args.privilegedKeyGetter - Optional. Method that will return the privileged `PrivateKey`, on demand.
|
|
77
|
+
*/
|
|
78
|
+
static async createWalletClientNoEnv(args: {
|
|
79
|
+
chain: sdk.Chain
|
|
80
|
+
rootKeyHex: string
|
|
81
|
+
storageUrl?: string
|
|
82
|
+
privilegedKeyGetter?: () => Promise<PrivateKey>
|
|
83
|
+
}): Promise<Wallet> {
|
|
84
|
+
const chain = args.chain
|
|
85
|
+
const endpointUrl = args.storageUrl || `https://${args.chain !== 'main' ? 'staging-' : ''}storage.babbage.systems`
|
|
86
|
+
const rootKey = PrivateKey.fromHex(args.rootKeyHex)
|
|
87
|
+
const keyDeriver = new KeyDeriver(rootKey)
|
|
88
|
+
const storage = new WalletStorageManager(keyDeriver.identityKey)
|
|
89
|
+
const services = new Services(chain)
|
|
90
|
+
const privilegedKeyManager = args.privilegedKeyGetter
|
|
91
|
+
? new sdk.PrivilegedKeyManager(args.privilegedKeyGetter)
|
|
92
|
+
: undefined
|
|
93
|
+
const wallet = new Wallet({
|
|
94
|
+
chain,
|
|
95
|
+
keyDeriver,
|
|
96
|
+
storage,
|
|
97
|
+
services,
|
|
98
|
+
privilegedKeyManager
|
|
99
|
+
})
|
|
100
|
+
const client = new StorageClient(wallet, endpointUrl)
|
|
101
|
+
await storage.addWalletStorageProvider(client)
|
|
102
|
+
await storage.makeAvailable()
|
|
103
|
+
return wallet
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @publicbody
|
|
108
|
+
*/
|
|
109
|
+
static async createWalletClient(args: SetupClientWalletClientArgs): Promise<SetupWalletClient> {
|
|
110
|
+
const wo = await SetupClient.createWallet(args)
|
|
111
|
+
|
|
112
|
+
const endpointUrl = args.endpointUrl || `https://${args.chain !== 'main' ? 'staging-' : ''}storage.babbage.systems`
|
|
113
|
+
|
|
114
|
+
const client = new StorageClient(wo.wallet, endpointUrl)
|
|
115
|
+
await wo.storage.addWalletStorageProvider(client)
|
|
116
|
+
await wo.storage.makeAvailable()
|
|
117
|
+
return {
|
|
118
|
+
...wo,
|
|
119
|
+
endpointUrl
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @publicbody
|
|
125
|
+
*/
|
|
126
|
+
static getKeyPair(priv?: string | PrivateKey): KeyPairAddress {
|
|
127
|
+
if (priv === undefined) priv = PrivateKey.fromRandom()
|
|
128
|
+
else if (typeof priv === 'string') priv = new PrivateKey(priv, 'hex')
|
|
129
|
+
|
|
130
|
+
const pub = PublicKey.fromPrivateKey(priv)
|
|
131
|
+
const address = pub.toAddress()
|
|
132
|
+
return { privateKey: priv, publicKey: pub, address }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @publicbody
|
|
137
|
+
*/
|
|
138
|
+
static getLockP2PKH(address: string): LockingScript {
|
|
139
|
+
const p2pkh = new P2PKH()
|
|
140
|
+
const lock = p2pkh.lock(address)
|
|
141
|
+
return lock
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @publicbody
|
|
146
|
+
*/
|
|
147
|
+
static getUnlockP2PKH(priv: PrivateKey, satoshis: number): sdk.ScriptTemplateUnlock {
|
|
148
|
+
const p2pkh = new P2PKH()
|
|
149
|
+
const lock = SetupClient.getLockP2PKH(SetupClient.getKeyPair(priv).address)
|
|
150
|
+
// Prepare to pay with SIGHASH_ALL and without ANYONE_CAN_PAY.
|
|
151
|
+
// In otherwords:
|
|
152
|
+
// - all outputs must remain in the current order, amount and locking scripts.
|
|
153
|
+
// - all inputs must remain from the current outpoints and sequence numbers.
|
|
154
|
+
// (unlock scripts are never signed)
|
|
155
|
+
const unlock = p2pkh.unlock(priv, 'all', false, satoshis, lock)
|
|
156
|
+
return unlock
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @publicbody
|
|
161
|
+
*/
|
|
162
|
+
static createP2PKHOutputs(
|
|
163
|
+
outputs: {
|
|
164
|
+
address: string
|
|
165
|
+
satoshis: number
|
|
166
|
+
outputDescription?: string
|
|
167
|
+
basket?: string
|
|
168
|
+
tags?: string[]
|
|
169
|
+
}[]
|
|
170
|
+
): CreateActionOutput[] {
|
|
171
|
+
const os: CreateActionOutput[] = []
|
|
172
|
+
const count = outputs.length
|
|
173
|
+
for (let i = 0; i < count; i++) {
|
|
174
|
+
const o = outputs[i]
|
|
175
|
+
os.push({
|
|
176
|
+
basket: o.basket,
|
|
177
|
+
tags: o.tags,
|
|
178
|
+
satoshis: o.satoshis,
|
|
179
|
+
lockingScript: SetupClient.getLockP2PKH(o.address).toHex(),
|
|
180
|
+
outputDescription: o.outputDescription || `p2pkh ${i}`
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
return os
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @publicbody
|
|
188
|
+
*/
|
|
189
|
+
static async createP2PKHOutputsAction(
|
|
190
|
+
wallet: WalletInterface,
|
|
191
|
+
outputs: {
|
|
192
|
+
address: string
|
|
193
|
+
satoshis: number
|
|
194
|
+
outputDescription?: string
|
|
195
|
+
basket?: string
|
|
196
|
+
tags?: string[]
|
|
197
|
+
}[],
|
|
198
|
+
options?: CreateActionOptions
|
|
199
|
+
): Promise<{
|
|
200
|
+
cr: CreateActionResult
|
|
201
|
+
outpoints: string[] | undefined
|
|
202
|
+
}> {
|
|
203
|
+
const os = SetupClient.createP2PKHOutputs(outputs)
|
|
204
|
+
|
|
205
|
+
const createArgs: CreateActionArgs = {
|
|
206
|
+
description: `createP2PKHOutputs`,
|
|
207
|
+
outputs: os,
|
|
208
|
+
options: {
|
|
209
|
+
...options,
|
|
210
|
+
// Don't randomize so we can simplify outpoint creation
|
|
211
|
+
randomizeOutputs: false
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const cr = await wallet.createAction(createArgs)
|
|
216
|
+
|
|
217
|
+
let outpoints: string[] | undefined
|
|
218
|
+
|
|
219
|
+
if (cr.txid) {
|
|
220
|
+
outpoints = os.map((o, i) => `${cr.txid}.${i}`)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return { cr, outpoints }
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* @publicbody
|
|
228
|
+
*/
|
|
229
|
+
static async fundWalletFromP2PKHOutpoints(
|
|
230
|
+
wallet: WalletInterface,
|
|
231
|
+
outpoints: string[],
|
|
232
|
+
p2pkhKey: KeyPairAddress,
|
|
233
|
+
inputBEEF?: BEEF
|
|
234
|
+
) {
|
|
235
|
+
// TODO
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Adds `indexedDB` based storage to a `Wallet` configured by `SetupClient.createWalletOnly`
|
|
240
|
+
*
|
|
241
|
+
* @param args.databaseName Name for this storage. For MySQL, the schema name within the MySQL instance.
|
|
242
|
+
* @param args.chain Which chain this wallet is on: 'main' or 'test'. Defaults to 'test'.
|
|
243
|
+
* @param args.rootKeyHex
|
|
244
|
+
*
|
|
245
|
+
* @publicbody
|
|
246
|
+
*/
|
|
247
|
+
static async createWalletIdb(args: SetupWalletIdbArgs): Promise<SetupWalletIdb> {
|
|
248
|
+
const wo = await SetupClient.createWallet(args)
|
|
249
|
+
const activeStorage = await SetupClient.createStorageIdb(args)
|
|
250
|
+
await wo.storage.addWalletStorageProvider(activeStorage)
|
|
251
|
+
const { user, isNew } = await activeStorage.findOrInsertUser(wo.identityKey)
|
|
252
|
+
const userId = user.userId
|
|
253
|
+
const r: SetupWalletIdb = {
|
|
254
|
+
...wo,
|
|
255
|
+
activeStorage,
|
|
256
|
+
userId
|
|
257
|
+
}
|
|
258
|
+
return r
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @returns {StorageIdb} - `Knex` based storage provider for a wallet. May be used for either active storage or backup storage.
|
|
263
|
+
*/
|
|
264
|
+
static async createStorageIdb(args: SetupWalletIdbArgs): Promise<StorageIdb> {
|
|
265
|
+
const storage = new StorageIdb({
|
|
266
|
+
chain: args.chain,
|
|
267
|
+
commissionSatoshis: 0,
|
|
268
|
+
commissionPubKeyHex: undefined,
|
|
269
|
+
feeModel: { model: 'sat/kb', value: 1 }
|
|
270
|
+
})
|
|
271
|
+
await storage.migrate(args.databaseName, randomBytesHex(33))
|
|
272
|
+
await storage.makeAvailable()
|
|
273
|
+
return storage
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
*
|
|
279
|
+
*/
|
|
280
|
+
export interface SetupWalletIdbArgs extends SetupClientWalletArgs {
|
|
281
|
+
databaseName: string
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
*
|
|
286
|
+
*/
|
|
287
|
+
export interface SetupWalletIdb extends SetupWallet {
|
|
288
|
+
activeStorage: StorageIdb
|
|
289
|
+
userId: number
|
|
290
|
+
|
|
291
|
+
rootKey: PrivateKey
|
|
292
|
+
identityKey: string
|
|
293
|
+
keyDeriver: KeyDeriver
|
|
294
|
+
chain: sdk.Chain
|
|
295
|
+
storage: WalletStorageManager
|
|
296
|
+
services: Services
|
|
297
|
+
monitor: Monitor
|
|
298
|
+
wallet: Wallet
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Extension `SetupWalletClientArgs` of `SetupWalletArgs` is used by `createWalletClient`
|
|
303
|
+
* to construct a `SetupWalletClient`.
|
|
304
|
+
*/
|
|
305
|
+
export interface SetupClientWalletClientArgs extends SetupClientWalletArgs {
|
|
306
|
+
/**
|
|
307
|
+
* The endpoint URL of a service hosting the `StorageServer` JSON-RPC service to
|
|
308
|
+
* which a `StorageClient` instance should connect to function as
|
|
309
|
+
* the active storage provider of the newly created wallet.
|
|
310
|
+
*/
|
|
311
|
+
endpointUrl?: string
|
|
312
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { PrivateKey, KeyDeriver, PublicKey } from '@bsv/sdk'
|
|
2
|
+
import { WalletStorageManager, Monitor, sdk } from './index.client'
|
|
3
|
+
import { Services } from './services'
|
|
4
|
+
import { Wallet } from './Wallet'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* When creating a BRC-100 compatible `Wallet`, many components come into play.
|
|
8
|
+
*
|
|
9
|
+
* All of the `createWallet` functions in the `Setup` and `SetupClient` classes return
|
|
10
|
+
* an object with direct access to each component to facilitate experimentation, testing
|
|
11
|
+
* and customization.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export interface SetupWallet {
|
|
15
|
+
/**
|
|
16
|
+
* The rootKey of the `KeyDeriver`. The private key from which other keys are derived.
|
|
17
|
+
*/
|
|
18
|
+
rootKey: PrivateKey
|
|
19
|
+
/**
|
|
20
|
+
* The pubilc key associated with the `rootKey` which also serves as the wallet's identity.
|
|
21
|
+
*/
|
|
22
|
+
identityKey: string
|
|
23
|
+
/**
|
|
24
|
+
* The `KeyDeriver` component used by the wallet for key derivation and cryptographic functions.
|
|
25
|
+
*/
|
|
26
|
+
keyDeriver: KeyDeriver
|
|
27
|
+
/**
|
|
28
|
+
* The chain ('main' or 'test') which the wallet accesses.
|
|
29
|
+
*/
|
|
30
|
+
chain: sdk.Chain
|
|
31
|
+
/**
|
|
32
|
+
* The `WalletStorageManager` that manages all the configured storage providers (active and backups)
|
|
33
|
+
* accessed by the wallet.
|
|
34
|
+
*/
|
|
35
|
+
storage: WalletStorageManager
|
|
36
|
+
/**
|
|
37
|
+
* The network `Services` component which provides the wallet with access to external services hosted
|
|
38
|
+
* on the public network.
|
|
39
|
+
*/
|
|
40
|
+
services: Services
|
|
41
|
+
/**
|
|
42
|
+
* The background task `Monitor` component available to the wallet to offload tasks
|
|
43
|
+
* that speed up wallet operations and maintain data integrity.
|
|
44
|
+
*/
|
|
45
|
+
monitor: Monitor
|
|
46
|
+
/**
|
|
47
|
+
* The actual BRC-100 `Wallet` to which all the other properties and components contribute.
|
|
48
|
+
*
|
|
49
|
+
* Note that internally, the wallet is itself linked to all these properties and components.
|
|
50
|
+
* They are included in this interface to facilitate access after wallet construction for
|
|
51
|
+
* experimentation, testing and customization. Any changes made to the configuration of these
|
|
52
|
+
* components after construction may disrupt the normal operation of the wallet.
|
|
53
|
+
*/
|
|
54
|
+
wallet: Wallet
|
|
55
|
+
} /**
|
|
56
|
+
* A private key and associated public key and address.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
export interface KeyPairAddress {
|
|
60
|
+
privateKey: PrivateKey
|
|
61
|
+
publicKey: PublicKey
|
|
62
|
+
address: string
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Arguments used by `createWallet` to construct a `SetupWallet`.
|
|
66
|
+
*
|
|
67
|
+
* Extension `SetupWalletClientArgs` used by `createWalletClient` to construct a `SetupWalletClient`.
|
|
68
|
+
*
|
|
69
|
+
* Extension `SetupWalletIdbArgs` used by `createWalletIdb` to construct a `SetupWalletIdb`.
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
export interface SetupClientWalletArgs {
|
|
73
|
+
chain: sdk.Chain
|
|
74
|
+
/**
|
|
75
|
+
* The non-privileged private key used to initialize the `KeyDeriver` and determine the `identityKey`.
|
|
76
|
+
*/
|
|
77
|
+
rootKeyHex: string
|
|
78
|
+
/**
|
|
79
|
+
* Optional. The privileged private key getter used to initialize the `PrivilegedKeyManager`.
|
|
80
|
+
* Defaults to undefined.
|
|
81
|
+
*/
|
|
82
|
+
privilegedKeyGetter?: () => Promise<PrivateKey>
|
|
83
|
+
/**
|
|
84
|
+
* Optional. Active wallet storage. Can be added later.
|
|
85
|
+
*/
|
|
86
|
+
active?: sdk.WalletStorageProvider
|
|
87
|
+
/**
|
|
88
|
+
* Optional. One or more storage providers managed as backup destinations. Can be added later.
|
|
89
|
+
*/
|
|
90
|
+
backups?: sdk.WalletStorageProvider[]
|
|
91
|
+
|
|
92
|
+
taalApiKey?: string
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Extension `SetupWalletClient` of `SetupWallet` is returned by `createWalletClient`
|
|
97
|
+
*/
|
|
98
|
+
export interface SetupWalletClient extends SetupWallet {
|
|
99
|
+
/**
|
|
100
|
+
* The endpoint URL of the service hosting the `StorageServer` JSON-RPC service to
|
|
101
|
+
* which a `StorageClient` instance is connected to function as
|
|
102
|
+
* the active storage provider of the wallet.
|
|
103
|
+
*/
|
|
104
|
+
endpointUrl: string
|
|
105
|
+
}
|
package/src/index.all.ts
CHANGED
|
@@ -2,6 +2,8 @@ export * as sdk from './sdk/index'
|
|
|
2
2
|
export * from './utility/index.all'
|
|
3
3
|
export * from './Wallet'
|
|
4
4
|
export * from './Setup'
|
|
5
|
+
export * from './SetupClient'
|
|
6
|
+
export * from './SetupWallet'
|
|
5
7
|
export * from './signer/WalletSigner'
|
|
6
8
|
export * from './storage/index.all'
|
|
7
9
|
export * from './services/Services'
|
package/src/index.client.ts
CHANGED
package/src/monitor/Monitor.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { TaskNewHeader } from './tasks/TaskNewHeader'
|
|
|
16
16
|
|
|
17
17
|
import { TaskSendWaiting } from './tasks/TaskSendWaiting'
|
|
18
18
|
import { TaskCheckNoSends } from './tasks/TaskCheckNoSends'
|
|
19
|
+
import { TaskUnFail } from './tasks/TaskUnFail'
|
|
19
20
|
|
|
20
21
|
export type MonitorStorage = WalletStorageManager
|
|
21
22
|
|
|
@@ -114,6 +115,7 @@ export class Monitor {
|
|
|
114
115
|
this._otherTasks.push(new TaskSendWaiting(this))
|
|
115
116
|
this._otherTasks.push(new TaskCheckForProofs(this))
|
|
116
117
|
this._otherTasks.push(new TaskCheckNoSends(this))
|
|
118
|
+
this._otherTasks.push(new TaskUnFail(this))
|
|
117
119
|
|
|
118
120
|
this._otherTasks.push(new TaskFailAbandoned(this))
|
|
119
121
|
|
|
@@ -130,6 +132,7 @@ export class Monitor {
|
|
|
130
132
|
this._tasks.push(new TaskCheckForProofs(this, 2 * this.oneHour)) // Every two hours if no block found
|
|
131
133
|
this._tasks.push(new TaskCheckNoSends(this))
|
|
132
134
|
this._tasks.push(new TaskFailAbandoned(this, 8 * this.oneMinute))
|
|
135
|
+
this._tasks.push(new TaskUnFail(this))
|
|
133
136
|
// No purging until invalid transactions are really invalid...
|
|
134
137
|
//this._tasks.push(new TaskPurge(this, this.defaultPurgeParams, 6 * this.oneHour))
|
|
135
138
|
this._tasks.push(new TaskReviewStatus(this))
|
|
@@ -146,6 +149,7 @@ export class Monitor {
|
|
|
146
149
|
this._tasks.push(new TaskCheckForProofs(this, 2 * this.oneHour)) // Every two hours if no block found
|
|
147
150
|
this._tasks.push(new TaskCheckNoSends(this))
|
|
148
151
|
this._tasks.push(new TaskFailAbandoned(this, 8 * this.oneMinute))
|
|
152
|
+
this._tasks.push(new TaskUnFail(this))
|
|
149
153
|
// No purging until invalid transactions are really invalid...
|
|
150
154
|
//this._tasks.push(new TaskPurge(this, this.defaultPurgeParams, 6 * this.oneHour))
|
|
151
155
|
this._tasks.push(new TaskReviewStatus(this))
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Transaction, Utils } from '@bsv/sdk'
|
|
2
2
|
import { Monitor } from '../Monitor'
|
|
3
3
|
import { WalletMonitorTask } from './WalletMonitorTask'
|
|
4
|
-
import { StorageKnex } from '../../storage/StorageKnex'
|
|
5
4
|
import { TableProvenTxReq } from '../../storage/schema/tables'
|
|
6
5
|
import { EntityProvenTxReq } from '../../storage/schema/entities'
|
|
6
|
+
import { StorageProvider } from '../../index.client'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Setting provenTxReq status to 'unfail' when 'invalid' will attempt to find a merklePath, and if successful:
|
|
@@ -103,7 +103,7 @@ export class TaskUnFail extends WalletMonitorTask {
|
|
|
103
103
|
for (const id of txIds) {
|
|
104
104
|
const bsvtx = Transaction.fromBinary(req.rawTx)
|
|
105
105
|
await this.storage.runAsStorageProvider(async sp => {
|
|
106
|
-
const spk = sp as
|
|
106
|
+
const spk = sp as StorageProvider
|
|
107
107
|
const tx = await sp.findTransactionById(id, undefined, true)
|
|
108
108
|
if (!tx) {
|
|
109
109
|
log += ' '.repeat(indent) + `transaction ${id} was not found\n`
|
|
@@ -134,8 +134,7 @@ export class TaskUnFail extends WalletMonitorTask {
|
|
|
134
134
|
if (!o.lockingScript) {
|
|
135
135
|
log += ' '.repeat(indent + 2) + `output ${o.outputId} does not have a valid locking script\n`
|
|
136
136
|
} else {
|
|
137
|
-
const
|
|
138
|
-
const isUtxo = or.isUtxo === true
|
|
137
|
+
const isUtxo = await services.isUtxo(o)
|
|
139
138
|
if (isUtxo !== o.spendable) {
|
|
140
139
|
log += ' '.repeat(indent + 2) + `output ${o.outputId} set to ${isUtxo ? 'spendable' : 'spent'}\n`
|
|
141
140
|
await sp.updateOutput(o.outputId, { spendable: isUtxo })
|
|
@@ -2,8 +2,7 @@ import { ArcConfig, Beef, Transaction as BsvTransaction, ChainTracker, MerklePat
|
|
|
2
2
|
import { ChaintracksServiceClient } from '../services/chaintracker'
|
|
3
3
|
import { Chain, ReqHistoryNote } from './types'
|
|
4
4
|
import { WalletError } from './WalletError'
|
|
5
|
-
import { TableOutput } from '../storage/schema/tables/
|
|
6
|
-
|
|
5
|
+
import { TableOutput } from '../storage/schema/tables/TableOutput'
|
|
7
6
|
/**
|
|
8
7
|
* Defines standard interfaces to access functionality implemented by external transaction processing services.
|
|
9
8
|
*/
|
|
@@ -29,7 +29,7 @@ function createServices(chain: sdk.Chain): Services {
|
|
|
29
29
|
}
|
|
30
30
|
if (env.whatsonchainApiKey) options.whatsOnChainApiKey = env.whatsonchainApiKey
|
|
31
31
|
if (env.bitailsApiKey) options.bitailsApiKey = env.bitailsApiKey
|
|
32
|
-
|
|
32
|
+
logger(`
|
|
33
33
|
API Keys:
|
|
34
34
|
TAAL ${options.taalApiKey!.slice(0, 20)}
|
|
35
35
|
WHATSONCHAIN ${options.whatsOnChainApiKey!.slice(0, 20)}
|