@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,217 +0,0 @@
|
|
|
1
|
-
import { IndexerProvider } from "../providers/indexer.js";
|
|
2
|
-
import { WalletRepository } from "../repositories/walletRepository.js";
|
|
3
|
-
import { Contract, ContractEventCallback } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* Configuration for the ContractWatcher.
|
|
6
|
-
*
|
|
7
|
-
* @see ContractWatcher
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const watcher = new ContractWatcher({
|
|
12
|
-
* indexerProvider,
|
|
13
|
-
* walletRepository,
|
|
14
|
-
* })
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export interface ContractWatcherConfig {
|
|
18
|
-
/** Indexer provider used for subscriptions and queries. */
|
|
19
|
-
indexerProvider: IndexerProvider;
|
|
20
|
-
/** Wallet repository used to store virtual output state between watcher updates. */
|
|
21
|
-
walletRepository: WalletRepository;
|
|
22
|
-
/**
|
|
23
|
-
* Interval for failsafe polling (ms).
|
|
24
|
-
* Polls even when subscription is active to catch missed events.
|
|
25
|
-
*
|
|
26
|
-
* @defaultValue `60_000` (1 minute)
|
|
27
|
-
*/
|
|
28
|
-
failsafePollIntervalMs?: number;
|
|
29
|
-
/**
|
|
30
|
-
* Initial reconnection delay (ms).
|
|
31
|
-
* Uses exponential backoff on repeated failures.
|
|
32
|
-
*
|
|
33
|
-
* @defaultValue `1_000` (1 second)
|
|
34
|
-
*/
|
|
35
|
-
reconnectDelayMs?: number;
|
|
36
|
-
/**
|
|
37
|
-
* Maximum reconnection delay (ms).
|
|
38
|
-
*
|
|
39
|
-
* @defaultValue `30_000` (30 seconds)
|
|
40
|
-
*/
|
|
41
|
-
maxReconnectDelayMs?: number;
|
|
42
|
-
/**
|
|
43
|
-
* Maximum reconnection attempts before giving up.
|
|
44
|
-
* Set to 0 for unlimited attempts.
|
|
45
|
-
*
|
|
46
|
-
* @defaultValue `0` (unlimited)
|
|
47
|
-
*/
|
|
48
|
-
maxReconnectAttempts?: number;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Connection state for the watcher.
|
|
52
|
-
*/
|
|
53
|
-
type ConnectionState = "disconnected" | "connecting" | "connected" | "reconnecting";
|
|
54
|
-
/**
|
|
55
|
-
* Watches multiple contracts for virtual output state changes with resilient connection handling.
|
|
56
|
-
*
|
|
57
|
-
* Features:
|
|
58
|
-
* - Automatic reconnection with exponential backoff
|
|
59
|
-
* - Failsafe polling to catch missed events
|
|
60
|
-
* - Polls immediately after (re)connection to sync state
|
|
61
|
-
* - Graceful handling of subscription failures
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* const watcher = new ContractWatcher({
|
|
66
|
-
* indexerProvider: wallet.indexerProvider,
|
|
67
|
-
* });
|
|
68
|
-
*
|
|
69
|
-
* // Add the wallet's default contract
|
|
70
|
-
* await watcher.addContract(defaultContract);
|
|
71
|
-
*
|
|
72
|
-
* // Add additional contracts (swaps, etc.)
|
|
73
|
-
* await watcher.addContract(swapContract);
|
|
74
|
-
*
|
|
75
|
-
* // Start watching for events
|
|
76
|
-
* const stop = await watcher.startWatching((event) => {
|
|
77
|
-
* console.log(`${event.type} on contract ${event.contractScript}`);
|
|
78
|
-
* });
|
|
79
|
-
*
|
|
80
|
-
* // Later: stop watching
|
|
81
|
-
* stop();
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
export declare class ContractWatcher {
|
|
85
|
-
private config;
|
|
86
|
-
private contracts;
|
|
87
|
-
private subscriptionId?;
|
|
88
|
-
private abortController?;
|
|
89
|
-
private isWatching;
|
|
90
|
-
private eventCallback?;
|
|
91
|
-
private connectionState;
|
|
92
|
-
private reconnectAttempts;
|
|
93
|
-
private reconnectTimeoutId?;
|
|
94
|
-
private failsafePollIntervalId?;
|
|
95
|
-
/**
|
|
96
|
-
* Create a contract watcher with the given providers and polling settings.
|
|
97
|
-
*
|
|
98
|
-
* @param config - Contract watcher configuration
|
|
99
|
-
* @see ContractWatcherConfig
|
|
100
|
-
*/
|
|
101
|
-
constructor(config: ContractWatcherConfig);
|
|
102
|
-
/**
|
|
103
|
-
* Add a contract to be watched.
|
|
104
|
-
*
|
|
105
|
-
* Active contracts are immediately subscribed.
|
|
106
|
-
*
|
|
107
|
-
* All contracts are polled to discover any existing virtual outputs
|
|
108
|
-
* (which may cause them to be watched even if inactive).
|
|
109
|
-
*/
|
|
110
|
-
addContract(contract: Contract): Promise<void>;
|
|
111
|
-
/**
|
|
112
|
-
* Pre-populate `lastKnownVtxos` from the wallet repository.
|
|
113
|
-
*
|
|
114
|
-
* Runs on add (and can be re-run after reconnect) so polling always
|
|
115
|
-
* compares the indexer's view against what is already persisted,
|
|
116
|
-
* emitting only genuine deltas.
|
|
117
|
-
*/
|
|
118
|
-
private seedLastKnownVtxos;
|
|
119
|
-
/**
|
|
120
|
-
* Update an existing contract.
|
|
121
|
-
*/
|
|
122
|
-
updateContract(contract: Contract): Promise<void>;
|
|
123
|
-
/**
|
|
124
|
-
* Remove a contract from watching.
|
|
125
|
-
*/
|
|
126
|
-
removeContract(contractScript: string): Promise<void>;
|
|
127
|
-
/**
|
|
128
|
-
* Get all in-memory contracts.
|
|
129
|
-
*/
|
|
130
|
-
getAllContracts(): Contract[];
|
|
131
|
-
/**
|
|
132
|
-
* Contracts the watcher is actually tracking:
|
|
133
|
-
* - all active contracts, plus
|
|
134
|
-
* - inactive contracts that still hold known virtual outputs
|
|
135
|
-
* (the subscription keeps watching them so `vtxo_spent` events for
|
|
136
|
-
* those unspent outputs are still observed).
|
|
137
|
-
*
|
|
138
|
-
* This is the single source of truth for "contracts whose VTXO state
|
|
139
|
-
* we still care about" — callers and the subscription itself fan out
|
|
140
|
-
* over the same set so nothing is reconciled that isn't also watched.
|
|
141
|
-
*/
|
|
142
|
-
getWatchedContracts(): Contract[];
|
|
143
|
-
/**
|
|
144
|
-
* Get virtual outputs for contracts, grouped by contract script.
|
|
145
|
-
* @see WalletRepository for `repo`
|
|
146
|
-
*/
|
|
147
|
-
private getContractVtxos;
|
|
148
|
-
/**
|
|
149
|
-
* Start watching for virtual output events across all active contracts.
|
|
150
|
-
*/
|
|
151
|
-
startWatching(callback: ContractEventCallback): Promise<() => void>;
|
|
152
|
-
/**
|
|
153
|
-
* Stop watching for events.
|
|
154
|
-
*/
|
|
155
|
-
stopWatching(): Promise<void>;
|
|
156
|
-
/**
|
|
157
|
-
* Check if currently watching.
|
|
158
|
-
*/
|
|
159
|
-
isCurrentlyWatching(): boolean;
|
|
160
|
-
/**
|
|
161
|
-
* Get current connection state.
|
|
162
|
-
*/
|
|
163
|
-
getConnectionState(): ConnectionState;
|
|
164
|
-
/**
|
|
165
|
-
* Force a poll of all active contracts.
|
|
166
|
-
* Useful for manual refresh or after app resume.
|
|
167
|
-
*/
|
|
168
|
-
forcePoll(): Promise<void>;
|
|
169
|
-
/**
|
|
170
|
-
* Connect to the subscription.
|
|
171
|
-
*
|
|
172
|
-
* @param skipUpdate - Skip the leading `updateSubscription` call when
|
|
173
|
-
* the caller has already established `subscriptionId`.
|
|
174
|
-
*/
|
|
175
|
-
private connect;
|
|
176
|
-
/**
|
|
177
|
-
* Schedule a reconnection attempt.
|
|
178
|
-
*/
|
|
179
|
-
private scheduleReconnect;
|
|
180
|
-
/**
|
|
181
|
-
* Start the failsafe polling interval.
|
|
182
|
-
*/
|
|
183
|
-
private startFailsafePolling;
|
|
184
|
-
private pollAllContracts;
|
|
185
|
-
/**
|
|
186
|
-
* Poll specific contracts and emit events for changes.
|
|
187
|
-
*/
|
|
188
|
-
private pollContracts;
|
|
189
|
-
private tryUpdateSubscription;
|
|
190
|
-
/**
|
|
191
|
-
* Update the subscription with scripts that should be watched.
|
|
192
|
-
*
|
|
193
|
-
* Watches both active contracts and contracts with virtual outputs.
|
|
194
|
-
*/
|
|
195
|
-
private updateSubscription;
|
|
196
|
-
/**
|
|
197
|
-
* Main listening loop for subscription events.
|
|
198
|
-
*/
|
|
199
|
-
private listenLoop;
|
|
200
|
-
/**
|
|
201
|
-
* Handle a subscription update.
|
|
202
|
-
*/
|
|
203
|
-
private handleSubscriptionUpdate;
|
|
204
|
-
/**
|
|
205
|
-
* Process virtual outputs from subscription and route each VTXO to the
|
|
206
|
-
* single contract that actually locks it via `vtxo.script`. If the script
|
|
207
|
-
* doesn't match any watched contract, skip the VTXO rather than fan it
|
|
208
|
-
* out to every matching contract — fan-out produced phantom state in
|
|
209
|
-
* non-owning contracts that then never reconciled.
|
|
210
|
-
*/
|
|
211
|
-
private processSubscriptionVtxos;
|
|
212
|
-
/**
|
|
213
|
-
* Emit a virtual output event for a contract.
|
|
214
|
-
*/
|
|
215
|
-
private emitVtxoEvent;
|
|
216
|
-
}
|
|
217
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { DefaultVtxo } from "../../script/default.js";
|
|
2
|
-
import { RelativeTimelock } from "../../script/tapscript.js";
|
|
3
|
-
import { ContractHandler } from "../types.js";
|
|
4
|
-
/**
|
|
5
|
-
* Typed parameters for DefaultVtxo contracts.
|
|
6
|
-
*/
|
|
7
|
-
export interface DefaultContractParams {
|
|
8
|
-
pubKey: Uint8Array;
|
|
9
|
-
serverPubKey: Uint8Array;
|
|
10
|
-
csvTimelock: RelativeTimelock;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Handler for default wallet VTXOs.
|
|
14
|
-
*
|
|
15
|
-
* Default contracts use the standard forfeit + exit tapscript:
|
|
16
|
-
* - forfeit: (Alice + Server) multisig for collaborative spending
|
|
17
|
-
* - exit: (Alice) + CSV timelock for unilateral exit
|
|
18
|
-
*/
|
|
19
|
-
export declare const DefaultContractHandler: ContractHandler<DefaultContractParams, DefaultVtxo.Script>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { DelegateVtxo } from "../../script/delegate.js";
|
|
2
|
-
import { RelativeTimelock } from "../../script/tapscript.js";
|
|
3
|
-
import { ContractHandler } from "../types.js";
|
|
4
|
-
/**
|
|
5
|
-
* Typed parameters for DelegateVtxo contracts.
|
|
6
|
-
*/
|
|
7
|
-
export interface DelegateContractParams {
|
|
8
|
-
pubKey: Uint8Array;
|
|
9
|
-
serverPubKey: Uint8Array;
|
|
10
|
-
delegatePubKey: Uint8Array;
|
|
11
|
-
csvTimelock: RelativeTimelock;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Handler for delegate wallet virtual outputs.
|
|
15
|
-
*
|
|
16
|
-
* Delegate contracts extend the default tapscript with an additional delegate path:
|
|
17
|
-
* - forfeit: (Alice + Server) multisig for collaborative spending
|
|
18
|
-
* - exit: (Alice) + CSV timelock for unilateral exit
|
|
19
|
-
* - delegate: (Alice + Delegate + Server) multisig for delegated renewal
|
|
20
|
-
*/
|
|
21
|
-
export declare const DelegateContractHandler: ContractHandler<DelegateContractParams, DelegateVtxo.Script>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Contract, PathContext } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Resolve wallet's role from explicit role or by matching descriptor/pubkey.
|
|
4
|
-
*/
|
|
5
|
-
export declare function resolveRole(contract: Contract, context: PathContext): "sender" | "receiver" | undefined;
|
|
6
|
-
/**
|
|
7
|
-
* Check if an absolute (CLTV) locktime is currently satisfied.
|
|
8
|
-
*
|
|
9
|
-
* Following the BIP65 convention:
|
|
10
|
-
* - locktime < 500_000_000 → interpreted as a block height; compared against `context.blockHeight`
|
|
11
|
-
* - locktime >= 500_000_000 → interpreted as a Unix timestamp (seconds); compared against `context.currentTime`
|
|
12
|
-
*
|
|
13
|
-
* Returns false if the relevant context field is missing.
|
|
14
|
-
*/
|
|
15
|
-
export declare function isCltvSatisfied(context: PathContext, locktime: bigint): boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Check if a CSV timelock is currently satisfied for the given context/virtual output.
|
|
18
|
-
*/
|
|
19
|
-
export declare function isCsvSpendable(context: PathContext, sequence?: number): boolean;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { contractHandlers } from "./registry.js";
|
|
2
|
-
export { DefaultContractHandler } from "./default.js";
|
|
3
|
-
export type { DefaultContractParams } from "./default.js";
|
|
4
|
-
export { DelegateContractHandler } from "./delegate.js";
|
|
5
|
-
export type { DelegateContractParams } from "./delegate.js";
|
|
6
|
-
export { VHTLCContractHandler } from "./vhtlc.js";
|
|
7
|
-
export type { VHTLCContractParams } from "./vhtlc.js";
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { ContractHandler } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Registry for contract handlers.
|
|
4
|
-
*
|
|
5
|
-
* Each contract type ("default", "vhtlc", etc.) has a handler that knows
|
|
6
|
-
* how to create VtxoScripts, serialize params, and select spending paths.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* // Register a custom handler
|
|
11
|
-
* contractHandlers.register(myCustomHandler);
|
|
12
|
-
*
|
|
13
|
-
* // Get handler for a type
|
|
14
|
-
* const handler = contractHandlers.get("vhtlc");
|
|
15
|
-
* const script = handler.createScript(contract.params);
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
declare class ContractHandlerRegistry {
|
|
19
|
-
private handlers;
|
|
20
|
-
/**
|
|
21
|
-
* Register a contract handler.
|
|
22
|
-
*
|
|
23
|
-
* @param handler - The handler to register
|
|
24
|
-
* @throws If a handler for this type is already registered
|
|
25
|
-
*/
|
|
26
|
-
register(handler: ContractHandler<unknown>): void;
|
|
27
|
-
/**
|
|
28
|
-
* Get a handler by type.
|
|
29
|
-
*
|
|
30
|
-
* @param type - The contract type
|
|
31
|
-
* @returns The handler, or undefined if not found
|
|
32
|
-
*/
|
|
33
|
-
get(type: string): ContractHandler<unknown> | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* Get a handler by type, throwing if not found.
|
|
36
|
-
*
|
|
37
|
-
* @param type - The contract type
|
|
38
|
-
* @returns The handler
|
|
39
|
-
* @throws If no handler is registered for this type
|
|
40
|
-
*/
|
|
41
|
-
getOrThrow(type: string): ContractHandler<unknown>;
|
|
42
|
-
/**
|
|
43
|
-
* Check if a handler is registered.
|
|
44
|
-
*
|
|
45
|
-
* @param type - The contract type
|
|
46
|
-
*/
|
|
47
|
-
has(type: string): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Get all registered types.
|
|
50
|
-
*/
|
|
51
|
-
getRegisteredTypes(): string[];
|
|
52
|
-
/**
|
|
53
|
-
* Unregister a handler (mainly for testing).
|
|
54
|
-
*/
|
|
55
|
-
unregister(type: string): boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Clear all handlers (mainly for testing).
|
|
58
|
-
*/
|
|
59
|
-
clear(): void;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Global registry of contract handlers.
|
|
63
|
-
*/
|
|
64
|
-
export declare const contractHandlers: ContractHandlerRegistry;
|
|
65
|
-
export {};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { VHTLC } from "../../script/vhtlc.js";
|
|
2
|
-
import { RelativeTimelock } from "../../script/tapscript.js";
|
|
3
|
-
import { ContractHandler } from "../types.js";
|
|
4
|
-
/**
|
|
5
|
-
* Typed parameters for VHTLC contracts.
|
|
6
|
-
*/
|
|
7
|
-
export interface VHTLCContractParams {
|
|
8
|
-
sender: Uint8Array;
|
|
9
|
-
receiver: Uint8Array;
|
|
10
|
-
server: Uint8Array;
|
|
11
|
-
preimageHash: Uint8Array;
|
|
12
|
-
refundLocktime: bigint;
|
|
13
|
-
unilateralClaimDelay: RelativeTimelock;
|
|
14
|
-
unilateralRefundDelay: RelativeTimelock;
|
|
15
|
-
unilateralRefundWithoutReceiverDelay: RelativeTimelock;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Handler for Virtual Hash Time Lock Contract (VHTLC).
|
|
19
|
-
*
|
|
20
|
-
* VHTLC supports multiple spending paths:
|
|
21
|
-
*
|
|
22
|
-
* Collaborative paths (with server):
|
|
23
|
-
* - claim: Receiver + Server with preimage
|
|
24
|
-
* - refund: Sender + Receiver + Server
|
|
25
|
-
* - refundWithoutReceiver: Sender + Server after CLTV locktime
|
|
26
|
-
*
|
|
27
|
-
* Unilateral paths (without server):
|
|
28
|
-
* - unilateralClaim: Receiver with preimage after CSV delay
|
|
29
|
-
* - unilateralRefund: Sender + Receiver after CSV delay
|
|
30
|
-
* - unilateralRefundWithoutReceiver: Sender after CSV delay
|
|
31
|
-
*/
|
|
32
|
-
export declare const VHTLCContractHandler: ContractHandler<VHTLCContractParams, VHTLC.Script>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * from "./types.js";
|
|
2
|
-
export { contractHandlers } from "./handlers/index.js";
|
|
3
|
-
export { DefaultContractHandler } from "./handlers/index.js";
|
|
4
|
-
export type { DefaultContractParams } from "./handlers/index.js";
|
|
5
|
-
export { DelegateContractHandler } from "./handlers/index.js";
|
|
6
|
-
export type { DelegateContractParams } from "./handlers/index.js";
|
|
7
|
-
export { VHTLCContractHandler } from "./handlers/index.js";
|
|
8
|
-
export type { VHTLCContractParams } from "./handlers/index.js";
|
|
9
|
-
export { encodeArkContract, decodeArkContract, contractFromArkContract, contractFromArkContractWithAddress, isArkContract, } from "./arkcontract.js";
|
|
10
|
-
export type { ParsedArkContract } from "./arkcontract.js";
|
|
11
|
-
export { ContractWatcher } from "./contractWatcher.js";
|
|
12
|
-
export type { ContractWatcherConfig } from "./contractWatcher.js";
|
|
13
|
-
export { ContractManager } from "./contractManager.js";
|
|
14
|
-
export type { ContractManagerConfig, CreateContractParams, RefreshVtxosOptions, } from "./contractManager.js";
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import { Bytes } from "@scure/btc-signer/utils.js";
|
|
2
|
-
import { EncodedVtxoScript, TapLeafScript, VtxoScript } from "../script/base.js";
|
|
3
|
-
import { ExtendedVirtualCoin, VirtualCoin, TapLeaves } from "../wallet/index.js";
|
|
4
|
-
import { ContractFilter } from "../repositories/index.js";
|
|
5
|
-
/**
|
|
6
|
-
* Contract state indicating whether it should be actively monitored.
|
|
7
|
-
*/
|
|
8
|
-
export type ContractState = "active" | "inactive";
|
|
9
|
-
/**
|
|
10
|
-
* Represents a contract that can receive and manage virtual outputs.
|
|
11
|
-
*
|
|
12
|
-
* A contract is defined by its type and parameters, which together
|
|
13
|
-
* determine the VtxoScript (spending paths). The wallet's default
|
|
14
|
-
* receiving address is itself a contract of type "default".
|
|
15
|
-
*
|
|
16
|
-
* External services (Boltz swaps, atomic swaps, etc.) create additional
|
|
17
|
-
* contracts with their own types and parameters.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* const vhtlcContract: Contract = {
|
|
22
|
-
* type: "vhtlc",
|
|
23
|
-
* params: {
|
|
24
|
-
* sender: "ab12...",
|
|
25
|
-
* receiver: "cd34...",
|
|
26
|
-
* server: "ef56...",
|
|
27
|
-
* hash: "1234...",
|
|
28
|
-
* refundLocktime: "800000",
|
|
29
|
-
* // ... timelocks
|
|
30
|
-
* },
|
|
31
|
-
* script: "5120...",
|
|
32
|
-
* address: "ark1q...",
|
|
33
|
-
* state: "active",
|
|
34
|
-
* createdAt: 1704067200000,
|
|
35
|
-
* };
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export interface Contract {
|
|
39
|
-
/** Human-readable label for display purposes. */
|
|
40
|
-
label?: string;
|
|
41
|
-
/**
|
|
42
|
-
* Contract type identifier.
|
|
43
|
-
* Built-in types: "default", "vhtlc"
|
|
44
|
-
* Custom types can be registered via ContractHandler.
|
|
45
|
-
*/
|
|
46
|
-
type: string;
|
|
47
|
-
/**
|
|
48
|
-
* Type-specific parameters for constructing the VtxoScript.
|
|
49
|
-
* All values are serialized as strings (hex for bytes, string for bigint).
|
|
50
|
-
* The ContractHandler for this type knows how to interpret these.
|
|
51
|
-
*/
|
|
52
|
-
params: Record<string, string>;
|
|
53
|
-
/** The pkScript hex, used as the unique identifier and primary key for contracts. */
|
|
54
|
-
script: string;
|
|
55
|
-
/** Address derived from the contract script. */
|
|
56
|
-
address: string;
|
|
57
|
-
/** Current state of the contract. */
|
|
58
|
-
state: ContractState;
|
|
59
|
-
/** Unix timestamp in milliseconds when this contract was created. */
|
|
60
|
-
createdAt: number;
|
|
61
|
-
/**
|
|
62
|
-
* Optional metadata for external integrations.
|
|
63
|
-
*/
|
|
64
|
-
metadata?: Record<string, unknown>;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* A virtual output that has been associated with a specific contract.
|
|
68
|
-
*/
|
|
69
|
-
export type ContractVtxo = VirtualCoin & Partial<TapLeaves & EncodedVtxoScript> & {
|
|
70
|
-
extraWitness?: Bytes[];
|
|
71
|
-
contractScript: string;
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* A {@link ContractVtxo} with all taproot annotation fields required.
|
|
75
|
-
*
|
|
76
|
-
* Mirrors the {@link ExtendedVirtualCoin} / {@link VirtualCoin} split:
|
|
77
|
-
* - {@link ContractVtxo} carries `TapLeaves` and `EncodedVtxoScript` as
|
|
78
|
-
* `Partial<>` because VTXOs fetched raw from the indexer do not yet have
|
|
79
|
-
* taproot data.
|
|
80
|
-
* - `ExtendedContractVtxo` narrows those fields to required, guaranteeing
|
|
81
|
-
* that `annotateVtxos` has run and the taproot leaves are present.
|
|
82
|
-
*
|
|
83
|
-
* Use this type (instead of {@link ContractVtxo}) wherever the compiler
|
|
84
|
-
* should enforce that annotation has happened — e.g. `saveVtxos` and
|
|
85
|
-
* forfeit transaction construction.
|
|
86
|
-
*/
|
|
87
|
-
export type ExtendedContractVtxo = ExtendedVirtualCoin & {
|
|
88
|
-
contractScript: string;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Result of path selection, including the tapleaf to use and any extra witness data.
|
|
92
|
-
*/
|
|
93
|
-
export interface PathSelection {
|
|
94
|
-
/** Tapleaf script to use for spending. */
|
|
95
|
-
leaf: TapLeafScript;
|
|
96
|
-
/** Additional witness elements, for example a preimage for HTLC-like paths. */
|
|
97
|
-
extraWitness?: Bytes[];
|
|
98
|
-
/**
|
|
99
|
-
* nSequence for the spending input, BIP-68 encoded when the leaf
|
|
100
|
-
* uses CSV. Decode with `sequenceToTimelock`; do NOT use as an
|
|
101
|
-
* absolute `Transaction.lockTime`.
|
|
102
|
-
*/
|
|
103
|
-
sequence?: number;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Context for path selection decisions.
|
|
107
|
-
*/
|
|
108
|
-
export interface PathContext {
|
|
109
|
-
/** Whether collaborative spending is available through server cooperation. */
|
|
110
|
-
collaborative: boolean;
|
|
111
|
-
/** Current time in milliseconds. */
|
|
112
|
-
currentTime: number;
|
|
113
|
-
/** Current block height, when known. */
|
|
114
|
-
blockHeight?: number;
|
|
115
|
-
/**
|
|
116
|
-
* Wallet's descriptor for signing.
|
|
117
|
-
* Format: tr(pubkey) for static keys, tr([fingerprint/path']xpub/0/{index}) for HD.
|
|
118
|
-
* Used by handlers to determine wallet's role in multi-party contracts.
|
|
119
|
-
*/
|
|
120
|
-
walletDescriptor?: string;
|
|
121
|
-
/**
|
|
122
|
-
* Wallet's public key (x-only, 32 bytes hex).
|
|
123
|
-
* @deprecated Use walletDescriptor instead.
|
|
124
|
-
*/
|
|
125
|
-
walletPubKey?: string;
|
|
126
|
-
/**
|
|
127
|
-
* Explicit role override for multi-party contracts such as VHTLC.
|
|
128
|
-
* If not provided, the handler may derive the role by matching
|
|
129
|
-
* {@link walletDescriptor} (preferred) — or {@link walletPubKey} as a
|
|
130
|
-
* fallback — against the contract's sender/receiver params.
|
|
131
|
-
*/
|
|
132
|
-
role?: string;
|
|
133
|
-
/** The specific virtual output being evaluated. */
|
|
134
|
-
vtxo?: VirtualCoin;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Handler for a specific contract type.
|
|
138
|
-
*
|
|
139
|
-
* Each contract type (`default`, `vhtlc`, etc.) has a handler that knows how to:
|
|
140
|
-
* 1. Create the VtxoScript from parameters
|
|
141
|
-
* 2. Serialize/deserialize parameters for storage
|
|
142
|
-
* 3. Select the appropriate spending path based on context
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* ```typescript
|
|
146
|
-
* const vhtlcHandler: ContractHandler = {
|
|
147
|
-
* type: "vhtlc",
|
|
148
|
-
* createScript(params) {
|
|
149
|
-
* return new VHTLC.Script(this.deserializeParams(params));
|
|
150
|
-
* },
|
|
151
|
-
* selectPath(script, contract, context) {
|
|
152
|
-
* const vhtlc = script as VHTLC.Script;
|
|
153
|
-
* const preimage = contract.data?.preimage;
|
|
154
|
-
* if (context.collaborative && preimage) {
|
|
155
|
-
* return { leaf: vhtlc.claim(), extraWitness: [hex.decode(preimage)] };
|
|
156
|
-
* }
|
|
157
|
-
* // ... other paths
|
|
158
|
-
* },
|
|
159
|
-
* // ...
|
|
160
|
-
* };
|
|
161
|
-
* ```
|
|
162
|
-
*/
|
|
163
|
-
export interface ContractHandler<P = Record<string, unknown>, S extends VtxoScript = VtxoScript> {
|
|
164
|
-
/** Contract type managed by this handler. */
|
|
165
|
-
readonly type: string;
|
|
166
|
-
/**
|
|
167
|
-
* Create the VtxoScript from serialized parameters.
|
|
168
|
-
*
|
|
169
|
-
* @param params - Serialized contract parameters
|
|
170
|
-
* @returns Contract script instance
|
|
171
|
-
*/
|
|
172
|
-
createScript(params: Record<string, string>): S;
|
|
173
|
-
/**
|
|
174
|
-
* Serialize typed parameters to string key-value pairs.
|
|
175
|
-
*
|
|
176
|
-
* @param params - Typed contract parameters
|
|
177
|
-
* @returns Serialized key-value representation
|
|
178
|
-
*/
|
|
179
|
-
serializeParams(params: P): Record<string, string>;
|
|
180
|
-
/**
|
|
181
|
-
* Deserialize string key-value pairs to typed parameters.
|
|
182
|
-
*/
|
|
183
|
-
deserializeParams(params: Record<string, string>): P;
|
|
184
|
-
/**
|
|
185
|
-
* Select the preferred spending path based on contract state and context.
|
|
186
|
-
* Returns the best available path (e.g., collaborative over unilateral).
|
|
187
|
-
*
|
|
188
|
-
* @returns PathSelection if a viable path exists, null otherwise
|
|
189
|
-
*/
|
|
190
|
-
selectPath(script: S, contract: Contract, context: PathContext): PathSelection | null;
|
|
191
|
-
/**
|
|
192
|
-
* Get all possible spending paths for the current context.
|
|
193
|
-
* Returns empty array if no paths are available.
|
|
194
|
-
*
|
|
195
|
-
* Useful for showing users which spending options exist regardless of
|
|
196
|
-
* current spendability.
|
|
197
|
-
*/
|
|
198
|
-
getAllSpendingPaths(script: S, contract: Contract, context: PathContext): PathSelection[];
|
|
199
|
-
/**
|
|
200
|
-
* Get all currently spendable paths.
|
|
201
|
-
* Returns empty array if no paths are available.
|
|
202
|
-
*/
|
|
203
|
-
getSpendablePaths(script: S, contract: Contract, context: PathContext): PathSelection[];
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Event emitted when contract-related changes occur.
|
|
207
|
-
*/
|
|
208
|
-
export type ContractEvent = {
|
|
209
|
-
type: "vtxo_received";
|
|
210
|
-
contractScript: string;
|
|
211
|
-
vtxos: ContractVtxo[];
|
|
212
|
-
contract: Contract;
|
|
213
|
-
timestamp: number;
|
|
214
|
-
} | {
|
|
215
|
-
type: "vtxo_spent";
|
|
216
|
-
contractScript: string;
|
|
217
|
-
vtxos: ContractVtxo[];
|
|
218
|
-
contract: Contract;
|
|
219
|
-
timestamp: number;
|
|
220
|
-
} | {
|
|
221
|
-
type: "connection_reset";
|
|
222
|
-
timestamp: number;
|
|
223
|
-
};
|
|
224
|
-
/**
|
|
225
|
-
* Callback for contract events.
|
|
226
|
-
*/
|
|
227
|
-
export type ContractEventCallback = (event: ContractEvent) => void;
|
|
228
|
-
/**
|
|
229
|
-
* Options for retrieving contracts from the Contract Manager.
|
|
230
|
-
* Currently an alias of the repository's filter type but can be extended in the future.
|
|
231
|
-
*/
|
|
232
|
-
export type GetContractsFilter = ContractFilter;
|
|
233
|
-
/**
|
|
234
|
-
* Contract with its virtual outputs included.
|
|
235
|
-
*/
|
|
236
|
-
export type ContractWithVtxos = {
|
|
237
|
-
contract: Contract;
|
|
238
|
-
vtxos: ExtendedContractVtxo[];
|
|
239
|
-
};
|
|
240
|
-
/**
|
|
241
|
-
* Summary of a contract's balance.
|
|
242
|
-
*/
|
|
243
|
-
export interface ContractBalance {
|
|
244
|
-
/** Total balance (settled + pending) in satoshis */
|
|
245
|
-
total: number;
|
|
246
|
-
/** Spendable balance in satoshis */
|
|
247
|
-
spendable: number;
|
|
248
|
-
/** Number of virtual outputs in this contract */
|
|
249
|
-
vtxoCount: number;
|
|
250
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { ExtendedVirtualCoin, VirtualCoin } from "../wallet/index.js";
|
|
2
|
-
import type { WalletRepository } from "../repositories/walletRepository.js";
|
|
3
|
-
import type { Contract } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* Tier 1 helpers that enforce VTXO ownership at call sites that already know
|
|
6
|
-
* the intended contract script. Address-keyed repositories may still hand back
|
|
7
|
-
* legacy duplicate rows under the wrong bucket; these helpers gate reads and
|
|
8
|
-
* writes so a wrong-script row never wins.
|
|
9
|
-
*
|
|
10
|
-
* `script` is the authoritative ownership key. Equality is strict: a missing
|
|
11
|
-
* or empty `vtxo.script` never matches.
|
|
12
|
-
*/
|
|
13
|
-
export declare function vtxoOutpoint(vtxo: Pick<VirtualCoin, "txid" | "vout">): string;
|
|
14
|
-
export declare function isVtxoForScript(vtxo: Pick<VirtualCoin, "script">, script: string): boolean;
|
|
15
|
-
export declare function filterVtxosForScript<T extends Pick<VirtualCoin, "script">>(vtxos: T[], script: string): T[];
|
|
16
|
-
/**
|
|
17
|
-
* Background/indexer sync flavour: drop wrong-script rows and log enough
|
|
18
|
-
* context to identify each rejection. Returns only matching rows so the
|
|
19
|
-
* caller can keep going.
|
|
20
|
-
*/
|
|
21
|
-
export declare function warnAndFilterVtxosForScript<T extends Pick<VirtualCoin, "txid" | "vout" | "script">>(vtxos: T[], script: string, context: string): T[];
|
|
22
|
-
/**
|
|
23
|
-
* User-initiated transaction/signing flavour: throw before persisting or
|
|
24
|
-
* signing inconsistent ownership state. Silently skipping here would hide a
|
|
25
|
-
* serious bug in the wallet's spend path.
|
|
26
|
-
*/
|
|
27
|
-
export declare function validateVtxosForScript(vtxos: Array<Pick<VirtualCoin, "txid" | "vout" | "script">>, script: string, context: string): void;
|
|
28
|
-
/**
|
|
29
|
-
* Tier 2 dispatch helpers: route to script-scoped repository methods when
|
|
30
|
-
* available, falling back to Tier 1 address-based filtering otherwise.
|
|
31
|
-
*/
|
|
32
|
-
export declare function getVtxosForContract(repo: WalletRepository, contract: Pick<Contract, "script" | "address">): Promise<ExtendedVirtualCoin[]>;
|
|
33
|
-
export declare function saveVtxosForContract(repo: WalletRepository, contract: Pick<Contract, "script" | "address">, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|