@arkade-os/sdk 0.4.27 → 0.4.28
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/README.md +31 -100
- package/dist/adapters/asyncStorage.cjs +48 -0
- package/dist/adapters/asyncStorage.cjs.map +1 -0
- package/dist/adapters/asyncStorage.d.cts +16 -0
- package/dist/{types/storage → adapters}/asyncStorage.d.ts +5 -2
- package/dist/adapters/asyncStorage.js +46 -0
- package/dist/adapters/asyncStorage.js.map +1 -0
- package/dist/adapters/expo.cjs +19 -0
- package/dist/adapters/expo.cjs.map +1 -0
- package/dist/adapters/expo.d.cts +48 -0
- package/dist/adapters/expo.d.ts +48 -0
- package/dist/adapters/expo.js +6 -0
- package/dist/adapters/expo.js.map +1 -0
- package/dist/adapters/fileSystem.cjs +116 -0
- package/dist/adapters/fileSystem.cjs.map +1 -0
- package/dist/adapters/fileSystem.d.cts +17 -0
- package/dist/{types/storage → adapters}/fileSystem.d.ts +5 -2
- package/dist/adapters/fileSystem.js +93 -0
- package/dist/adapters/fileSystem.js.map +1 -0
- package/dist/adapters/indexedDB.cjs +103 -0
- package/dist/adapters/indexedDB.cjs.map +1 -0
- package/dist/adapters/indexedDB.d.cts +18 -0
- package/dist/{types/storage → adapters}/indexedDB.d.ts +5 -2
- package/dist/adapters/indexedDB.js +101 -0
- package/dist/adapters/indexedDB.js.map +1 -0
- package/dist/adapters/localStorage.cjs +50 -0
- package/dist/adapters/localStorage.cjs.map +1 -0
- package/dist/{types/storage/inMemory.d.ts → adapters/localStorage.d.cts} +6 -3
- package/dist/{types/storage → adapters}/localStorage.d.ts +5 -2
- package/dist/adapters/localStorage.js +48 -0
- package/dist/adapters/localStorage.js.map +1 -0
- package/dist/ark-TZ1gXAXU.d.cts +3880 -0
- package/dist/ark-TZ1gXAXU.d.ts +3880 -0
- package/dist/{types/worker/expo/asyncStorageTaskQueue.d.ts → asyncStorageTaskQueue-Cb1F_Z9s.d.ts} +6 -3
- package/dist/asyncStorageTaskQueue-EFqSmYTg.d.cts +49 -0
- package/dist/chunk-5BLDMQED.cjs +18 -0
- package/dist/chunk-5BLDMQED.cjs.map +1 -0
- package/dist/chunk-5PG7DV7A.cjs +805 -0
- package/dist/chunk-5PG7DV7A.cjs.map +1 -0
- package/dist/chunk-A3EMF7RN.js +95 -0
- package/dist/chunk-A3EMF7RN.js.map +1 -0
- package/dist/chunk-ADV27S4N.cjs +2701 -0
- package/dist/chunk-ADV27S4N.cjs.map +1 -0
- package/dist/chunk-BQLHADL7.js +13805 -0
- package/dist/chunk-BQLHADL7.js.map +1 -0
- package/dist/chunk-CFZMTDWI.js +209 -0
- package/dist/chunk-CFZMTDWI.js.map +1 -0
- package/dist/chunk-FG5ACJJW.cjs +212 -0
- package/dist/chunk-FG5ACJJW.cjs.map +1 -0
- package/dist/chunk-HW3JJ323.js +768 -0
- package/dist/chunk-HW3JJ323.js.map +1 -0
- package/dist/chunk-I3DGUUCT.cjs +838 -0
- package/dist/chunk-I3DGUUCT.cjs.map +1 -0
- package/dist/chunk-IPX2R7FR.cjs +100 -0
- package/dist/chunk-IPX2R7FR.cjs.map +1 -0
- package/dist/chunk-NSBPE2FW.js +15 -0
- package/dist/chunk-NSBPE2FW.js.map +1 -0
- package/dist/chunk-T64LAI7L.js +829 -0
- package/dist/chunk-T64LAI7L.js.map +1 -0
- package/dist/chunk-ZBUDLTBO.js +2671 -0
- package/dist/chunk-ZBUDLTBO.js.map +1 -0
- package/dist/chunk-ZLO6NETT.cjs +13910 -0
- package/dist/chunk-ZLO6NETT.cjs.map +1 -0
- package/dist/contracts/handlers/index.cjs +26 -0
- package/dist/contracts/handlers/index.cjs.map +1 -0
- package/dist/contracts/handlers/index.d.cts +7 -0
- package/dist/contracts/handlers/index.d.ts +7 -0
- package/dist/contracts/handlers/index.js +5 -0
- package/dist/contracts/handlers/index.js.map +1 -0
- package/dist/delegate-BFZs69hp.d.cts +84 -0
- package/dist/delegate-aaVGfWsV.d.ts +84 -0
- package/dist/index-B22cA64m.d.cts +199 -0
- package/dist/{types/storage/index.d.ts → index-C0IanN1m.d.cts} +3 -1
- package/dist/index-C0IanN1m.d.ts +11 -0
- package/dist/index-NDla_UoJ.d.ts +199 -0
- package/dist/index.cjs +480 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3343 -0
- package/dist/index.d.ts +3343 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/repositories/realm/index.cjs +513 -0
- package/dist/repositories/realm/index.cjs.map +1 -0
- package/dist/repositories/realm/index.d.cts +217 -0
- package/dist/{types/repositories/realm/schemas.d.ts → repositories/realm/index.d.ts} +80 -112
- package/dist/repositories/realm/index.js +507 -0
- package/dist/repositories/realm/index.js.map +1 -0
- package/dist/repositories/sqlite/index.cjs +588 -0
- package/dist/repositories/sqlite/index.cjs.map +1 -0
- package/dist/repositories/sqlite/index.d.cts +118 -0
- package/dist/{types/repositories/sqlite/walletRepository.d.ts → repositories/sqlite/index.d.ts} +58 -5
- package/dist/repositories/sqlite/index.js +585 -0
- package/dist/repositories/sqlite/index.js.map +1 -0
- package/dist/taskRunner-C6Ff4OaU.d.cts +114 -0
- package/dist/taskRunner-yvPN8Z0K.d.ts +114 -0
- package/dist/wallet/expo/background.cjs +93 -0
- package/dist/wallet/expo/background.cjs.map +1 -0
- package/dist/wallet/expo/background.d.cts +84 -0
- package/dist/wallet/expo/background.d.ts +84 -0
- package/dist/wallet/expo/background.js +68 -0
- package/dist/wallet/expo/background.js.map +1 -0
- package/dist/wallet/expo/index.cjs +171 -0
- package/dist/wallet/expo/index.cjs.map +1 -0
- package/dist/wallet/expo/index.d.cts +122 -0
- package/dist/{types/wallet/expo/wallet.d.ts → wallet/expo/index.d.ts} +45 -22
- package/dist/wallet/expo/index.js +169 -0
- package/dist/wallet/expo/index.js.map +1 -0
- package/dist/wallet-AF-p-OWj.d.cts +774 -0
- package/dist/wallet-D9NBRqvC.d.ts +774 -0
- package/dist/worker/expo/index.cjs +140 -0
- package/dist/worker/expo/index.cjs.map +1 -0
- package/dist/worker/expo/index.d.cts +29 -0
- package/dist/worker/expo/index.d.ts +29 -0
- package/dist/worker/expo/index.js +121 -0
- package/dist/worker/expo/index.js.map +1 -0
- package/package.json +110 -76
- package/dist/cjs/adapters/asyncStorage.js +0 -5
- package/dist/cjs/adapters/expo.js +0 -8
- package/dist/cjs/adapters/fileSystem.js +0 -5
- package/dist/cjs/adapters/indexedDB.js +0 -5
- package/dist/cjs/adapters/localStorage.js +0 -5
- package/dist/cjs/arkfee/celenv.js +0 -43
- package/dist/cjs/arkfee/estimator.js +0 -143
- package/dist/cjs/arkfee/index.js +0 -5
- package/dist/cjs/arkfee/types.js +0 -26
- package/dist/cjs/arknote/index.js +0 -128
- package/dist/cjs/bip322/index.js +0 -270
- package/dist/cjs/contracts/arkcontract.js +0 -147
- package/dist/cjs/contracts/contractManager.js +0 -649
- package/dist/cjs/contracts/contractWatcher.js +0 -598
- package/dist/cjs/contracts/handlers/default.js +0 -93
- package/dist/cjs/contracts/handlers/delegate.js +0 -90
- package/dist/cjs/contracts/handlers/helpers.js +0 -115
- package/dist/cjs/contracts/handlers/index.js +0 -19
- package/dist/cjs/contracts/handlers/registry.js +0 -89
- package/dist/cjs/contracts/handlers/vhtlc.js +0 -194
- package/dist/cjs/contracts/index.js +0 -41
- package/dist/cjs/contracts/types.js +0 -2
- package/dist/cjs/contracts/vtxoOwnership.js +0 -78
- package/dist/cjs/extension/asset/assetGroup.js +0 -228
- package/dist/cjs/extension/asset/assetId.js +0 -152
- package/dist/cjs/extension/asset/assetInput.js +0 -222
- package/dist/cjs/extension/asset/assetOutput.js +0 -174
- package/dist/cjs/extension/asset/assetRef.js +0 -148
- package/dist/cjs/extension/asset/index.js +0 -23
- package/dist/cjs/extension/asset/metadata.js +0 -187
- package/dist/cjs/extension/asset/packet.js +0 -114
- package/dist/cjs/extension/asset/types.js +0 -22
- package/dist/cjs/extension/asset/utils.js +0 -105
- package/dist/cjs/extension/index.js +0 -254
- package/dist/cjs/extension/packet.js +0 -20
- package/dist/cjs/forfeit.js +0 -45
- package/dist/cjs/identity/descriptor.js +0 -169
- package/dist/cjs/identity/descriptorProvider.js +0 -2
- package/dist/cjs/identity/hdCapableIdentity.js +0 -20
- package/dist/cjs/identity/index.js +0 -40
- package/dist/cjs/identity/seedIdentity.js +0 -477
- package/dist/cjs/identity/serialize.js +0 -171
- package/dist/cjs/identity/singleKey.js +0 -126
- package/dist/cjs/identity/staticDescriptorProvider.js +0 -65
- package/dist/cjs/index.js +0 -202
- package/dist/cjs/intent/index.js +0 -259
- package/dist/cjs/musig2/index.js +0 -11
- package/dist/cjs/musig2/keys.js +0 -57
- package/dist/cjs/musig2/nonces.js +0 -48
- package/dist/cjs/musig2/sign.js +0 -102
- package/dist/cjs/networks.js +0 -26
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/providers/ark.js +0 -577
- package/dist/cjs/providers/delegator.js +0 -85
- package/dist/cjs/providers/electrum.js +0 -869
- package/dist/cjs/providers/errors.js +0 -59
- package/dist/cjs/providers/expoArk.js +0 -82
- package/dist/cjs/providers/expoIndexer.js +0 -111
- package/dist/cjs/providers/expoUtils.js +0 -124
- package/dist/cjs/providers/indexer.js +0 -630
- package/dist/cjs/providers/onchain.js +0 -262
- package/dist/cjs/providers/utils.js +0 -121
- package/dist/cjs/repositories/contractRepository.js +0 -2
- package/dist/cjs/repositories/inMemory/contractRepository.js +0 -55
- package/dist/cjs/repositories/inMemory/walletRepository.js +0 -115
- package/dist/cjs/repositories/index.js +0 -34
- package/dist/cjs/repositories/indexedDB/contractRepository.js +0 -187
- package/dist/cjs/repositories/indexedDB/db.js +0 -19
- package/dist/cjs/repositories/indexedDB/manager.js +0 -100
- package/dist/cjs/repositories/indexedDB/schema.js +0 -204
- package/dist/cjs/repositories/indexedDB/walletRepository.js +0 -474
- package/dist/cjs/repositories/indexedDB/websqlAdapter.js +0 -144
- package/dist/cjs/repositories/migrations/contractRepositoryImpl.js +0 -127
- package/dist/cjs/repositories/migrations/fromStorageAdapter.js +0 -66
- package/dist/cjs/repositories/migrations/walletRepositoryImpl.js +0 -184
- package/dist/cjs/repositories/realm/contractRepository.js +0 -116
- package/dist/cjs/repositories/realm/index.js +0 -11
- package/dist/cjs/repositories/realm/schemas.js +0 -157
- package/dist/cjs/repositories/realm/types.js +0 -7
- package/dist/cjs/repositories/realm/walletRepository.js +0 -305
- package/dist/cjs/repositories/scriptFromAddress.js +0 -16
- package/dist/cjs/repositories/serialization.js +0 -82
- package/dist/cjs/repositories/sqlite/contractRepository.js +0 -135
- package/dist/cjs/repositories/sqlite/index.js +0 -7
- package/dist/cjs/repositories/sqlite/types.js +0 -2
- package/dist/cjs/repositories/sqlite/walletRepository.js +0 -441
- package/dist/cjs/repositories/walletRepository.js +0 -2
- package/dist/cjs/script/address.js +0 -108
- package/dist/cjs/script/base.js +0 -185
- package/dist/cjs/script/default.js +0 -57
- package/dist/cjs/script/delegate.js +0 -53
- package/dist/cjs/script/tapscript.js +0 -619
- package/dist/cjs/script/vhtlc.js +0 -170
- package/dist/cjs/storage/asyncStorage.js +0 -50
- package/dist/cjs/storage/fileSystem.js +0 -141
- package/dist/cjs/storage/inMemory.js +0 -24
- package/dist/cjs/storage/index.js +0 -2
- package/dist/cjs/storage/indexedDB.js +0 -101
- package/dist/cjs/storage/localStorage.js +0 -51
- package/dist/cjs/tree/signingSession.js +0 -229
- package/dist/cjs/tree/txTree.js +0 -192
- package/dist/cjs/tree/validation.js +0 -107
- package/dist/cjs/utils/anchor.js +0 -35
- package/dist/cjs/utils/arkTransaction.js +0 -271
- package/dist/cjs/utils/bip21.js +0 -127
- package/dist/cjs/utils/syncCursors.js +0 -128
- package/dist/cjs/utils/timelock.js +0 -59
- package/dist/cjs/utils/transaction.js +0 -28
- package/dist/cjs/utils/transactionHistory.js +0 -183
- package/dist/cjs/utils/txSizeEstimator.js +0 -132
- package/dist/cjs/utils/unknownFields.js +0 -174
- package/dist/cjs/wallet/asset-manager.js +0 -330
- package/dist/cjs/wallet/asset.js +0 -119
- package/dist/cjs/wallet/batch.js +0 -183
- package/dist/cjs/wallet/delegator.js +0 -308
- package/dist/cjs/wallet/expo/background.js +0 -116
- package/dist/cjs/wallet/expo/index.js +0 -9
- package/dist/cjs/wallet/expo/wallet.js +0 -230
- package/dist/cjs/wallet/hdDescriptorProvider.js +0 -188
- package/dist/cjs/wallet/index.js +0 -82
- package/dist/cjs/wallet/inputSignerRouter.js +0 -98
- package/dist/cjs/wallet/onchain.js +0 -290
- package/dist/cjs/wallet/ramps.js +0 -216
- package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +0 -953
- package/dist/cjs/wallet/serviceWorker/wallet.js +0 -1174
- package/dist/cjs/wallet/signingErrors.js +0 -32
- package/dist/cjs/wallet/unroll.js +0 -293
- package/dist/cjs/wallet/utils.js +0 -111
- package/dist/cjs/wallet/validation.js +0 -154
- package/dist/cjs/wallet/vtxo-manager.js +0 -1142
- package/dist/cjs/wallet/wallet.js +0 -2195
- package/dist/cjs/wallet/walletReceiveRotator.js +0 -547
- package/dist/cjs/worker/browser/service-worker-manager.js +0 -183
- package/dist/cjs/worker/browser/utils.js +0 -67
- package/dist/cjs/worker/errors.js +0 -16
- package/dist/cjs/worker/expo/asyncStorageTaskQueue.js +0 -78
- package/dist/cjs/worker/expo/index.js +0 -13
- package/dist/cjs/worker/expo/processors/contractPollProcessor.js +0 -62
- package/dist/cjs/worker/expo/processors/index.js +0 -6
- package/dist/cjs/worker/expo/taskQueue.js +0 -41
- package/dist/cjs/worker/expo/taskRunner.js +0 -73
- package/dist/cjs/worker/messageBus.js +0 -474
- package/dist/esm/adapters/asyncStorage.js +0 -1
- package/dist/esm/adapters/expo.js +0 -3
- package/dist/esm/adapters/fileSystem.js +0 -1
- package/dist/esm/adapters/indexedDB.js +0 -1
- package/dist/esm/adapters/localStorage.js +0 -1
- package/dist/esm/arkfee/celenv.js +0 -40
- package/dist/esm/arkfee/estimator.js +0 -139
- package/dist/esm/arkfee/index.js +0 -1
- package/dist/esm/arkfee/types.js +0 -22
- package/dist/esm/arknote/index.js +0 -124
- package/dist/esm/bip322/index.js +0 -267
- package/dist/esm/contracts/arkcontract.js +0 -140
- package/dist/esm/contracts/contractManager.js +0 -645
- package/dist/esm/contracts/contractWatcher.js +0 -594
- package/dist/esm/contracts/handlers/default.js +0 -90
- package/dist/esm/contracts/handlers/delegate.js +0 -87
- package/dist/esm/contracts/handlers/helpers.js +0 -110
- package/dist/esm/contracts/handlers/index.js +0 -12
- package/dist/esm/contracts/handlers/registry.js +0 -86
- package/dist/esm/contracts/handlers/vhtlc.js +0 -191
- package/dist/esm/contracts/index.js +0 -13
- package/dist/esm/contracts/types.js +0 -1
- package/dist/esm/contracts/vtxoOwnership.js +0 -69
- package/dist/esm/extension/asset/assetGroup.js +0 -224
- package/dist/esm/extension/asset/assetId.js +0 -148
- package/dist/esm/extension/asset/assetInput.js +0 -217
- package/dist/esm/extension/asset/assetOutput.js +0 -169
- package/dist/esm/extension/asset/assetRef.js +0 -144
- package/dist/esm/extension/asset/index.js +0 -8
- package/dist/esm/extension/asset/metadata.js +0 -182
- package/dist/esm/extension/asset/packet.js +0 -110
- package/dist/esm/extension/asset/types.js +0 -19
- package/dist/esm/extension/asset/utils.js +0 -99
- package/dist/esm/extension/index.js +0 -248
- package/dist/esm/extension/packet.js +0 -16
- package/dist/esm/forfeit.js +0 -41
- package/dist/esm/identity/descriptor.js +0 -161
- package/dist/esm/identity/descriptorProvider.js +0 -1
- package/dist/esm/identity/hdCapableIdentity.js +0 -17
- package/dist/esm/identity/index.js +0 -13
- package/dist/esm/identity/seedIdentity.js +0 -469
- package/dist/esm/identity/serialize.js +0 -164
- package/dist/esm/identity/singleKey.js +0 -121
- package/dist/esm/identity/staticDescriptorProvider.js +0 -61
- package/dist/esm/index.js +0 -87
- package/dist/esm/intent/index.js +0 -255
- package/dist/esm/musig2/index.js +0 -3
- package/dist/esm/musig2/keys.js +0 -21
- package/dist/esm/musig2/nonces.js +0 -11
- package/dist/esm/musig2/sign.js +0 -63
- package/dist/esm/networks.js +0 -22
- package/dist/esm/package.json +0 -3
- package/dist/esm/providers/ark.js +0 -572
- package/dist/esm/providers/delegator.js +0 -81
- package/dist/esm/providers/electrum.js +0 -864
- package/dist/esm/providers/errors.js +0 -54
- package/dist/esm/providers/expoArk.js +0 -78
- package/dist/esm/providers/expoIndexer.js +0 -107
- package/dist/esm/providers/expoUtils.js +0 -87
- package/dist/esm/providers/indexer.js +0 -626
- package/dist/esm/providers/onchain.js +0 -258
- package/dist/esm/providers/utils.js +0 -117
- package/dist/esm/repositories/contractRepository.js +0 -1
- package/dist/esm/repositories/inMemory/contractRepository.js +0 -51
- package/dist/esm/repositories/inMemory/walletRepository.js +0 -111
- package/dist/esm/repositories/index.js +0 -10
- package/dist/esm/repositories/indexedDB/contractRepository.js +0 -183
- package/dist/esm/repositories/indexedDB/db.js +0 -4
- package/dist/esm/repositories/indexedDB/manager.js +0 -95
- package/dist/esm/repositories/indexedDB/schema.js +0 -199
- package/dist/esm/repositories/indexedDB/walletRepository.js +0 -470
- package/dist/esm/repositories/indexedDB/websqlAdapter.js +0 -138
- package/dist/esm/repositories/migrations/contractRepositoryImpl.js +0 -121
- package/dist/esm/repositories/migrations/fromStorageAdapter.js +0 -58
- package/dist/esm/repositories/migrations/walletRepositoryImpl.js +0 -180
- package/dist/esm/repositories/realm/contractRepository.js +0 -112
- package/dist/esm/repositories/realm/index.js +0 -3
- package/dist/esm/repositories/realm/schemas.js +0 -153
- package/dist/esm/repositories/realm/types.js +0 -6
- package/dist/esm/repositories/realm/walletRepository.js +0 -301
- package/dist/esm/repositories/scriptFromAddress.js +0 -13
- package/dist/esm/repositories/serialization.js +0 -67
- package/dist/esm/repositories/sqlite/contractRepository.js +0 -131
- package/dist/esm/repositories/sqlite/index.js +0 -2
- package/dist/esm/repositories/sqlite/types.js +0 -1
- package/dist/esm/repositories/sqlite/walletRepository.js +0 -437
- package/dist/esm/repositories/walletRepository.js +0 -1
- package/dist/esm/script/address.js +0 -104
- package/dist/esm/script/base.js +0 -179
- package/dist/esm/script/default.js +0 -54
- package/dist/esm/script/delegate.js +0 -50
- package/dist/esm/script/tapscript.js +0 -615
- package/dist/esm/script/vhtlc.js +0 -167
- package/dist/esm/storage/asyncStorage.js +0 -46
- package/dist/esm/storage/fileSystem.js +0 -104
- package/dist/esm/storage/inMemory.js +0 -20
- package/dist/esm/storage/index.js +0 -1
- package/dist/esm/storage/indexedDB.js +0 -97
- package/dist/esm/storage/localStorage.js +0 -47
- package/dist/esm/tree/signingSession.js +0 -191
- package/dist/esm/tree/txTree.js +0 -188
- package/dist/esm/tree/validation.js +0 -101
- package/dist/esm/utils/anchor.js +0 -31
- package/dist/esm/utils/arkTransaction.js +0 -264
- package/dist/esm/utils/bip21.js +0 -123
- package/dist/esm/utils/syncCursors.js +0 -119
- package/dist/esm/utils/timelock.js +0 -22
- package/dist/esm/utils/transaction.js +0 -24
- package/dist/esm/utils/transactionHistory.js +0 -180
- package/dist/esm/utils/txSizeEstimator.js +0 -128
- package/dist/esm/utils/unknownFields.js +0 -169
- package/dist/esm/wallet/asset-manager.js +0 -325
- package/dist/esm/wallet/asset.js +0 -113
- package/dist/esm/wallet/batch.js +0 -180
- package/dist/esm/wallet/delegator.js +0 -303
- package/dist/esm/wallet/expo/background.js +0 -111
- package/dist/esm/wallet/expo/index.js +0 -2
- package/dist/esm/wallet/expo/wallet.js +0 -193
- package/dist/esm/wallet/hdDescriptorProvider.js +0 -184
- package/dist/esm/wallet/index.js +0 -75
- package/dist/esm/wallet/inputSignerRouter.js +0 -94
- package/dist/esm/wallet/onchain.js +0 -285
- package/dist/esm/wallet/ramps.js +0 -212
- package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +0 -946
- package/dist/esm/wallet/serviceWorker/wallet.js +0 -1169
- package/dist/esm/wallet/signingErrors.js +0 -27
- package/dist/esm/wallet/unroll.js +0 -289
- package/dist/esm/wallet/utils.js +0 -103
- package/dist/esm/wallet/validation.js +0 -142
- package/dist/esm/wallet/vtxo-manager.js +0 -1136
- package/dist/esm/wallet/wallet.js +0 -2186
- package/dist/esm/wallet/walletReceiveRotator.js +0 -540
- package/dist/esm/worker/browser/service-worker-manager.js +0 -177
- package/dist/esm/worker/browser/utils.js +0 -63
- package/dist/esm/worker/errors.js +0 -11
- package/dist/esm/worker/expo/asyncStorageTaskQueue.js +0 -74
- package/dist/esm/worker/expo/index.js +0 -4
- package/dist/esm/worker/expo/processors/contractPollProcessor.js +0 -59
- package/dist/esm/worker/expo/processors/index.js +0 -1
- package/dist/esm/worker/expo/taskQueue.js +0 -37
- package/dist/esm/worker/expo/taskRunner.js +0 -69
- package/dist/esm/worker/messageBus.js +0 -470
- package/dist/types/adapters/asyncStorage.d.ts +0 -2
- package/dist/types/adapters/expo.d.ts +0 -4
- package/dist/types/adapters/fileSystem.d.ts +0 -2
- package/dist/types/adapters/indexedDB.d.ts +0 -2
- package/dist/types/adapters/localStorage.d.ts +0 -2
- package/dist/types/arkfee/celenv.d.ts +0 -25
- package/dist/types/arkfee/estimator.d.ts +0 -49
- package/dist/types/arkfee/index.d.ts +0 -2
- package/dist/types/arkfee/types.d.ts +0 -38
- package/dist/types/arknote/index.d.ts +0 -84
- package/dist/types/bip322/index.d.ts +0 -55
- package/dist/types/contracts/arkcontract.d.ts +0 -99
- package/dist/types/contracts/contractManager.d.ts +0 -411
- package/dist/types/contracts/contractWatcher.d.ts +0 -217
- package/dist/types/contracts/handlers/default.d.ts +0 -19
- package/dist/types/contracts/handlers/delegate.d.ts +0 -21
- package/dist/types/contracts/handlers/helpers.d.ts +0 -19
- package/dist/types/contracts/handlers/index.d.ts +0 -7
- package/dist/types/contracts/handlers/registry.d.ts +0 -65
- package/dist/types/contracts/handlers/vhtlc.d.ts +0 -32
- package/dist/types/contracts/index.d.ts +0 -14
- package/dist/types/contracts/types.d.ts +0 -250
- package/dist/types/contracts/vtxoOwnership.d.ts +0 -33
- package/dist/types/extension/asset/assetGroup.d.ts +0 -119
- package/dist/types/extension/asset/assetId.d.ts +0 -83
- package/dist/types/extension/asset/assetInput.d.ts +0 -64
- package/dist/types/extension/asset/assetOutput.d.ts +0 -54
- package/dist/types/extension/asset/assetRef.d.ts +0 -91
- package/dist/types/extension/asset/index.d.ts +0 -8
- package/dist/types/extension/asset/metadata.d.ts +0 -52
- package/dist/types/extension/asset/packet.d.ts +0 -41
- package/dist/types/extension/asset/types.d.ts +0 -16
- package/dist/types/extension/asset/utils.d.ts +0 -21
- package/dist/types/extension/index.d.ts +0 -56
- package/dist/types/extension/packet.d.ts +0 -21
- package/dist/types/forfeit.d.ts +0 -18
- package/dist/types/identity/descriptor.d.ts +0 -61
- package/dist/types/identity/descriptorProvider.d.ts +0 -42
- package/dist/types/identity/hdCapableIdentity.d.ts +0 -71
- package/dist/types/identity/index.d.ts +0 -57
- package/dist/types/identity/seedIdentity.d.ts +0 -270
- package/dist/types/identity/serialize.d.ts +0 -96
- package/dist/types/identity/singleKey.d.ts +0 -62
- package/dist/types/identity/staticDescriptorProvider.d.ts +0 -18
- package/dist/types/index.d.ts +0 -59
- package/dist/types/intent/index.d.ts +0 -86
- package/dist/types/musig2/index.d.ts +0 -4
- package/dist/types/musig2/keys.d.ts +0 -9
- package/dist/types/musig2/nonces.d.ts +0 -14
- package/dist/types/musig2/sign.d.ts +0 -27
- package/dist/types/networks.d.ts +0 -16
- package/dist/types/providers/ark.d.ts +0 -369
- package/dist/types/providers/delegator.d.ts +0 -82
- package/dist/types/providers/electrum.d.ts +0 -312
- package/dist/types/providers/errors.d.ts +0 -13
- package/dist/types/providers/expoArk.d.ts +0 -22
- package/dist/types/providers/expoIndexer.d.ts +0 -18
- package/dist/types/providers/expoUtils.d.ts +0 -18
- package/dist/types/providers/indexer.d.ts +0 -301
- package/dist/types/providers/onchain.d.ts +0 -148
- package/dist/types/providers/utils.d.ts +0 -12
- package/dist/types/repositories/contractRepository.d.ts +0 -32
- package/dist/types/repositories/inMemory/contractRepository.d.ts +0 -17
- package/dist/types/repositories/inMemory/walletRepository.d.ts +0 -29
- package/dist/types/repositories/index.d.ts +0 -9
- package/dist/types/repositories/indexedDB/contractRepository.d.ts +0 -21
- package/dist/types/repositories/indexedDB/db.d.ts +0 -4
- package/dist/types/repositories/indexedDB/manager.d.ts +0 -25
- package/dist/types/repositories/indexedDB/schema.d.ts +0 -9
- package/dist/types/repositories/indexedDB/walletRepository.d.ts +0 -28
- package/dist/types/repositories/indexedDB/websqlAdapter.d.ts +0 -49
- package/dist/types/repositories/migrations/contractRepositoryImpl.d.ts +0 -24
- package/dist/types/repositories/migrations/fromStorageAdapter.d.ts +0 -19
- package/dist/types/repositories/migrations/walletRepositoryImpl.d.ts +0 -27
- package/dist/types/repositories/realm/contractRepository.d.ts +0 -24
- package/dist/types/repositories/realm/index.d.ts +0 -4
- package/dist/types/repositories/realm/types.d.ts +0 -16
- package/dist/types/repositories/realm/walletRepository.d.ts +0 -34
- package/dist/types/repositories/scriptFromAddress.d.ts +0 -9
- package/dist/types/repositories/serialization.d.ts +0 -65
- package/dist/types/repositories/sqlite/contractRepository.d.ts +0 -33
- package/dist/types/repositories/sqlite/index.d.ts +0 -3
- package/dist/types/repositories/sqlite/types.d.ts +0 -18
- package/dist/types/repositories/walletRepository.d.ts +0 -72
- package/dist/types/script/address.d.ts +0 -67
- package/dist/types/script/base.d.ts +0 -105
- package/dist/types/script/default.d.ts +0 -44
- package/dist/types/script/delegate.d.ts +0 -40
- package/dist/types/script/tapscript.d.ts +0 -169
- package/dist/types/script/vhtlc.d.ts +0 -66
- package/dist/types/tree/signingSession.d.ts +0 -37
- package/dist/types/tree/txTree.d.ts +0 -28
- package/dist/types/tree/validation.d.ts +0 -15
- package/dist/types/utils/anchor.d.ts +0 -19
- package/dist/types/utils/arkTransaction.d.ts +0 -49
- package/dist/types/utils/bip21.d.ts +0 -38
- package/dist/types/utils/syncCursors.d.ts +0 -60
- package/dist/types/utils/timelock.d.ts +0 -9
- package/dist/types/utils/transaction.d.ts +0 -13
- package/dist/types/utils/transactionHistory.d.ts +0 -15
- package/dist/types/utils/txSizeEstimator.d.ts +0 -40
- package/dist/types/utils/unknownFields.d.ts +0 -83
- package/dist/types/wallet/asset-manager.d.ts +0 -69
- package/dist/types/wallet/asset.d.ts +0 -21
- package/dist/types/wallet/batch.d.ts +0 -107
- package/dist/types/wallet/delegator.d.ts +0 -48
- package/dist/types/wallet/expo/background.d.ts +0 -66
- package/dist/types/wallet/expo/index.d.ts +0 -4
- package/dist/types/wallet/hdDescriptorProvider.d.ts +0 -114
- package/dist/types/wallet/index.d.ts +0 -789
- package/dist/types/wallet/inputSignerRouter.d.ts +0 -35
- package/dist/types/wallet/onchain.d.ts +0 -109
- package/dist/types/wallet/ramps.d.ts +0 -64
- package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +0 -543
- package/dist/types/wallet/serviceWorker/wallet.d.ts +0 -248
- package/dist/types/wallet/signingErrors.d.ts +0 -19
- package/dist/types/wallet/unroll.d.ts +0 -114
- package/dist/types/wallet/utils.d.ts +0 -36
- package/dist/types/wallet/validation.d.ts +0 -24
- package/dist/types/wallet/vtxo-manager.d.ts +0 -476
- package/dist/types/wallet/wallet.d.ts +0 -409
- package/dist/types/wallet/walletReceiveRotator.d.ts +0 -306
- package/dist/types/worker/browser/service-worker-manager.d.ts +0 -32
- package/dist/types/worker/browser/utils.d.ts +0 -17
- package/dist/types/worker/errors.d.ts +0 -7
- package/dist/types/worker/expo/index.d.ts +0 -7
- package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +0 -19
- package/dist/types/worker/expo/processors/index.d.ts +0 -1
- package/dist/types/worker/expo/taskQueue.d.ts +0 -50
- package/dist/types/worker/expo/taskRunner.d.ts +0 -66
- package/dist/types/worker/messageBus.d.ts +0 -189
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Bytes } from "@scure/btc-signer/utils.js";
|
|
2
|
-
import { TapLeafScript, VtxoScript } from "../script/base.js";
|
|
3
|
-
import { ExtendedCoin, Status } from "../wallet/index.js";
|
|
4
|
-
/**
|
|
5
|
-
* ArkNotes are special virtual outputs in the Arkade protocol that
|
|
6
|
-
* can be created and spent without requiring any transactions.
|
|
7
|
-
* The server mints them, and they are encoded as base58 strings
|
|
8
|
-
* with a human-readable prefix, a preimage and a value.
|
|
9
|
-
*
|
|
10
|
-
* @see VtxoScript
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* // Create an ArkNote
|
|
15
|
-
* const note = new ArkNote(preimage, 50000);
|
|
16
|
-
*
|
|
17
|
-
* // Encode to string
|
|
18
|
-
* const noteString = note.toString();
|
|
19
|
-
*
|
|
20
|
-
* // Decode from string
|
|
21
|
-
* const decodedNote = ArkNote.fromString(noteString);
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare class ArkNote implements ExtendedCoin {
|
|
25
|
-
preimage: Uint8Array;
|
|
26
|
-
value: number;
|
|
27
|
-
HRP: string;
|
|
28
|
-
static readonly DefaultHRP = "arknote";
|
|
29
|
-
static readonly PreimageLength = 32;
|
|
30
|
-
static readonly ValueLength = 4;
|
|
31
|
-
static readonly Length: number;
|
|
32
|
-
static readonly FakeOutpointIndex = 0;
|
|
33
|
-
readonly vtxoScript: VtxoScript;
|
|
34
|
-
/** Hashlock script backing the note. */
|
|
35
|
-
readonly txid: string;
|
|
36
|
-
readonly vout = 0;
|
|
37
|
-
readonly forfeitTapLeafScript: TapLeafScript;
|
|
38
|
-
readonly intentTapLeafScript: TapLeafScript;
|
|
39
|
-
readonly tapTree: Bytes;
|
|
40
|
-
readonly status: Status;
|
|
41
|
-
readonly extraWitness?: Bytes[] | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Create an ArkNote from a preimage and value.
|
|
44
|
-
*
|
|
45
|
-
* @param preimage - 32-byte preimage revealed to spend the note
|
|
46
|
-
* @param value - Note value in satoshis
|
|
47
|
-
* @param HRP - Optional human-readable prefix for string encoding
|
|
48
|
-
*/
|
|
49
|
-
constructor(preimage: Uint8Array, value: number, HRP?: string);
|
|
50
|
-
/**
|
|
51
|
-
* Encode the note as raw bytes.
|
|
52
|
-
*
|
|
53
|
-
* @returns Serialized note bytes
|
|
54
|
-
* @see decode
|
|
55
|
-
*/
|
|
56
|
-
encode(): Uint8Array;
|
|
57
|
-
/**
|
|
58
|
-
* Decode a note from raw bytes.
|
|
59
|
-
*
|
|
60
|
-
* @param data - Serialized note bytes
|
|
61
|
-
* @param hrp - Human-readable prefix expected for future string encoding
|
|
62
|
-
* @returns Decoded ArkNote
|
|
63
|
-
* @throws Error if the payload length is invalid
|
|
64
|
-
* @see encode
|
|
65
|
-
*/
|
|
66
|
-
static decode(data: Uint8Array, hrp?: string): ArkNote;
|
|
67
|
-
/**
|
|
68
|
-
* Decode a note from its base58 string form.
|
|
69
|
-
*
|
|
70
|
-
* @param noteStr - Base58-encoded note string
|
|
71
|
-
* @param hrp - Human-readable prefix expected on the note string
|
|
72
|
-
* @returns Decoded ArkNote
|
|
73
|
-
* @throws Error if the prefix or base58 payload is invalid
|
|
74
|
-
* @see toString
|
|
75
|
-
*/
|
|
76
|
-
static fromString(noteStr: string, hrp?: string): ArkNote;
|
|
77
|
-
/**
|
|
78
|
-
* Encode the note to its human-readable base58 string form.
|
|
79
|
-
*
|
|
80
|
-
* @returns Base58-encoded note string
|
|
81
|
-
* @see fromString
|
|
82
|
-
*/
|
|
83
|
-
toString(): string;
|
|
84
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { type BTC_NETWORK } from "@scure/btc-signer/utils.js";
|
|
2
|
-
import type { Identity } from "../identity/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* BIP-322 simple message signing and verification.
|
|
5
|
-
*
|
|
6
|
-
* Supports P2TR (Taproot) signing and verification, P2WPKH verification,
|
|
7
|
-
* and legacy P2PKH verification (Bitcoin Core signmessage format).
|
|
8
|
-
*
|
|
9
|
-
* Reuses the same toSpend/toSign transaction construction as Intent proofs,
|
|
10
|
-
* but with the standard BIP-322 tagged hash ("BIP0322-signed-message")
|
|
11
|
-
* instead of the Arkade-specific tag.
|
|
12
|
-
*
|
|
13
|
-
* @see https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* // Sign a message (P2TR)
|
|
18
|
-
* const signature = await BIP322.sign("Hello Bitcoin!", identity);
|
|
19
|
-
*
|
|
20
|
-
* // Verify a signature (P2TR or P2WPKH)
|
|
21
|
-
* const valid = BIP322.verify("Hello Bitcoin!", signature, "bc1p...");
|
|
22
|
-
* const valid2 = BIP322.verify("Hello Bitcoin!", signature, "bc1q...");
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export declare namespace BIP322 {
|
|
26
|
-
/**
|
|
27
|
-
* Sign a message using the BIP-322 simple signature scheme.
|
|
28
|
-
*
|
|
29
|
-
* Constructs the standard BIP-322 toSpend and toSign transactions,
|
|
30
|
-
* signs via the Identity interface, and returns the base64-encoded
|
|
31
|
-
* witness stack.
|
|
32
|
-
*
|
|
33
|
-
* @param message - The message to sign
|
|
34
|
-
* @param identity - Identity instance (holds the private key internally)
|
|
35
|
-
* @param network - Optional Bitcoin network for P2TR address derivation
|
|
36
|
-
* @returns Base64-encoded BIP-322 simple signature (witness stack)
|
|
37
|
-
*/
|
|
38
|
-
function sign(message: string, identity: Identity, network?: BTC_NETWORK): Promise<string>;
|
|
39
|
-
/**
|
|
40
|
-
* Verify a BIP-322 signature for a P2TR, P2WPKH, or legacy P2PKH address.
|
|
41
|
-
*
|
|
42
|
-
* For segwit addresses (P2TR, P2WPKH), reconstructs the BIP-322
|
|
43
|
-
* toSpend/toSign transactions and verifies the witness signature.
|
|
44
|
-
*
|
|
45
|
-
* For P2PKH addresses, verifies using the Bitcoin Core legacy
|
|
46
|
-
* `signmessage` format (compact recoverable ECDSA signature).
|
|
47
|
-
*
|
|
48
|
-
* @param message - The original message that was signed
|
|
49
|
-
* @param signature - Base64-encoded signature (BIP-322 witness or legacy compact)
|
|
50
|
-
* @param address - P2TR, P2WPKH, or P2PKH address of the signer
|
|
51
|
-
* @param network - Optional Bitcoin network for address decoding
|
|
52
|
-
* @returns true if the signature is valid
|
|
53
|
-
*/
|
|
54
|
-
function verify(message: string, signature: string, address: string, network?: BTC_NETWORK): boolean;
|
|
55
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { Contract } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Encode a contract to the arkcontract string format.
|
|
4
|
-
*
|
|
5
|
-
* Format: arkcontract={type}&{key1}={value1}&{key2}={value2}...
|
|
6
|
-
*
|
|
7
|
-
* This format is compatible with NArk and allows contracts to be
|
|
8
|
-
* shared/imported across different Arkade SDKs.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* const contract: Contract = {
|
|
13
|
-
* type: "vhtlc",
|
|
14
|
-
* params: { sender: "ab12...", receiver: "cd34...", ... },
|
|
15
|
-
* // ...
|
|
16
|
-
* };
|
|
17
|
-
*
|
|
18
|
-
* const encoded = encodeArkContract(contract);
|
|
19
|
-
* // "arkcontract=vhtlc&sender=ab12...&receiver=cd34...&..."
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export declare function encodeArkContract(contract: Contract): string;
|
|
23
|
-
/**
|
|
24
|
-
* Parsed result from decoding an arkcontract string.
|
|
25
|
-
*
|
|
26
|
-
* This is a low-level representation. For type-safe contract creation,
|
|
27
|
-
* use `contractFromArkContract` or `contractFromArkContractWithAddress`
|
|
28
|
-
* which validate params through the handler system.
|
|
29
|
-
*/
|
|
30
|
-
export interface ParsedArkContract {
|
|
31
|
-
/** Contract type (e.g., "vhtlc", "default") */
|
|
32
|
-
type: string;
|
|
33
|
-
/** All key-value pairs from the string */
|
|
34
|
-
data: Record<string, string>;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Decode an arkcontract string into raw type and data.
|
|
38
|
-
*
|
|
39
|
-
* This is a low-level function that parses the URL-encoded format.
|
|
40
|
-
* For creating typed Contract objects, use `contractFromArkContract`
|
|
41
|
-
* or `contractFromArkContractWithAddress` instead.
|
|
42
|
-
*
|
|
43
|
-
* @param encoded - The arkcontract string
|
|
44
|
-
* @returns Parsed type and key-value data
|
|
45
|
-
* @throws If the string is not a valid arkcontract
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```typescript
|
|
49
|
-
* const parsed = decodeArkContract("arkcontract=vhtlc&sender=ab12...");
|
|
50
|
-
* // { type: "vhtlc", data: { sender: "ab12...", ... } }
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
export declare function decodeArkContract(encoded: string): ParsedArkContract;
|
|
54
|
-
/**
|
|
55
|
-
* Create a Contract from an arkcontract string.
|
|
56
|
-
*
|
|
57
|
-
* This requires a handler to be registered for the contract type.
|
|
58
|
-
*
|
|
59
|
-
* @param encoded - The arkcontract string
|
|
60
|
-
* @param options - Additional options for the contract
|
|
61
|
-
* @returns A Contract object
|
|
62
|
-
* @throws If the string is invalid or no handler exists for the type
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```typescript
|
|
66
|
-
* const contract = contractFromArkContract(
|
|
67
|
-
* "arkcontract=vhtlc&sender=ab12...",
|
|
68
|
-
* {
|
|
69
|
-
* label: "Lightning Receive",
|
|
70
|
-
* }
|
|
71
|
-
* );
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
export declare function contractFromArkContract(encoded: string, options?: {
|
|
75
|
-
label?: string;
|
|
76
|
-
state?: "active" | "inactive";
|
|
77
|
-
metadata?: Record<string, unknown>;
|
|
78
|
-
}): Omit<Contract, "script" | "address"> & {
|
|
79
|
-
script?: string;
|
|
80
|
-
address?: string;
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Create a full Contract with derived script and address.
|
|
84
|
-
*
|
|
85
|
-
* @param encoded - The arkcontract string
|
|
86
|
-
* @param serverPubKey - Server public key (for address derivation)
|
|
87
|
-
* @param addressPrefix - Address prefix (e.g., "tark" for testnet)
|
|
88
|
-
* @param options - Additional options
|
|
89
|
-
* @returns A complete Contract object
|
|
90
|
-
*/
|
|
91
|
-
export declare function contractFromArkContractWithAddress(encoded: string, serverPubKey: Uint8Array, addressPrefix?: string, options?: {
|
|
92
|
-
label?: string;
|
|
93
|
-
state?: "active" | "inactive";
|
|
94
|
-
metadata?: Record<string, unknown>;
|
|
95
|
-
}): Contract;
|
|
96
|
-
/**
|
|
97
|
-
* Check if a string is an arkcontract.
|
|
98
|
-
*/
|
|
99
|
-
export declare function isArkContract(str: string): boolean;
|
|
@@ -1,411 +0,0 @@
|
|
|
1
|
-
import { IndexerProvider } from "../providers/indexer.js";
|
|
2
|
-
import { WalletRepository } from "../repositories/walletRepository.js";
|
|
3
|
-
import { Contract, ContractEventCallback, ContractState, ContractWithVtxos, GetContractsFilter, PathSelection } from "./types.js";
|
|
4
|
-
import { ContractWatcherConfig } from "./contractWatcher.js";
|
|
5
|
-
import { ExtendedVirtualCoin, Outpoint, VirtualCoin } from "../wallet/index.js";
|
|
6
|
-
import { ContractRepository } from "../repositories/index.js";
|
|
7
|
-
export type RefreshVtxosOptions = {
|
|
8
|
-
scripts?: string[];
|
|
9
|
-
after?: number;
|
|
10
|
-
before?: number;
|
|
11
|
-
/**
|
|
12
|
-
* When true and `scripts` is not set, refresh every contract in
|
|
13
|
-
* the repository — including those marked `inactive` and those
|
|
14
|
-
* that have dropped out of the watcher's active set. Useful for
|
|
15
|
-
* "did anyone send funds to a stale rotated display address?"
|
|
16
|
-
* audits.
|
|
17
|
-
*
|
|
18
|
-
* Because this is a *superset* of the watcher's watched set, the
|
|
19
|
-
* cursor invariant still holds and the cursor advances normally
|
|
20
|
-
* (unless an explicit `after` / `before` window is also supplied).
|
|
21
|
-
*
|
|
22
|
-
* Ignored when `scripts` is set (the explicit list already
|
|
23
|
-
* specifies what to refresh, regardless of contract state).
|
|
24
|
-
*
|
|
25
|
-
* @defaultValue `false`
|
|
26
|
-
*/
|
|
27
|
-
includeInactive?: boolean;
|
|
28
|
-
};
|
|
29
|
-
export interface IContractManager extends Disposable {
|
|
30
|
-
/**
|
|
31
|
-
* Create and register a new contract.
|
|
32
|
-
*
|
|
33
|
-
* Implementations may validate that:
|
|
34
|
-
* - A handler exists for `params.type`
|
|
35
|
-
* - `params.script` matches the script derived from `params.params`
|
|
36
|
-
*
|
|
37
|
-
* The contract script is used as the unique identifier.
|
|
38
|
-
*/
|
|
39
|
-
createContract(params: CreateContractParams): Promise<Contract>;
|
|
40
|
-
/**
|
|
41
|
-
* List contracts with optional filters.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* const vhtlcs = await manager.getContracts({ type: "vhtlc" });
|
|
46
|
-
* const active = await manager.getContracts({ state: "active" });
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
getContracts(filter?: GetContractsFilter): Promise<Contract[]>;
|
|
50
|
-
/**
|
|
51
|
-
* List contracts and their current virtual outputs.
|
|
52
|
-
*
|
|
53
|
-
* If no filter is provided, returns all contracts with their virtual outputs.
|
|
54
|
-
*/
|
|
55
|
-
getContractsWithVtxos(filter?: GetContractsFilter): Promise<ContractWithVtxos[]>;
|
|
56
|
-
/**
|
|
57
|
-
* Stamp raw virtual outputs with the correct per-contract tapscripts
|
|
58
|
-
* (forfeit, intent, tap tree).
|
|
59
|
-
*
|
|
60
|
-
* Resolves each vtxo's `script` to its owning contract via the contract
|
|
61
|
-
* repository and attaches the matching tapscripts. Throws when any vtxo
|
|
62
|
-
* references a script with no registered contract — callers are expected
|
|
63
|
-
* to register the contract before asking for annotation. This is the
|
|
64
|
-
* single shared path that replaces scattered `extendVirtualCoin*` calls
|
|
65
|
-
* in wallet/handler code, and keeps the wallet from silently stamping the
|
|
66
|
-
* default tapscript onto a non-default vtxo.
|
|
67
|
-
*/
|
|
68
|
-
annotateVtxos(vtxos: VirtualCoin[]): Promise<ExtendedVirtualCoin[]>;
|
|
69
|
-
/**
|
|
70
|
-
* Update mutable contract fields.
|
|
71
|
-
*
|
|
72
|
-
* `script` and `createdAt` are immutable.
|
|
73
|
-
*/
|
|
74
|
-
updateContract(script: string, updates: Partial<Omit<Contract, "script" | "createdAt">>): Promise<Contract>;
|
|
75
|
-
/**
|
|
76
|
-
* Convenience helper to update only the contract state.
|
|
77
|
-
*/
|
|
78
|
-
setContractState(script: string, state: ContractState): Promise<void>;
|
|
79
|
-
/**
|
|
80
|
-
* Delete a contract by script and stop watching it (if applicable).
|
|
81
|
-
*/
|
|
82
|
-
deleteContract(script: string): Promise<void>;
|
|
83
|
-
/**
|
|
84
|
-
* Get all currently spendable paths for a contract.
|
|
85
|
-
*
|
|
86
|
-
* Returns an empty array if the contract or its handler cannot be found.
|
|
87
|
-
*/
|
|
88
|
-
getSpendablePaths(options: GetSpendablePathsOptions): Promise<PathSelection[]>;
|
|
89
|
-
/**
|
|
90
|
-
* Get all possible spending paths for a contract.
|
|
91
|
-
*
|
|
92
|
-
* Returns an empty array if the contract or its handler cannot be found.
|
|
93
|
-
*/
|
|
94
|
-
getAllSpendingPaths(options: GetAllSpendingPathsOptions): Promise<PathSelection[]>;
|
|
95
|
-
/**
|
|
96
|
-
* Subscribe to contract events.
|
|
97
|
-
*
|
|
98
|
-
* @returns Unsubscribe function
|
|
99
|
-
*/
|
|
100
|
-
onContractEvent(callback: ContractEventCallback): () => void;
|
|
101
|
-
/**
|
|
102
|
-
* Force a virtual output refresh from the indexer.
|
|
103
|
-
*
|
|
104
|
-
* Without options, refreshes all contracts from scratch.
|
|
105
|
-
* With options, narrows the refresh to specific scripts and/or a time window.
|
|
106
|
-
*/
|
|
107
|
-
refreshVtxos(opts?: RefreshVtxosOptions): Promise<void>;
|
|
108
|
-
/**
|
|
109
|
-
* Reconcile specific outpoints with the indexer's authoritative state and
|
|
110
|
-
* upsert the result into the wallet repository.
|
|
111
|
-
*
|
|
112
|
-
* The cursor-derived delta sync filters by `created_at`, so a VTXO that
|
|
113
|
-
* was created before the cursor but spent recently won't surface in a
|
|
114
|
-
* standard `refreshVtxos()` call. This method is the surgical recovery
|
|
115
|
-
* path for that case: when something hands us a stale outpoint (e.g. the
|
|
116
|
-
* server returns `VTXO_ALREADY_SPENT` with a `vtxo_outpoint` in its
|
|
117
|
-
* error metadata), call this to pull the latest state and unblock the
|
|
118
|
-
* caller — no full re-scan, no cursor change.
|
|
119
|
-
*
|
|
120
|
-
* Outpoints not owned by any tracked contract are silently dropped.
|
|
121
|
-
*/
|
|
122
|
-
refreshOutpoints(outpoints: Outpoint[]): Promise<void>;
|
|
123
|
-
/**
|
|
124
|
-
* Whether the underlying watcher is currently active.
|
|
125
|
-
*/
|
|
126
|
-
isWatching(): Promise<boolean>;
|
|
127
|
-
/**
|
|
128
|
-
* Release resources (stop watching, clear listeners).
|
|
129
|
-
*/
|
|
130
|
-
dispose(): void;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Options for getting spendable paths.
|
|
134
|
-
*/
|
|
135
|
-
export type GetSpendablePathsOptions = {
|
|
136
|
-
/** The contract script */
|
|
137
|
-
contractScript: string;
|
|
138
|
-
/** The specific virtual output being evaluated */
|
|
139
|
-
vtxo: VirtualCoin;
|
|
140
|
-
/** Whether collaborative spending is available (default: true) */
|
|
141
|
-
collaborative?: boolean;
|
|
142
|
-
/** Wallet's public key (hex) to determine role */
|
|
143
|
-
walletPubKey?: string;
|
|
144
|
-
};
|
|
145
|
-
/**
|
|
146
|
-
* Options for getting all possible spending paths.
|
|
147
|
-
*/
|
|
148
|
-
export type GetAllSpendingPathsOptions = {
|
|
149
|
-
/** The contract script */
|
|
150
|
-
contractScript: string;
|
|
151
|
-
/** Whether collaborative spending is available (default: true) */
|
|
152
|
-
collaborative?: boolean;
|
|
153
|
-
/** Wallet's public key (hex) to determine role */
|
|
154
|
-
walletPubKey?: string;
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* Configuration for the ContractManager.
|
|
158
|
-
*/
|
|
159
|
-
export interface ContractManagerConfig {
|
|
160
|
-
/** The indexer provider */
|
|
161
|
-
indexerProvider: IndexerProvider;
|
|
162
|
-
/** The contract repository for persistence */
|
|
163
|
-
contractRepository: ContractRepository;
|
|
164
|
-
/** The wallet repository for virtual output storage (single source of truth) */
|
|
165
|
-
walletRepository: WalletRepository;
|
|
166
|
-
/** Watcher configuration */
|
|
167
|
-
watcherConfig?: Partial<ContractWatcherConfig>;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Parameters for creating a new contract.
|
|
171
|
-
*/
|
|
172
|
-
export type CreateContractParams = Omit<Contract, "createdAt" | "state"> & {
|
|
173
|
-
/** Initial state (defaults to "active") */
|
|
174
|
-
state?: ContractState;
|
|
175
|
-
};
|
|
176
|
-
/**
|
|
177
|
-
* Central manager for contract lifecycle and operations.
|
|
178
|
-
*
|
|
179
|
-
* Responsibilities:
|
|
180
|
-
* - Create and persist contracts
|
|
181
|
-
* - Query stored contracts (optionally with their virtual outputs)
|
|
182
|
-
* - Provide spendable path selection for a contract
|
|
183
|
-
* - Emit contract-related events (virtual output received/spent, connection reset)
|
|
184
|
-
*
|
|
185
|
-
* Notes:
|
|
186
|
-
* - Implementations typically start watching automatically during initialization
|
|
187
|
-
* (so `onContractEvent()` is just for subscribing).
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* ```typescript
|
|
191
|
-
* const manager = await ContractManager.create({
|
|
192
|
-
* indexerProvider: wallet.indexerProvider,
|
|
193
|
-
* contractRepository: wallet.contractRepository,
|
|
194
|
-
* });
|
|
195
|
-
*
|
|
196
|
-
* // Create a new VHTLC contract
|
|
197
|
-
* const contract = await manager.createContract({
|
|
198
|
-
* label: "Lightning Receive",
|
|
199
|
-
* type: "vhtlc",
|
|
200
|
-
* params: { sender: "ark1q...", receiver: "ark1q...", ... },
|
|
201
|
-
* script: "5120...",
|
|
202
|
-
* address: "ark1q...",
|
|
203
|
-
* });
|
|
204
|
-
*
|
|
205
|
-
* // Start watching for events
|
|
206
|
-
* const unsubscribe = manager.onContractEvent((event) => {
|
|
207
|
-
* console.log(`${event.type} on ${event.contractScript}`);
|
|
208
|
-
* });
|
|
209
|
-
*
|
|
210
|
-
* // Query contracts together with their current virtual outputs
|
|
211
|
-
* const contractsWithVtxos = await manager.getContractsWithVtxos();
|
|
212
|
-
*
|
|
213
|
-
* // Get balance across all contracts
|
|
214
|
-
* const balances = contractsWithVtxos.flatMap(({vtxos}) => vtxos).reduce((acc, vtxo) => acc + vtxo.value, 0)
|
|
215
|
-
*
|
|
216
|
-
* // Later: unsubscribe from events
|
|
217
|
-
* unsubscribe();
|
|
218
|
-
*
|
|
219
|
-
* // Clean up
|
|
220
|
-
* manager.dispose();
|
|
221
|
-
* ```
|
|
222
|
-
*/
|
|
223
|
-
export declare class ContractManager implements IContractManager {
|
|
224
|
-
private config;
|
|
225
|
-
private watcher;
|
|
226
|
-
private initialized;
|
|
227
|
-
private eventCallbacks;
|
|
228
|
-
private stopWatcherFn?;
|
|
229
|
-
private constructor();
|
|
230
|
-
/**
|
|
231
|
-
* Static factory method for creating a new ContractManager.
|
|
232
|
-
* Initialize the manager by loading persisted contracts and starting to watch.
|
|
233
|
-
*
|
|
234
|
-
* After initialization, the manager automatically watches all active contracts
|
|
235
|
-
* and contracts with virtual outputs. Use `onContractEvent()` to register event callbacks.
|
|
236
|
-
*
|
|
237
|
-
* @param config ContractManagerConfig
|
|
238
|
-
*/
|
|
239
|
-
static create(config: ContractManagerConfig): Promise<ContractManager>;
|
|
240
|
-
private initialize;
|
|
241
|
-
/**
|
|
242
|
-
* Delta-sync the full watched set and reconcile the pending frontier.
|
|
243
|
-
*
|
|
244
|
-
* Shared recovery path used on initial boot and after a subscription
|
|
245
|
-
* reconnect. `syncContracts({})` scopes to the current watched set
|
|
246
|
-
* (see {@link ContractWatcher.getWatchedContracts}), uses the
|
|
247
|
-
* cursor-derived delta window, and advances the cursor on success.
|
|
248
|
-
* `reconcilePendingFrontier` catches not-yet-finalized virtual
|
|
249
|
-
* outputs that could sit outside any delta window.
|
|
250
|
-
*/
|
|
251
|
-
private reconcileWatched;
|
|
252
|
-
/**
|
|
253
|
-
* Create and register a new contract.
|
|
254
|
-
*
|
|
255
|
-
* @param params - Contract parameters
|
|
256
|
-
* @returns The created contract
|
|
257
|
-
*/
|
|
258
|
-
createContract(params: CreateContractParams): Promise<Contract>;
|
|
259
|
-
/**
|
|
260
|
-
* Get contracts with optional filters.
|
|
261
|
-
*
|
|
262
|
-
* @param filter - Optional filter criteria
|
|
263
|
-
* @returns Filtered contracts TODO: filter spent/unspent
|
|
264
|
-
*
|
|
265
|
-
* @example
|
|
266
|
-
* ```typescript
|
|
267
|
-
* // Get all VHTLC contracts
|
|
268
|
-
* const vhtlcs = await manager.getContracts({ type: 'vhtlc' });
|
|
269
|
-
*
|
|
270
|
-
* // Get all active contracts
|
|
271
|
-
* const active = await manager.getContracts({ state: 'active' });
|
|
272
|
-
* ```
|
|
273
|
-
*/
|
|
274
|
-
getContracts(filter?: GetContractsFilter): Promise<Contract[]>;
|
|
275
|
-
getContractsWithVtxos(filter?: GetContractsFilter, pageSize?: number): Promise<ContractWithVtxos[]>;
|
|
276
|
-
annotateVtxos(vtxos: VirtualCoin[]): Promise<ExtendedVirtualCoin[]>;
|
|
277
|
-
private buildContractsDbFilter;
|
|
278
|
-
/**
|
|
279
|
-
* Update a contract.
|
|
280
|
-
* Nested fields like `params` and `metadata` are replaced with the provided values.
|
|
281
|
-
* If you need to preserve existing fields, merge them manually.
|
|
282
|
-
*
|
|
283
|
-
* @param script - Contract script
|
|
284
|
-
* @param updates - Fields to update
|
|
285
|
-
*/
|
|
286
|
-
updateContract(script: string, updates: Partial<Omit<Contract, "script" | "createdAt">>): Promise<Contract>;
|
|
287
|
-
/**
|
|
288
|
-
* Update a contract's params.
|
|
289
|
-
* This method preserves existing params by merging the provided values.
|
|
290
|
-
*
|
|
291
|
-
* @param script - Contract script
|
|
292
|
-
* @param updates - The new values to merge with existing params
|
|
293
|
-
*/
|
|
294
|
-
updateContractParams(script: string, updates: Contract["params"]): Promise<Contract>;
|
|
295
|
-
/**
|
|
296
|
-
* Set a contract's state.
|
|
297
|
-
*/
|
|
298
|
-
setContractState(script: string, state: ContractState): Promise<void>;
|
|
299
|
-
/**
|
|
300
|
-
* Delete a contract.
|
|
301
|
-
*
|
|
302
|
-
* @param script - Contract script
|
|
303
|
-
*/
|
|
304
|
-
deleteContract(script: string): Promise<void>;
|
|
305
|
-
/**
|
|
306
|
-
* Get currently spendable paths for a contract.
|
|
307
|
-
*
|
|
308
|
-
* @param options - Options for getting spendable paths
|
|
309
|
-
*/
|
|
310
|
-
getSpendablePaths(options: GetSpendablePathsOptions): Promise<PathSelection[]>;
|
|
311
|
-
/**
|
|
312
|
-
* Get every currently valid spending path for a contract.
|
|
313
|
-
*
|
|
314
|
-
* @param options - Options for getting spending paths
|
|
315
|
-
*/
|
|
316
|
-
getAllSpendingPaths(options: GetAllSpendingPathsOptions): Promise<PathSelection[]>;
|
|
317
|
-
/**
|
|
318
|
-
* Register a callback for contract events.
|
|
319
|
-
*
|
|
320
|
-
* The manager automatically watches after `initialize()`. This method
|
|
321
|
-
* allows registering callbacks to receive events.
|
|
322
|
-
*
|
|
323
|
-
* @param callback - Event callback
|
|
324
|
-
* @returns Unsubscribe function to remove this callback
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
* ```typescript
|
|
328
|
-
* const unsubscribe = manager.onContractEvent((event) => {
|
|
329
|
-
* console.log(`${event.type} on ${event.contractScript}`);
|
|
330
|
-
* });
|
|
331
|
-
*
|
|
332
|
-
* // Later: stop receiving events
|
|
333
|
-
* unsubscribe();
|
|
334
|
-
* ```
|
|
335
|
-
*/
|
|
336
|
-
onContractEvent(callback: ContractEventCallback): () => void;
|
|
337
|
-
/**
|
|
338
|
-
* Force refresh virtual outputs from the indexer.
|
|
339
|
-
*
|
|
340
|
-
* Without options, re-fetches every contract in the watcher's
|
|
341
|
-
* watched set and advances the global cursor.
|
|
342
|
-
*
|
|
343
|
-
* `scripts` narrows the refresh to a specific list (subset query —
|
|
344
|
-
* cursor is not advanced because contracts outside the list may
|
|
345
|
-
* have data we'd skip).
|
|
346
|
-
*
|
|
347
|
-
* `includeInactive: true` (and no `scripts`) widens the refresh to
|
|
348
|
-
* every contract in the repository, including ones marked
|
|
349
|
-
* `inactive` and ones that have dropped out of the watcher's
|
|
350
|
-
* active set. This is a *superset* of the watched set, so the
|
|
351
|
-
* cursor invariant still holds and the cursor advances normally.
|
|
352
|
-
*
|
|
353
|
-
* `after` / `before` apply a caller-supplied time window. The
|
|
354
|
-
* cursor never advances on a windowed query because the window
|
|
355
|
-
* may skip data outside its bounds.
|
|
356
|
-
*/
|
|
357
|
-
refreshVtxos(opts?: RefreshVtxosOptions): Promise<void>;
|
|
358
|
-
refreshOutpoints(outpoints: Outpoint[]): Promise<void>;
|
|
359
|
-
/**
|
|
360
|
-
* Check if currently watching.
|
|
361
|
-
*/
|
|
362
|
-
isWatching(): Promise<boolean>;
|
|
363
|
-
/**
|
|
364
|
-
* Emit an event to all registered callbacks.
|
|
365
|
-
*/
|
|
366
|
-
private emitEvent;
|
|
367
|
-
/**
|
|
368
|
-
* Handle events from the watcher.
|
|
369
|
-
*/
|
|
370
|
-
private handleContractEvent;
|
|
371
|
-
private getVtxosForContracts;
|
|
372
|
-
/**
|
|
373
|
-
* Sync virtual outputs for the given contracts against the indexer.
|
|
374
|
-
*
|
|
375
|
-
* When `options.contracts` is omitted the sync covers the full
|
|
376
|
-
* watched set (active contracts plus any inactive contracts still
|
|
377
|
-
* holding cached VTXOs) and the global cursor is advanced on
|
|
378
|
-
* success. Passing an explicit subset leaves the cursor alone so a
|
|
379
|
-
* narrow poll can't hide data that other contracts still need to
|
|
380
|
-
* pick up.
|
|
381
|
-
*/
|
|
382
|
-
private syncContracts;
|
|
383
|
-
/**
|
|
384
|
-
* Fetch all pending (unfinalized) virtual outputs and upsert them into the
|
|
385
|
-
* repository. This catches virtual outputs whose state changed outside the delta
|
|
386
|
-
* window (e.g. a spend that hasn't settled yet).
|
|
387
|
-
*/
|
|
388
|
-
private reconcilePendingFrontier;
|
|
389
|
-
private fetchContractVxosFromIndexer;
|
|
390
|
-
private fetchContractVtxosBulk;
|
|
391
|
-
/**
|
|
392
|
-
* Dispose of the ContractManager and release all resources.
|
|
393
|
-
*
|
|
394
|
-
* Stops the watcher, clears callbacks, and marks
|
|
395
|
-
* the manager as uninitialized.
|
|
396
|
-
*
|
|
397
|
-
* Implements the disposable pattern for cleanup.
|
|
398
|
-
*/
|
|
399
|
-
dispose(): void;
|
|
400
|
-
/**
|
|
401
|
-
* Symbol.dispose implementation for using with `using` keyword.
|
|
402
|
-
* @example
|
|
403
|
-
* ```typescript
|
|
404
|
-
* {
|
|
405
|
-
* using manager = await wallet.getContractManager();
|
|
406
|
-
* // ... use manager
|
|
407
|
-
* } // automatically disposed
|
|
408
|
-
* ```
|
|
409
|
-
*/
|
|
410
|
-
[Symbol.dispose](): void;
|
|
411
|
-
}
|