@arkade-os/sdk 0.4.26 → 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 +36 -125
- 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 -629
- 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 -2
- package/dist/cjs/identity/index.js +0 -38
- package/dist/cjs/identity/seedIdentity.js +0 -461
- 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 -200
- 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 -302
- 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 -159
- package/dist/cjs/wallet/index.js +0 -82
- 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 -1173
- package/dist/cjs/wallet/unroll.js +0 -289
- 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 -2049
- 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 -473
- 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 -625
- 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 -1
- package/dist/esm/identity/index.js +0 -12
- package/dist/esm/identity/seedIdentity.js +0 -453
- 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 -297
- 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 -155
- package/dist/esm/wallet/index.js +0 -75
- 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 -1168
- package/dist/esm/wallet/unroll.js +0 -285
- 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 -2041
- 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 -469
- 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 -381
- 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 -233
- 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 -35
- package/dist/types/identity/hdCapableIdentity.d.ts +0 -44
- package/dist/types/identity/index.d.ts +0 -56
- package/dist/types/identity/seedIdentity.d.ts +0 -254
- 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 -93
- package/dist/types/wallet/index.d.ts +0 -755
- 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 -238
- 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 -360
- 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 -188
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
2
|
+
import { B as BatchStartedEvent, v as TreeSigningStartedEvent, w as TxTree, x as TreeNoncesEvent, y as BatchFinalizationEvent, z as BatchFinalizedEvent, D as BatchFailedEvent, F as TreeTxEvent, H as TreeSignatureEvent, h as SettlementEvent, W as WalletRepository, C as ContractRepository, b as WalletConfig, J as DescriptorProvider, e as IContractManager, K as Coin, E as ExtendedVirtualCoin, L as IReadonlyWallet, M as ReadonlyIdentity, N as Network, O as OnchainProvider, n as IndexerProvider, P as DelegatorProvider, Q as ReadonlyWalletConfig, o as RelativeTimelock, U as IReadonlyAssetManager, m as ArkProvider, X as NetworkName, Y as ArkInfo, Z as ArkAddress, c as WalletBalance, G as GetVtxosFilter, A as ArkTransaction, d as ExtendedCoin, _ as ContractManager, I as IWallet, $ as CSVMultisigTapscript, a as Identity, a0 as SettlementConfig, i as IAssetManager, a1 as VtxoManager, f as IDelegatorManager, S as SendBitcoinParams, g as SettleParams, R as Recipient, a2 as SignerSession, a3 as SignedIntent, a4 as Intent } from './ark-TZ1gXAXU.js';
|
|
3
|
+
import { TransactionOutput } from '@scure/btc-signer/psbt.js';
|
|
4
|
+
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-aaVGfWsV.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Batch namespace provides utilities for joining and processing batch session.
|
|
8
|
+
* The batch settlement process involves multiple events, this namespace provides abstractions and types to handle them.
|
|
9
|
+
* @see https://docs.arkadeos.com/learn/pillars/batch-swaps
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // use wallet handler or create a custom one
|
|
13
|
+
* const handler = wallet.createBatchHandler(intentId, inputs, expectedRecipients, musig2session);
|
|
14
|
+
*
|
|
15
|
+
* const abortController = new AbortController();
|
|
16
|
+
* // Get event stream from the Arkade provider
|
|
17
|
+
* const eventStream = arkProvider.getEventStream(
|
|
18
|
+
* abortController.signal,
|
|
19
|
+
* ['your-topic-1', 'your-topic-2']
|
|
20
|
+
* );
|
|
21
|
+
*
|
|
22
|
+
* // Join the batch and process events
|
|
23
|
+
* try {
|
|
24
|
+
* const commitmentTxid = await Batch.join(eventStream, handler);
|
|
25
|
+
* console.log('Batch completed with commitment:', commitmentTxid);
|
|
26
|
+
* } catch (error) {
|
|
27
|
+
* console.error('Batch processing failed:', error);
|
|
28
|
+
* } finally {
|
|
29
|
+
* abortController.abort();
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
declare namespace Batch {
|
|
34
|
+
interface Handler {
|
|
35
|
+
/**
|
|
36
|
+
* Called on BatchStarted event.
|
|
37
|
+
* @returns { skip: boolean } indicating whether the batch should be skipped or not.
|
|
38
|
+
*/
|
|
39
|
+
onBatchStarted(event: BatchStartedEvent): Promise<{
|
|
40
|
+
skip: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Called when tree signing starts.
|
|
44
|
+
* @param event The tree signing started event.
|
|
45
|
+
* @param vtxoTree The unsigned virtual output tree, reconstructed from the TreeTxEvent events.
|
|
46
|
+
* @returns Promise resolving to a boolean indicating whether to continue processing.
|
|
47
|
+
*/
|
|
48
|
+
onTreeSigningStarted(event: TreeSigningStartedEvent, vtxoTree: TxTree): Promise<{
|
|
49
|
+
skip: boolean;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Called when tree nonces are received.
|
|
53
|
+
* @param event The tree nonces event.
|
|
54
|
+
* @returns Promise resolving to a boolean indicating whether signing is complete.
|
|
55
|
+
*/
|
|
56
|
+
onTreeNonces(event: TreeNoncesEvent): Promise<{
|
|
57
|
+
fullySigned: boolean;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Called during batch finalization.
|
|
61
|
+
* @param event The batch finalization event.
|
|
62
|
+
* @param vtxoTree The signed virtual output tree, reconstructed from the TreeTxEvent events.
|
|
63
|
+
* @param connectorTree The connector transaction tree, reconstructed from the TreeTxEvent events.
|
|
64
|
+
*/
|
|
65
|
+
onBatchFinalization(event: BatchFinalizationEvent, vtxoTree?: TxTree, connectorTree?: TxTree): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Called when batch finalization completes successfully.
|
|
68
|
+
*
|
|
69
|
+
* @param event - Batch finalized event
|
|
70
|
+
*/
|
|
71
|
+
onBatchFinalized?(event: BatchFinalizedEvent): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Called when batch processing fails.
|
|
74
|
+
*
|
|
75
|
+
* @param event - Batch failed event
|
|
76
|
+
*/
|
|
77
|
+
onBatchFailed?(event: BatchFailedEvent): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Called for each virtual output tree transaction chunk received during batch processing.
|
|
80
|
+
*
|
|
81
|
+
* @param event - Tree transaction event
|
|
82
|
+
*/
|
|
83
|
+
onTreeTxEvent?(event: TreeTxEvent): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Called for each tree signature event received during batch processing.
|
|
86
|
+
*
|
|
87
|
+
* @param event - Tree signature event
|
|
88
|
+
*/
|
|
89
|
+
onTreeSignatureEvent?(event: TreeSignatureEvent): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Options for the join function.
|
|
93
|
+
*
|
|
94
|
+
* @property abortController - Abort controller used to cancel batch processing.
|
|
95
|
+
* @property skipVtxoTreeSigning - Ignore events related to the virtual output tree musig2 signing session.
|
|
96
|
+
* @property eventCallback - Callback invoked for each settlement event received while joining the batch.
|
|
97
|
+
*/
|
|
98
|
+
type JoinOptions = Partial<{
|
|
99
|
+
abortController: AbortController;
|
|
100
|
+
skipVtxoTreeSigning: boolean;
|
|
101
|
+
eventCallback: (event: SettlementEvent) => Promise<void>;
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* Start the state machine that will process the batch events and join a batch.
|
|
105
|
+
* @param eventIterator - The events stream to process.
|
|
106
|
+
* @param handler - How to react to events.
|
|
107
|
+
* @param options - Options.
|
|
108
|
+
*/
|
|
109
|
+
function join(eventIterator: AsyncIterableIterator<SettlementEvent>, handler: Handler, options?: JoinOptions): Promise<string>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Inputs the wallet hands to a {@link ReceiveRotatorFactory} when
|
|
114
|
+
* asking it to construct the rotator at boot. The factory uses these
|
|
115
|
+
* to look up the wallet's current display contract (or allocate a
|
|
116
|
+
* fresh receive descriptor). Note: no `offchainTapscript` here — the
|
|
117
|
+
* factory's job is allocation, not script construction. The wallet's
|
|
118
|
+
* orchestrator (`WalletReceiveRotator.resolveBoot`) handles the
|
|
119
|
+
* tapscript rebuild on top of the factory's result.
|
|
120
|
+
*/
|
|
121
|
+
interface ReceiveRotatorBootOpts {
|
|
122
|
+
walletRepository: WalletRepository;
|
|
123
|
+
contractRepository: ContractRepository;
|
|
124
|
+
serverPubKey: Uint8Array;
|
|
125
|
+
/**
|
|
126
|
+
* Expected contract family ("default" or "delegate"). When provided,
|
|
127
|
+
* boot will only consider contracts of this type when looking up the
|
|
128
|
+
* wallet's current display contract, preventing a default wallet from
|
|
129
|
+
* accidentally picking up a delegate contract or vice versa.
|
|
130
|
+
*/
|
|
131
|
+
expectedContractType?: "default" | "delegate";
|
|
132
|
+
/**
|
|
133
|
+
* Logger to receive rotation-failure + backoff diagnostics. Defaults
|
|
134
|
+
* to `console` when omitted. Any object implementing
|
|
135
|
+
* {@link Logger.error} works (winston, pino, Sentry breadcrumbs,
|
|
136
|
+
* the runtime's own logger).
|
|
137
|
+
*/
|
|
138
|
+
logger?: Logger;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Output of {@link ReceiveRotatorFactory.createReceiveRotator}: the
|
|
142
|
+
* constructed rotator paired with the receive pubkey it resolved at
|
|
143
|
+
* boot (either the existing tagged display contract's pubkey, or a
|
|
144
|
+
* freshly allocated one).
|
|
145
|
+
*/
|
|
146
|
+
interface ReceiveRotatorBoot {
|
|
147
|
+
rotator: WalletReceiveRotator;
|
|
148
|
+
receivePubkey: Uint8Array;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Result returned by {@link WalletReceiveRotator.resolveBoot} to the
|
|
152
|
+
* wallet: the rotator plus the offchain tapscript the wallet should
|
|
153
|
+
* actually use (rebuilt to the resolved boot pubkey when it differs
|
|
154
|
+
* from the identity's static pubkey), plus the {@link DescriptorProvider}
|
|
155
|
+
* the rotator was built around. The wallet retains the provider so
|
|
156
|
+
* spending paths can route per-input signing through
|
|
157
|
+
* {@link DescriptorProvider.signWithDescriptor} instead of the
|
|
158
|
+
* identity's index-0 key.
|
|
159
|
+
*/
|
|
160
|
+
interface ReceiveRotatorBootResult {
|
|
161
|
+
rotator: WalletReceiveRotator;
|
|
162
|
+
offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
|
|
163
|
+
provider: DescriptorProvider;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Opt-in extension to {@link DescriptorProvider} for providers that
|
|
167
|
+
* drive HD receive rotation. Implemented by {@link HDDescriptorProvider}
|
|
168
|
+
* out of the box; custom providers (HSMs, external signers, …) can also
|
|
169
|
+
* implement it when they want to participate.
|
|
170
|
+
*
|
|
171
|
+
* Kept out of the core `DescriptorProvider` interface so providers that
|
|
172
|
+
* only do allocation + signing don't have to know about the wallet's
|
|
173
|
+
* receive lifecycle. The wallet detects support via
|
|
174
|
+
* {@link hasReceiveRotatorFactory} (a duck-typed `instanceof`-style
|
|
175
|
+
* check) and falls back to {@link WalletReceiveRotator.defaultBoot}
|
|
176
|
+
* when the provider doesn't implement the extension.
|
|
177
|
+
*/
|
|
178
|
+
interface ReceiveRotatorFactory {
|
|
179
|
+
createReceiveRotator(opts: ReceiveRotatorBootOpts): Promise<ReceiveRotatorBoot | undefined>;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Minimal logging surface the rotator needs. `console` satisfies it
|
|
183
|
+
* out of the box; SDK consumers can pass a structured logger
|
|
184
|
+
* (winston / pino / Sentry adapter) via {@link ReceiveRotatorBootOpts}
|
|
185
|
+
* to capture rotation failures + backoff diagnostics through their
|
|
186
|
+
* own pipeline.
|
|
187
|
+
*/
|
|
188
|
+
interface Logger {
|
|
189
|
+
error(message: string, ...args: unknown[]): void;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Narrow surface the rotator needs from the wallet at runtime: the
|
|
193
|
+
* mutable display tapscript, the display contract's script hex, the
|
|
194
|
+
* contract manager (for subscribing + registering rotated contracts),
|
|
195
|
+
* and the display address (for the contract's `address` field).
|
|
196
|
+
*
|
|
197
|
+
* Kept as an interface so the rotator module avoids a circular
|
|
198
|
+
* dependency on `wallet.ts`. `Wallet` implements this surface
|
|
199
|
+
* structurally — no `implements` clause is required.
|
|
200
|
+
*/
|
|
201
|
+
interface RotatableWallet {
|
|
202
|
+
readonly defaultContractScript: string;
|
|
203
|
+
readonly network: {
|
|
204
|
+
hrp: string;
|
|
205
|
+
};
|
|
206
|
+
readonly arkServerPublicKey: Uint8Array;
|
|
207
|
+
readonly offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
|
|
208
|
+
/**
|
|
209
|
+
* @internal Sole sanctioned write path for `offchainTapscript`
|
|
210
|
+
* after construction. The rotator calls this once per rotation
|
|
211
|
+
* after persisting the new display contract.
|
|
212
|
+
*/
|
|
213
|
+
setOffchainTapscriptForRotation(tapscript: DefaultVtxo.Script | DelegateVtxo.Script): void;
|
|
214
|
+
getContractManager(): Promise<IContractManager>;
|
|
215
|
+
getAddress(): Promise<string>;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Owns the wallet's HD receive-rotation lifecycle.
|
|
219
|
+
*
|
|
220
|
+
* The rotator is constructed only when the wallet's `walletMode`
|
|
221
|
+
* resolves to a {@link DescriptorProvider}; static wallets and
|
|
222
|
+
* non-HD-capable wallets under `'auto'` never see one.
|
|
223
|
+
*
|
|
224
|
+
* Lifecycle:
|
|
225
|
+
* 1. `resolveBoot()` — pre-Wallet-construction. Resolves the provider
|
|
226
|
+
* from `walletMode`, then either reuses the existing display
|
|
227
|
+
* contract's pubkey (if any) or allocates the first descriptor.
|
|
228
|
+
* Returns the rotator paired with the boot pubkey.
|
|
229
|
+
* 2. `install(wallet)` — post-`getVtxoManager()`. Subscribes to
|
|
230
|
+
* `vtxo_received` on the contract manager and routes matching events
|
|
231
|
+
* through the rotation chain.
|
|
232
|
+
* 3. `dispose()` — tears down the subscription and drains any in-flight
|
|
233
|
+
* rotation so the contract manager can be disposed cleanly.
|
|
234
|
+
*
|
|
235
|
+
* This class follows the dotnet-sdk's split of responsibilities: the
|
|
236
|
+
* provider is a pure rotating allocator; "what address am I currently
|
|
237
|
+
* bound to?" is answered by querying the contract repository, not by
|
|
238
|
+
* asking the provider.
|
|
239
|
+
*/
|
|
240
|
+
declare class WalletReceiveRotator {
|
|
241
|
+
private readonly provider;
|
|
242
|
+
private unsubscribe?;
|
|
243
|
+
private chain;
|
|
244
|
+
/**
|
|
245
|
+
* Script of the most-recent tagged display contract — populated
|
|
246
|
+
* either from the boot-time repo lookup or from the previous
|
|
247
|
+
* `rotate()` call within this session. The next `rotate()` marks
|
|
248
|
+
* this contract `inactive` once the new tagged contract is in
|
|
249
|
+
* place. `undefined` means the wallet's current display is the
|
|
250
|
+
* untagged index-0 baseline (no rotation has happened yet on this
|
|
251
|
+
* repo), and the baseline must NOT be deactivated.
|
|
252
|
+
*/
|
|
253
|
+
private currentTaggedScript;
|
|
254
|
+
/**
|
|
255
|
+
* Consecutive rotation failures since the last successful rotate.
|
|
256
|
+
* Drives an exponential backoff (capped at
|
|
257
|
+
* {@link ROTATION_MAX_BACKOFF_MS}) so a broken provider can't make
|
|
258
|
+
* the rotator hammer `getNextSigningDescriptor` + `createContract`
|
|
259
|
+
* on every inbound VTXO. Reset to zero on a successful rotate.
|
|
260
|
+
*/
|
|
261
|
+
private consecutiveFailures;
|
|
262
|
+
/**
|
|
263
|
+
* Unix-ms timestamp before which incoming `vtxo_received` events
|
|
264
|
+
* skip the rotation attempt entirely. Zero means "no backoff
|
|
265
|
+
* active" — the next event can rotate immediately.
|
|
266
|
+
*/
|
|
267
|
+
private nextRotationAllowedAt;
|
|
268
|
+
private readonly logger;
|
|
269
|
+
private constructor();
|
|
270
|
+
/**
|
|
271
|
+
* Phase 1 — pre-Wallet-construction. Resolves `walletMode` to a
|
|
272
|
+
* {@link DescriptorProvider}, then asks that provider to construct
|
|
273
|
+
* the rotator (delegated through
|
|
274
|
+
* {@link DescriptorProvider.createReceiveRotator}, which falls back
|
|
275
|
+
* to {@link defaultBoot} when the provider doesn't override it).
|
|
276
|
+
*
|
|
277
|
+
* Returns the rotator paired with the offchain tapscript the wallet
|
|
278
|
+
* should actually install (rebuilt to the resolved receive pubkey
|
|
279
|
+
* when it differs from the identity's static pubkey), or
|
|
280
|
+
* `undefined` when the wallet should stay on the static path.
|
|
281
|
+
*
|
|
282
|
+
* Errors during pubkey resolution propagate when:
|
|
283
|
+
* - `walletMode === 'hd'` (caller asked for HD; loud failure expected).
|
|
284
|
+
* - `walletMode` is a {@link DescriptorProvider} (caller supplied an
|
|
285
|
+
* explicit allocator; silently degrading would hide misconfig).
|
|
286
|
+
*
|
|
287
|
+
* Errors are silently swallowed (returning `undefined`) only under
|
|
288
|
+
* `walletMode: 'auto'` with the built-in HD provider, to preserve
|
|
289
|
+
* backwards compatibility with wallets whose identity descriptor
|
|
290
|
+
* isn't actually rangeable.
|
|
291
|
+
*/
|
|
292
|
+
static resolveBoot(config: WalletConfig, setup: ReceiveRotatorBootOpts & {
|
|
293
|
+
offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
|
|
294
|
+
}): Promise<ReceiveRotatorBootResult | undefined>;
|
|
295
|
+
/**
|
|
296
|
+
* Default factory-shaped boot any
|
|
297
|
+
* {@link ReceiveRotatorFactory.createReceiveRotator} implementation
|
|
298
|
+
* can delegate to. Pulls the wallet's current display contract from
|
|
299
|
+
* the contract repository (or allocates a fresh receive descriptor
|
|
300
|
+
* via the provider when no tagged display contract exists), and
|
|
301
|
+
* returns the rotator paired with the resolved receive pubkey.
|
|
302
|
+
*
|
|
303
|
+
* Used internally by `resolveBoot` when the provider doesn't
|
|
304
|
+
* implement {@link ReceiveRotatorFactory}. Exported so providers
|
|
305
|
+
* that *do* override can still invoke the default work for the
|
|
306
|
+
* parts of the boot path they don't want to customise. Tapscript
|
|
307
|
+
* construction is intentionally NOT in here — that's the
|
|
308
|
+
* orchestrator's job.
|
|
309
|
+
*/
|
|
310
|
+
static defaultBoot(provider: DescriptorProvider, opts: ReceiveRotatorBootOpts): Promise<ReceiveRotatorBoot>;
|
|
311
|
+
/**
|
|
312
|
+
* Phase 2 — post-`getVtxoManager()`. Subscribe to `vtxo_received`
|
|
313
|
+
* and trigger a rotation whenever the currently-active display
|
|
314
|
+
* contract receives funds. Old display contracts remain `active`
|
|
315
|
+
* in the repo so earlier shared addresses keep crediting this
|
|
316
|
+
* wallet.
|
|
317
|
+
*/
|
|
318
|
+
install(wallet: RotatableWallet): Promise<void>;
|
|
319
|
+
/**
|
|
320
|
+
* Run a single rotation attempt, applying exponential backoff on
|
|
321
|
+
* failure. Public-shaped behavior:
|
|
322
|
+
* - During a backoff window: log + skip (no `rotate()` call).
|
|
323
|
+
* - On success: reset failure count and backoff.
|
|
324
|
+
* - On failure: increment counter, schedule next attempt at
|
|
325
|
+
* `min(2^consecutiveFailures * 1s, ROTATION_MAX_BACKOFF_MS)`.
|
|
326
|
+
*
|
|
327
|
+
* Errors are deliberately swallowed (logged, not rethrown) so the
|
|
328
|
+
* surrounding `chain` Promise never settles to rejected — the next
|
|
329
|
+
* `vtxo_received` event must still get a chance to run.
|
|
330
|
+
*/
|
|
331
|
+
private runRotateWithBackoff;
|
|
332
|
+
/**
|
|
333
|
+
* Wait for any in-flight rotation to complete. Useful in tests
|
|
334
|
+
* that need to observe the post-rotation state after dispatching
|
|
335
|
+
* a `vtxo_received` event synchronously; production code rarely
|
|
336
|
+
* needs to call this directly.
|
|
337
|
+
*/
|
|
338
|
+
drain(): Promise<void>;
|
|
339
|
+
/**
|
|
340
|
+
* Tear down the subscription first so no late `vtxo_received` event
|
|
341
|
+
* can queue work on a disposing wallet, then drain any in-flight
|
|
342
|
+
* rotation so its `createContract` finishes before the contract
|
|
343
|
+
* manager itself disposes.
|
|
344
|
+
*/
|
|
345
|
+
dispose(): Promise<void>;
|
|
346
|
+
/**
|
|
347
|
+
* Allocate the next descriptor, swap it into the wallet's active
|
|
348
|
+
* offchain tapscript, register the new tagged contract, and retire
|
|
349
|
+
* the previous tagged contract (if any) by setting its state to
|
|
350
|
+
* `inactive`. The contract watcher keeps watching inactive
|
|
351
|
+
* contracts until their VTXOs are spent, so funds in flight at the
|
|
352
|
+
* old display address are not lost — only the address stops being
|
|
353
|
+
* advertised.
|
|
354
|
+
*
|
|
355
|
+
* Contract type matches the wallet's tapscript shape: a default
|
|
356
|
+
* wallet rotates to a new `default` contract, a delegate wallet to
|
|
357
|
+
* a new `delegate` contract.
|
|
358
|
+
*
|
|
359
|
+
* The first rotation on a fresh wallet does NOT deactivate
|
|
360
|
+
* anything: `currentTaggedScript` is `undefined` because the wallet
|
|
361
|
+
* was displaying the untagged index-0 baseline, which must stay
|
|
362
|
+
* active forever.
|
|
363
|
+
*/
|
|
364
|
+
private rotate;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
type IncomingFunds = {
|
|
368
|
+
type: "utxo";
|
|
369
|
+
coins: Coin[];
|
|
370
|
+
} | {
|
|
371
|
+
type: "vtxo";
|
|
372
|
+
newVtxos: ExtendedVirtualCoin[];
|
|
373
|
+
spentVtxos: ExtendedVirtualCoin[];
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
declare class ReadonlyWallet implements IReadonlyWallet {
|
|
377
|
+
readonly identity: ReadonlyIdentity;
|
|
378
|
+
readonly network: Network;
|
|
379
|
+
readonly onchainProvider: OnchainProvider;
|
|
380
|
+
readonly indexerProvider: IndexerProvider;
|
|
381
|
+
readonly arkServerPublicKey: Bytes;
|
|
382
|
+
readonly boardingTapscript: DefaultVtxo.Script;
|
|
383
|
+
readonly dustAmount: bigint;
|
|
384
|
+
readonly walletRepository: WalletRepository;
|
|
385
|
+
readonly contractRepository: ContractRepository;
|
|
386
|
+
readonly delegatorProvider?: DelegatorProvider | undefined;
|
|
387
|
+
private _contractManager?;
|
|
388
|
+
private _contractManagerInitializing?;
|
|
389
|
+
protected readonly watcherConfig?: ReadonlyWalletConfig["watcherConfig"];
|
|
390
|
+
private readonly _assetManager;
|
|
391
|
+
private _syncVtxosInflight?;
|
|
392
|
+
readonly walletContractTimelocks: RelativeTimelock[];
|
|
393
|
+
protected _pendingSpendOutpoints: Set<string>;
|
|
394
|
+
get assetManager(): IReadonlyAssetManager;
|
|
395
|
+
/**
|
|
396
|
+
* Backing field for the active receive tapscript. Read via the
|
|
397
|
+
* public `offchainTapscript` getter; written only by
|
|
398
|
+
* {@link Wallet.setOffchainTapscriptForRotation}, which
|
|
399
|
+
* {@link WalletReceiveRotator.rotate} is the sole intended caller of.
|
|
400
|
+
*/
|
|
401
|
+
protected _offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
|
|
402
|
+
protected constructor(identity: ReadonlyIdentity, network: Network, onchainProvider: OnchainProvider, indexerProvider: IndexerProvider, arkServerPublicKey: Bytes, offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script, boardingTapscript: DefaultVtxo.Script, dustAmount: bigint, walletRepository: WalletRepository, contractRepository: ContractRepository, delegatorProvider?: DelegatorProvider | undefined, watcherConfig?: ReadonlyWalletConfig["watcherConfig"], walletContractTimelocks?: RelativeTimelock[]);
|
|
403
|
+
/**
|
|
404
|
+
* Currently-active receive tapscript. Read-only from the outside;
|
|
405
|
+
* mutated only via {@link Wallet.setOffchainTapscriptForRotation}
|
|
406
|
+
* by {@link WalletReceiveRotator.rotate}.
|
|
407
|
+
*/
|
|
408
|
+
get offchainTapscript(): DefaultVtxo.Script | DelegateVtxo.Script;
|
|
409
|
+
/**
|
|
410
|
+
* Protected helper to set up shared wallet configuration.
|
|
411
|
+
* Extracts common logic used by both ReadonlyWallet.create() and Wallet.create().
|
|
412
|
+
*/
|
|
413
|
+
protected static setupWalletConfig(config: ReadonlyWalletConfig, pubKey: Uint8Array): Promise<{
|
|
414
|
+
arkProvider: ArkProvider;
|
|
415
|
+
indexerProvider: IndexerProvider;
|
|
416
|
+
onchainProvider: OnchainProvider;
|
|
417
|
+
network: Network;
|
|
418
|
+
networkName: NetworkName;
|
|
419
|
+
serverPubKey: Uint8Array<ArrayBuffer>;
|
|
420
|
+
offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
|
|
421
|
+
boardingTapscript: DefaultVtxo.Script;
|
|
422
|
+
dustAmount: bigint;
|
|
423
|
+
walletRepository: WalletRepository;
|
|
424
|
+
contractRepository: ContractRepository;
|
|
425
|
+
info: ArkInfo;
|
|
426
|
+
delegatorProvider: DelegatorProvider | undefined;
|
|
427
|
+
walletContractTimelocks: RelativeTimelock[];
|
|
428
|
+
}>;
|
|
429
|
+
/**
|
|
430
|
+
* Create a readonly wallet for querying balances, addresses, and history.
|
|
431
|
+
*
|
|
432
|
+
* @param config - Readonly wallet configuration
|
|
433
|
+
* @returns A readonly wallet instance
|
|
434
|
+
*/
|
|
435
|
+
static create(config: ReadonlyWalletConfig): Promise<ReadonlyWallet>;
|
|
436
|
+
get arkAddress(): ArkAddress;
|
|
437
|
+
/**
|
|
438
|
+
* Get the pkScript hex for the wallet's primary offchain address.
|
|
439
|
+
* For the full wallet-owned script set registered in ContractManager, use getWalletScripts().
|
|
440
|
+
*/
|
|
441
|
+
get defaultContractScript(): string;
|
|
442
|
+
/** Returns the wallet's Arkade address. */
|
|
443
|
+
getAddress(): Promise<string>;
|
|
444
|
+
/** Returns the onchain boarding address used to move funds into Arkade. */
|
|
445
|
+
getBoardingAddress(): Promise<string>;
|
|
446
|
+
/**
|
|
447
|
+
* Return the wallet's combined onchain and offchain balances.
|
|
448
|
+
*/
|
|
449
|
+
getBalance(): Promise<WalletBalance>;
|
|
450
|
+
/**
|
|
451
|
+
* Return virtual outputs tracked by the wallet.
|
|
452
|
+
*
|
|
453
|
+
* @param filter - Optional flags controlling whether recoverable or unrolled VTXOs are included
|
|
454
|
+
*/
|
|
455
|
+
getVtxos(filter?: GetVtxosFilter): Promise<ExtendedVirtualCoin[]>;
|
|
456
|
+
/**
|
|
457
|
+
* Return wallet transaction history derived from Arkade state and boarding transactions.
|
|
458
|
+
*/
|
|
459
|
+
getTransactionHistory(): Promise<ArkTransaction[]>;
|
|
460
|
+
/**
|
|
461
|
+
* Clear the global VTXO sync cursor, forcing a full re-bootstrap on next sync.
|
|
462
|
+
* Useful for recovery after indexer reprocessing or debugging.
|
|
463
|
+
*/
|
|
464
|
+
clearSyncCursor(): Promise<void>;
|
|
465
|
+
/**
|
|
466
|
+
* Build a transaction history view for the wallet's boarding address.
|
|
467
|
+
*/
|
|
468
|
+
getBoardingTxs(): Promise<{
|
|
469
|
+
boardingTxs: ArkTransaction[];
|
|
470
|
+
commitmentsToIgnore: Set<string>;
|
|
471
|
+
}>;
|
|
472
|
+
/**
|
|
473
|
+
* Fetch and cache onchain inputs (UTXOs) received at the boarding address.
|
|
474
|
+
*/
|
|
475
|
+
getBoardingUtxos(): Promise<ExtendedCoin[]>;
|
|
476
|
+
/**
|
|
477
|
+
* Subscribe to onchain and offchain notifications for newly received funds.
|
|
478
|
+
*
|
|
479
|
+
* @param eventCallback - Callback invoked when matching funds are detected
|
|
480
|
+
* @returns A function that stops the subscriptions
|
|
481
|
+
*/
|
|
482
|
+
notifyIncomingFunds(eventCallback: (coins: IncomingFunds) => void): Promise<() => void>;
|
|
483
|
+
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
484
|
+
fetchPendingTxs(): Promise<string[]>;
|
|
485
|
+
/**
|
|
486
|
+
* Get all pkScript hex strings for the wallet's own addresses
|
|
487
|
+
* (both delegate and non-delegate, current and historical).
|
|
488
|
+
*/
|
|
489
|
+
getWalletScripts(): Promise<string[]>;
|
|
490
|
+
/**
|
|
491
|
+
* Build a map of scriptHex → VtxoScript for all wallet contracts,
|
|
492
|
+
* so virtual outputs can be extended with the correct tapscript per contract.
|
|
493
|
+
*/
|
|
494
|
+
getScriptMap(): Promise<Map<string, DefaultVtxo.Script | DelegateVtxo.Script>>;
|
|
495
|
+
/**
|
|
496
|
+
* Get the ContractManager for managing contracts including the wallet's default address.
|
|
497
|
+
*
|
|
498
|
+
* The ContractManager handles:
|
|
499
|
+
* - The wallet's default receiving address (as a "default" contract)
|
|
500
|
+
* - External contracts (Boltz swaps, HTLCs, etc.)
|
|
501
|
+
* - Multi-contract watching with resilient connections
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
* ```typescript
|
|
505
|
+
* const manager = await wallet.getContractManager();
|
|
506
|
+
*
|
|
507
|
+
* // Create a contract for a Boltz swap
|
|
508
|
+
* const contract = await manager.createContract({
|
|
509
|
+
* label: "Boltz Swap",
|
|
510
|
+
* type: "vhtlc",
|
|
511
|
+
* params: { ... },
|
|
512
|
+
* script: swapScript,
|
|
513
|
+
* address: swapAddress,
|
|
514
|
+
* });
|
|
515
|
+
*
|
|
516
|
+
* // Start watching for events (includes wallet's default address)
|
|
517
|
+
* const stop = await manager.onContractEvent((event) => {
|
|
518
|
+
* console.log(`${event.type} on ${event.contractScript}`);
|
|
519
|
+
* });
|
|
520
|
+
* ```
|
|
521
|
+
*/
|
|
522
|
+
getContractManager(): Promise<ContractManager>;
|
|
523
|
+
private initializeContractManager;
|
|
524
|
+
/** Dispose wallet-owned managers and release background resources. */
|
|
525
|
+
dispose(): Promise<void>;
|
|
526
|
+
/** Async-dispose hook that forwards to `dispose()`. */
|
|
527
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Main wallet implementation for Bitcoin transactions with Arkade protocol support.
|
|
531
|
+
* The wallet does not store any data locally and relies on Arkade and onchain
|
|
532
|
+
* providers to fetch onchain and virtual outputs.
|
|
533
|
+
*
|
|
534
|
+
* @example
|
|
535
|
+
* ```typescript
|
|
536
|
+
* // Create a wallet with URL configuration
|
|
537
|
+
* const wallet = await Wallet.create({
|
|
538
|
+
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
|
|
539
|
+
* arkServerUrl: 'https://arkade.computer',
|
|
540
|
+
* esploraUrl: 'https://mempool.space/api'
|
|
541
|
+
* });
|
|
542
|
+
*
|
|
543
|
+
* // Or with custom provider instances (e.g., for Expo/React Native)
|
|
544
|
+
* const wallet = await Wallet.create({
|
|
545
|
+
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
|
|
546
|
+
* arkProvider: new ExpoArkProvider('https://arkade.computer'),
|
|
547
|
+
* indexerProvider: new ExpoIndexerProvider('https://arkade.computer'),
|
|
548
|
+
* esploraUrl: 'https://mempool.space/api'
|
|
549
|
+
* });
|
|
550
|
+
*
|
|
551
|
+
* // Get addresses
|
|
552
|
+
* const arkAddress = await wallet.getAddress();
|
|
553
|
+
* const boardingAddress = await wallet.getBoardingAddress();
|
|
554
|
+
*
|
|
555
|
+
* // Send bitcoin
|
|
556
|
+
* const txid = await wallet.send({
|
|
557
|
+
* address: 'ark1q...',
|
|
558
|
+
* amount: 50000,
|
|
559
|
+
* });
|
|
560
|
+
* ```
|
|
561
|
+
*/
|
|
562
|
+
declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
563
|
+
readonly arkProvider: ArkProvider;
|
|
564
|
+
readonly serverUnrollScript: CSVMultisigTapscript.Type;
|
|
565
|
+
readonly forfeitOutputScript: Bytes;
|
|
566
|
+
readonly forfeitPubkey: Bytes;
|
|
567
|
+
static MIN_FEE_RATE: number;
|
|
568
|
+
readonly identity: Identity;
|
|
569
|
+
private readonly _delegatorManager?;
|
|
570
|
+
private _vtxoManager?;
|
|
571
|
+
private _vtxoManagerInitializing?;
|
|
572
|
+
private _walletAssetManager?;
|
|
573
|
+
/**
|
|
574
|
+
* HD receive rotator. Owns the {@link DescriptorProvider}, the
|
|
575
|
+
* `vtxo_received` subscription, and the rotate-and-register
|
|
576
|
+
* lifecycle. Absent in `walletMode: 'static'` and for SingleKey
|
|
577
|
+
* wallets under `'auto'`. Wired in via the constructor; the actual
|
|
578
|
+
* subscription is installed lazily on first `getVtxoManager()` so
|
|
579
|
+
* the contract manager is up first.
|
|
580
|
+
*/
|
|
581
|
+
private _receiveRotator?;
|
|
582
|
+
private _receiveRotatorInstalled;
|
|
583
|
+
/**
|
|
584
|
+
* Descriptor-aware signer used by {@link _signerRouter} to sign
|
|
585
|
+
* inputs locked by rotated pubkeys. Same instance the rotator owns;
|
|
586
|
+
* stashed here so the spending paths don't have to reach inside the
|
|
587
|
+
* rotator. Undefined for static / non-HD-capable wallets — those
|
|
588
|
+
* paths only ever take the identity-sign branch.
|
|
589
|
+
*/
|
|
590
|
+
private readonly _descriptorProvider?;
|
|
591
|
+
private readonly _signerRouter;
|
|
592
|
+
/**
|
|
593
|
+
* @internal Sole write path for `offchainTapscript` after construction.
|
|
594
|
+
* Called by {@link WalletReceiveRotator.rotate} once the rotated
|
|
595
|
+
* display contract has been persisted. External code must treat
|
|
596
|
+
* `offchainTapscript` as read-only.
|
|
597
|
+
*/
|
|
598
|
+
setOffchainTapscriptForRotation(tapscript: DefaultVtxo.Script | DelegateVtxo.Script): void;
|
|
599
|
+
/**
|
|
600
|
+
* Async mutex that serializes all operations submitting VTXOs to the Arkade
|
|
601
|
+
* server (`settle`, `send`, `sendBitcoin`). This prevents VtxoManager's
|
|
602
|
+
* background renewal from racing with user-initiated transactions for the
|
|
603
|
+
* same VTXO inputs.
|
|
604
|
+
*/
|
|
605
|
+
private _txLock;
|
|
606
|
+
/**
|
|
607
|
+
* In-flight guard for {@link restore}. A second `restore()` while one
|
|
608
|
+
* is running returns the same promise so concurrent callers coalesce
|
|
609
|
+
* into a single scan (spec §3.E). Cleared on settle so a later
|
|
610
|
+
* explicit `restore()` re-runs.
|
|
611
|
+
*/
|
|
612
|
+
private _restoreInFlight?;
|
|
613
|
+
private _addPendingSpends;
|
|
614
|
+
private _removePendingSpends;
|
|
615
|
+
private _withTxLock;
|
|
616
|
+
/**
|
|
617
|
+
* Explicitly recover this wallet's contracts and balance on a fresh
|
|
618
|
+
* repo. HD wallets run a gap-limit scan across the index range;
|
|
619
|
+
* static / non-HD wallets restore based on the single default
|
|
620
|
+
* pubkey. Never throws because of identity/mode (a static identity
|
|
621
|
+
* is a valid, narrower restore); throws on operational failure (so a
|
|
622
|
+
* truncated restore is loud, not silent — the gap window may have
|
|
623
|
+
* closed early). Idempotent and safe to call concurrently (calls
|
|
624
|
+
* coalesce into one scan).
|
|
625
|
+
*
|
|
626
|
+
* Ordering is deliberate (spec §3.B / §4): scan → advance the HD
|
|
627
|
+
* watermark → inline VTXO pull → only THEN surface aggregated
|
|
628
|
+
* handler errors, so safely-discovered funds are always recovered
|
|
629
|
+
* even when one discovery handler failed.
|
|
630
|
+
*
|
|
631
|
+
* @param opts.gapLimit - Consecutive-unused-index window. Default
|
|
632
|
+
* 20. A non-positive / non-integer value is a programmer error and
|
|
633
|
+
* throws synchronously (distinct from operational failure).
|
|
634
|
+
*
|
|
635
|
+
* @note Concurrent calls coalesce: if a restore is already in flight,
|
|
636
|
+
* subsequent callers receive the same promise and their `gapLimit` is
|
|
637
|
+
* ignored — the first caller's value governs the running scan.
|
|
638
|
+
*/
|
|
639
|
+
restore(opts?: {
|
|
640
|
+
gapLimit?: number;
|
|
641
|
+
}): Promise<void>;
|
|
642
|
+
private _runRestore;
|
|
643
|
+
/** @deprecated Use settlementConfig instead */
|
|
644
|
+
readonly renewalConfig: Required<Omit<WalletConfig["renewalConfig"], "enabled">> & {
|
|
645
|
+
enabled: boolean;
|
|
646
|
+
thresholdMs: number;
|
|
647
|
+
};
|
|
648
|
+
readonly settlementConfig: SettlementConfig | false;
|
|
649
|
+
protected constructor(identity: Identity, network: Network, onchainProvider: OnchainProvider, arkProvider: ArkProvider, indexerProvider: IndexerProvider, arkServerPublicKey: Bytes, offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script, boardingTapscript: DefaultVtxo.Script, serverUnrollScript: CSVMultisigTapscript.Type, forfeitOutputScript: Bytes, forfeitPubkey: Bytes, dustAmount: bigint, walletRepository: WalletRepository, contractRepository: ContractRepository,
|
|
650
|
+
/** @deprecated Use settlementConfig */
|
|
651
|
+
renewalConfig?: WalletConfig["renewalConfig"], delegatorProvider?: DelegatorProvider, watcherConfig?: WalletConfig["watcherConfig"], settlementConfig?: WalletConfig["settlementConfig"], walletContractTimelocks?: RelativeTimelock[], receiveRotator?: WalletReceiveRotator, descriptorProvider?: DescriptorProvider);
|
|
652
|
+
get assetManager(): IAssetManager;
|
|
653
|
+
getVtxoManager(): Promise<VtxoManager>;
|
|
654
|
+
dispose(): Promise<void>;
|
|
655
|
+
/**
|
|
656
|
+
* Create a full wallet and initialize its background managers.
|
|
657
|
+
*
|
|
658
|
+
* @param config - Wallet configuration
|
|
659
|
+
* @returns A wallet ready to query balances and send transactions
|
|
660
|
+
* @example
|
|
661
|
+
* ```typescript
|
|
662
|
+
* const wallet = await Wallet.create({
|
|
663
|
+
* identity,
|
|
664
|
+
* arkServerUrl: 'https://arkade.computer',
|
|
665
|
+
* });
|
|
666
|
+
* ```
|
|
667
|
+
*/
|
|
668
|
+
static create(config: WalletConfig): Promise<Wallet>;
|
|
669
|
+
/**
|
|
670
|
+
* Convert this wallet to a readonly wallet.
|
|
671
|
+
*
|
|
672
|
+
* @returns A readonly wallet with the same configuration but readonly identity
|
|
673
|
+
* @example
|
|
674
|
+
* ```typescript
|
|
675
|
+
* const wallet = await Wallet.create({ identity: MnemonicIdentity.fromMnemonic('abandon abandon...'), ... });
|
|
676
|
+
* const readonlyWallet = await wallet.toReadonly();
|
|
677
|
+
*
|
|
678
|
+
* // Can query balance and addresses
|
|
679
|
+
* const balance = await readonlyWallet.getBalance();
|
|
680
|
+
* const address = await readonlyWallet.getAddress();
|
|
681
|
+
*
|
|
682
|
+
* // But cannot send transactions (type error)
|
|
683
|
+
* // readonlyWallet.send(...); // TypeScript error
|
|
684
|
+
* ```
|
|
685
|
+
*/
|
|
686
|
+
toReadonly(): Promise<ReadonlyWallet>;
|
|
687
|
+
/** Returns the delegator manager when delegation support is configured. */
|
|
688
|
+
getDelegatorManager(): Promise<IDelegatorManager | undefined>;
|
|
689
|
+
/**
|
|
690
|
+
* Send bitcoin to an Arkade address.
|
|
691
|
+
*
|
|
692
|
+
* @deprecated Use `send`.
|
|
693
|
+
* @param params - Send parameters
|
|
694
|
+
*/
|
|
695
|
+
sendBitcoin(params: SendBitcoinParams): Promise<string>;
|
|
696
|
+
/**
|
|
697
|
+
* Settle boarding inputs and/or virtual outputs into a finalized mainnet transaction.
|
|
698
|
+
*
|
|
699
|
+
* @param params - Optional settlement inputs and outputs. When omitted, the wallet settles all eligible funds.
|
|
700
|
+
* @param eventCallback - Optional callback invoked for settlement stream events.
|
|
701
|
+
* @returns The finalized Arkade transaction id
|
|
702
|
+
*/
|
|
703
|
+
settle(params?: SettleParams, eventCallback?: (event: SettlementEvent) => void): Promise<string>;
|
|
704
|
+
private _settleImpl;
|
|
705
|
+
private handleSettlementFinalizationEvent;
|
|
706
|
+
/**
|
|
707
|
+
* Create a batch event handler for settlement flows.
|
|
708
|
+
*
|
|
709
|
+
* @param intentId - The intent ID.
|
|
710
|
+
* @param inputs - Inputs used by the intent.
|
|
711
|
+
* @param expectedRecipients - Expected recipients to validate in the virtual output tree.
|
|
712
|
+
* @param session - Optional musig2 signing session. When omitted, signing steps are skipped.
|
|
713
|
+
*/
|
|
714
|
+
createBatchHandler(intentId: string, inputs: ExtendedCoin[], expectedRecipients: Recipient[], session?: SignerSession): Batch.Handler;
|
|
715
|
+
/**
|
|
716
|
+
* Build {@link InputSigningJob}s for a tx whose signable inputs can be
|
|
717
|
+
* resolved from their own `witnessUtxo.script`. Inputs without a
|
|
718
|
+
* `witnessUtxo` are silently omitted, mirroring the wallet's
|
|
719
|
+
* historical silent-skip behaviour for cosigner/connector inputs.
|
|
720
|
+
*/
|
|
721
|
+
private inputSigningJobsFromWitnessUtxos;
|
|
722
|
+
safeRegisterIntent(intent: SignedIntent<Intent.RegisterMessage>, inputs: ExtendedCoin[]): Promise<string>;
|
|
723
|
+
makeRegisterIntentSignature(coins: ExtendedCoin[], outputs: TransactionOutput[], onchainOutputsIndexes: number[], cosignerPubKeys: string[], validAt?: number): Promise<SignedIntent<Intent.RegisterMessage>>;
|
|
724
|
+
makeDeleteIntentSignature(coins: ExtendedCoin[]): Promise<SignedIntent<Intent.DeleteMessage>>;
|
|
725
|
+
makeGetPendingTxIntentSignature(coins: ExtendedVirtualCoin[]): Promise<SignedIntent<Intent.GetPendingTxMessage>>;
|
|
726
|
+
/**
|
|
727
|
+
* Finalizes pending transactions by retrieving them from the server and finalizing each one.
|
|
728
|
+
* Skips the server check entirely when no send was interrupted (no pending tx flag set).
|
|
729
|
+
* @param vtxos - Optional list of virtual outputs to use instead of retrieving them from the server
|
|
730
|
+
* @returns Array of transaction IDs that were finalized
|
|
731
|
+
*/
|
|
732
|
+
finalizePendingTxs(vtxos?: ExtendedVirtualCoin[]): Promise<{
|
|
733
|
+
finalized: string[];
|
|
734
|
+
pending: string[];
|
|
735
|
+
}>;
|
|
736
|
+
private hasPendingTxFlag;
|
|
737
|
+
private setPendingTxFlag;
|
|
738
|
+
/**
|
|
739
|
+
* Send BTC and/or assets to one or more recipients.
|
|
740
|
+
*
|
|
741
|
+
* @param args - Recipients with their addresses, BTC amounts, and assets
|
|
742
|
+
* @returns Promise resolving to the Arkade transaction ID
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* ```typescript
|
|
746
|
+
* const txid = await wallet.send({
|
|
747
|
+
* address: 'ark1q...',
|
|
748
|
+
* amount: 1000, // (optional, default to dust) btc amount to send to the output
|
|
749
|
+
* assets: [{ assetId: 'abc123...', amount: 50n }] // (optional) list of assets to send
|
|
750
|
+
* });
|
|
751
|
+
* ```
|
|
752
|
+
*/
|
|
753
|
+
send(...args: [Recipient, ...Recipient[]]): Promise<string>;
|
|
754
|
+
private _sendImpl;
|
|
755
|
+
/**
|
|
756
|
+
* Build an offchain transaction from the given inputs and outputs,
|
|
757
|
+
* sign it, submit to the Arkade provider, and finalize.
|
|
758
|
+
* @returns The Arkade transaction id and server-signed checkpoint PSBTs (for bookkeeping)
|
|
759
|
+
*/
|
|
760
|
+
buildAndSubmitOffchainTx(inputs: ExtendedVirtualCoin[], outputs: TransactionOutput[]): Promise<{
|
|
761
|
+
arkTxid: string;
|
|
762
|
+
signedCheckpointTxs: string[];
|
|
763
|
+
}>;
|
|
764
|
+
private updateDbAfterOffchainTx;
|
|
765
|
+
private updateDbAfterSettle;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Wait for incoming funds to the wallet
|
|
769
|
+
* @param wallet - The wallet to wait for incoming funds
|
|
770
|
+
* @returns A promise that resolves the next new coins received by the wallet's address
|
|
771
|
+
*/
|
|
772
|
+
declare function waitForIncomingFunds(wallet: Wallet): Promise<IncomingFunds>;
|
|
773
|
+
|
|
774
|
+
export { Batch as B, type IncomingFunds as I, ReadonlyWallet as R, Wallet as W, type ReceiveRotatorFactory as a, type ReceiveRotatorBootOpts as b, type ReceiveRotatorBoot as c, waitForIncomingFunds as w };
|