@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
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Unroll = void 0;
|
|
4
|
-
exports.prepareUnrollTransaction = prepareUnrollTransaction;
|
|
5
|
-
const base_1 = require("@scure/base");
|
|
6
|
-
const btc_signer_1 = require("@scure/btc-signer");
|
|
7
|
-
const timelock_1 = require("../utils/timelock");
|
|
8
|
-
const indexer_1 = require("../providers/indexer");
|
|
9
|
-
const base_2 = require("../script/base");
|
|
10
|
-
const txSizeEstimator_1 = require("../utils/txSizeEstimator");
|
|
11
|
-
const wallet_1 = require("./wallet");
|
|
12
|
-
const transaction_1 = require("../utils/transaction");
|
|
13
|
-
const utils_1 = require("./utils");
|
|
14
|
-
var Unroll;
|
|
15
|
-
(function (Unroll) {
|
|
16
|
-
let StepType;
|
|
17
|
-
(function (StepType) {
|
|
18
|
-
StepType[StepType["UNROLL"] = 0] = "UNROLL";
|
|
19
|
-
StepType[StepType["WAIT"] = 1] = "WAIT";
|
|
20
|
-
StepType[StepType["DONE"] = 2] = "DONE";
|
|
21
|
-
})(StepType = Unroll.StepType || (Unroll.StepType = {}));
|
|
22
|
-
/**
|
|
23
|
-
* Manages the unrolling process of a virtual output back to the Bitcoin blockchain.
|
|
24
|
-
*
|
|
25
|
-
* The Session class implements an async iterator that processes the unrolling steps:
|
|
26
|
-
* 1. **WAIT**: Waits for a transaction to be confirmed onchain (if it's in mempool)
|
|
27
|
-
* 2. **UNROLL**: Broadcasts the next transaction in the chain to the blockchain
|
|
28
|
-
* 3. **DONE**: Indicates the unrolling process is complete
|
|
29
|
-
*
|
|
30
|
-
* The unrolling process works by traversing the transaction chain from the root (most recent)
|
|
31
|
-
* to the leaf (oldest), broadcasting each transaction that isn't already onchain.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* const session = await Unroll.Session.create(vtxoOutpoint, bumper, explorer, indexer);
|
|
36
|
-
*
|
|
37
|
-
* // iterate over the steps
|
|
38
|
-
* for await (const doneStep of session) {
|
|
39
|
-
* switch (doneStep.type) {
|
|
40
|
-
* case Unroll.StepType.WAIT:
|
|
41
|
-
* console.log(`Transaction ${doneStep.txid} confirmed`);
|
|
42
|
-
* break;
|
|
43
|
-
* case Unroll.StepType.UNROLL:
|
|
44
|
-
* console.log(`Broadcasting transaction ${doneStep.tx.id}`);
|
|
45
|
-
* break;
|
|
46
|
-
* case Unroll.StepType.DONE:
|
|
47
|
-
* console.log(`Unrolling complete for virtual output ${doneStep.vtxoTxid}`);
|
|
48
|
-
* break;
|
|
49
|
-
* }
|
|
50
|
-
* }
|
|
51
|
-
* ```
|
|
52
|
-
**/
|
|
53
|
-
class Session {
|
|
54
|
-
/** Create an unroll session from a virtual output outpoint and its dependency chain. */
|
|
55
|
-
constructor(toUnroll, bumper, explorer, indexer) {
|
|
56
|
-
this.toUnroll = toUnroll;
|
|
57
|
-
this.bumper = bumper;
|
|
58
|
-
this.explorer = explorer;
|
|
59
|
-
this.indexer = indexer;
|
|
60
|
-
}
|
|
61
|
-
/** Create an unroll session by loading the virtual output chain from the indexer. */
|
|
62
|
-
static async create(toUnroll, bumper, explorer, indexer) {
|
|
63
|
-
const { chain } = await indexer.getVtxoChain(toUnroll);
|
|
64
|
-
return new Session({ ...toUnroll, chain }, bumper, explorer, indexer);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Get the next step to be executed
|
|
68
|
-
* @returns The next step to be executed + the function to execute it
|
|
69
|
-
*/
|
|
70
|
-
async next() {
|
|
71
|
-
let nextTxToBroadcast;
|
|
72
|
-
const chain = this.toUnroll.chain;
|
|
73
|
-
// Iterate through the chain from the end (root) to the beginning (leaf)
|
|
74
|
-
for (let i = chain.length - 1; i >= 0; i--) {
|
|
75
|
-
const chainTx = chain[i];
|
|
76
|
-
// Skip commitment transactions as they are always onchain
|
|
77
|
-
if (chainTx.type === indexer_1.ChainTxType.COMMITMENT ||
|
|
78
|
-
chainTx.type === indexer_1.ChainTxType.UNSPECIFIED) {
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
try {
|
|
82
|
-
// Check if the transaction is confirmed onchain
|
|
83
|
-
const txInfo = await this.explorer.getTxStatus(chainTx.txid);
|
|
84
|
-
// If found but not confirmed, it means the tx is in the mempool
|
|
85
|
-
// An unilateral exit is running, we must wait for it to be confirmed
|
|
86
|
-
if (!txInfo.confirmed) {
|
|
87
|
-
return {
|
|
88
|
-
type: StepType.WAIT,
|
|
89
|
-
txid: chainTx.txid,
|
|
90
|
-
do: doWait(this.explorer, chainTx.txid),
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
catch (e) {
|
|
95
|
-
// If the tx is not found, it's offchain, let's break
|
|
96
|
-
nextTxToBroadcast = chainTx;
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (!nextTxToBroadcast) {
|
|
101
|
-
return {
|
|
102
|
-
type: StepType.DONE,
|
|
103
|
-
vtxoTxid: this.toUnroll.txid,
|
|
104
|
-
do: () => Promise.resolve(),
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
// Get the virtual transaction data
|
|
108
|
-
const virtualTxs = await this.indexer.getVirtualTxs([
|
|
109
|
-
nextTxToBroadcast.txid,
|
|
110
|
-
]);
|
|
111
|
-
if (virtualTxs.txs.length === 0) {
|
|
112
|
-
throw new Error(`Tx ${nextTxToBroadcast.txid} not found`);
|
|
113
|
-
}
|
|
114
|
-
const tx = transaction_1.Transaction.fromPSBT(base_1.base64.decode(virtualTxs.txs[0]));
|
|
115
|
-
// finalize the tree transaction
|
|
116
|
-
if (nextTxToBroadcast.type === indexer_1.ChainTxType.TREE) {
|
|
117
|
-
const input = tx.getInput(0);
|
|
118
|
-
if (!input) {
|
|
119
|
-
throw new Error("Input not found");
|
|
120
|
-
}
|
|
121
|
-
const tapKeySig = input.tapKeySig;
|
|
122
|
-
if (!tapKeySig) {
|
|
123
|
-
throw new Error("Tap key sig not found");
|
|
124
|
-
}
|
|
125
|
-
tx.updateInput(0, {
|
|
126
|
-
finalScriptWitness: [tapKeySig],
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
// finalize Arkade transaction
|
|
131
|
-
tx.finalize();
|
|
132
|
-
}
|
|
133
|
-
const pkg = await this.bumper.bumpP2A(tx);
|
|
134
|
-
return {
|
|
135
|
-
type: StepType.UNROLL,
|
|
136
|
-
tx,
|
|
137
|
-
pkg,
|
|
138
|
-
do: doUnroll(this.explorer, pkg),
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Iterate over the steps to be executed and execute them
|
|
143
|
-
* @returns An async iterator over the executed steps
|
|
144
|
-
*/
|
|
145
|
-
async *[Symbol.asyncIterator]() {
|
|
146
|
-
let lastStep;
|
|
147
|
-
do {
|
|
148
|
-
if (lastStep !== undefined) {
|
|
149
|
-
// wait 1 second before trying the next step in order to give time to the
|
|
150
|
-
// explorer to update the tx status
|
|
151
|
-
await sleep(1000);
|
|
152
|
-
}
|
|
153
|
-
const step = await this.next();
|
|
154
|
-
await step.do();
|
|
155
|
-
yield step;
|
|
156
|
-
lastStep = step.type;
|
|
157
|
-
} while (lastStep !== StepType.DONE);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
Unroll.Session = Session;
|
|
161
|
-
/**
|
|
162
|
-
* Complete the unroll of a virtual output by broadcasting the transaction that spends the CSV path.
|
|
163
|
-
* @param wallet the wallet owning the virtual output(s)
|
|
164
|
-
* @param vtxoTxids the txids of the virtual output(s) to complete unroll
|
|
165
|
-
* @param outputAddress the address to send the unrolled funds to
|
|
166
|
-
* @throws if the virtual output(s) are not fully unrolled, if the txids are not found, if the tx is not confirmed, if no exit path is found or not available
|
|
167
|
-
* @returns the txid of the transaction spending the unrolled funds
|
|
168
|
-
*/
|
|
169
|
-
async function completeUnroll(wallet, vtxoTxids, outputAddress) {
|
|
170
|
-
const signedTx = await prepareUnrollTransaction(wallet, vtxoTxids, outputAddress);
|
|
171
|
-
await wallet.onchainProvider.broadcastTransaction(signedTx.hex);
|
|
172
|
-
return signedTx.id;
|
|
173
|
-
}
|
|
174
|
-
Unroll.completeUnroll = completeUnroll;
|
|
175
|
-
})(Unroll || (exports.Unroll = Unroll = {}));
|
|
176
|
-
/**
|
|
177
|
-
* Prepares the transaction that spends the CSV path to complete unrolling a VTXO.
|
|
178
|
-
* @param wallet the wallet owning the VTXO(s)
|
|
179
|
-
* @param vtxoTxIds the txids of the VTXO(s) to complete unroll
|
|
180
|
-
* @param outputAddress the address to send the unrolled funds to
|
|
181
|
-
* @throws if the VTXO(s) are not fully unrolled, if the txids are not found, if the tx is not confirmed, if no exit path is found or not available
|
|
182
|
-
* @returns the transaction spending the unrolled funds
|
|
183
|
-
*/
|
|
184
|
-
async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
185
|
-
const chainTip = await wallet.onchainProvider.getChainTip();
|
|
186
|
-
let vtxos = await wallet.getVtxos({ withUnrolled: true });
|
|
187
|
-
vtxos = vtxos.filter((vtxo) => vtxoTxIds.includes(vtxo.txid));
|
|
188
|
-
if (vtxos.length === 0) {
|
|
189
|
-
throw new Error("No vtxos to complete unroll");
|
|
190
|
-
}
|
|
191
|
-
const inputs = [];
|
|
192
|
-
let totalAmount = 0n;
|
|
193
|
-
const txWeightEstimator = txSizeEstimator_1.TxWeightEstimator.create();
|
|
194
|
-
for (const vtxo of vtxos) {
|
|
195
|
-
if (!vtxo.isUnrolled) {
|
|
196
|
-
throw new Error(`Vtxo ${vtxo.txid}:${vtxo.vout} is not fully unrolled, use unroll first`);
|
|
197
|
-
}
|
|
198
|
-
const txStatus = await wallet.onchainProvider.getTxStatus(vtxo.txid);
|
|
199
|
-
if (!txStatus.confirmed) {
|
|
200
|
-
throw new Error(`tx ${vtxo.txid} is not confirmed`);
|
|
201
|
-
}
|
|
202
|
-
const exit = availableExitPath({ height: txStatus.blockHeight, time: txStatus.blockTime }, chainTip, vtxo);
|
|
203
|
-
if (!exit) {
|
|
204
|
-
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
205
|
-
}
|
|
206
|
-
const spendingLeaf = base_2.VtxoScript.decode(vtxo.tapTree).findLeaf(base_1.hex.encode(exit.script));
|
|
207
|
-
if (!spendingLeaf) {
|
|
208
|
-
throw new Error(`spending leaf not found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
209
|
-
}
|
|
210
|
-
totalAmount += BigInt(vtxo.value);
|
|
211
|
-
const sequence = (0, timelock_1.timelockToSequence)(exit.params.timelock);
|
|
212
|
-
inputs.push({
|
|
213
|
-
txid: vtxo.txid,
|
|
214
|
-
index: vtxo.vout,
|
|
215
|
-
tapLeafScript: [spendingLeaf],
|
|
216
|
-
sequence,
|
|
217
|
-
witnessUtxo: {
|
|
218
|
-
amount: BigInt(vtxo.value),
|
|
219
|
-
script: base_2.VtxoScript.decode(vtxo.tapTree).pkScript,
|
|
220
|
-
},
|
|
221
|
-
sighashType: btc_signer_1.SigHash.DEFAULT,
|
|
222
|
-
});
|
|
223
|
-
txWeightEstimator.addTapscriptInput(64, spendingLeaf[1].length, btc_signer_1.TaprootControlBlock.encode(spendingLeaf[0]).length);
|
|
224
|
-
}
|
|
225
|
-
const tx = new transaction_1.Transaction({ version: 2 });
|
|
226
|
-
for (const input of inputs) {
|
|
227
|
-
tx.addInput(input);
|
|
228
|
-
}
|
|
229
|
-
txWeightEstimator.addOutputAddress(outputAddress, wallet.network);
|
|
230
|
-
let feeRate = await wallet.onchainProvider.getFeeRate();
|
|
231
|
-
if (!feeRate || feeRate < wallet_1.Wallet.MIN_FEE_RATE) {
|
|
232
|
-
feeRate = wallet_1.Wallet.MIN_FEE_RATE;
|
|
233
|
-
}
|
|
234
|
-
const feeAmount = txWeightEstimator.vsize().fee(BigInt(feeRate));
|
|
235
|
-
if (feeAmount > totalAmount) {
|
|
236
|
-
throw new Error("fee amount is greater than the total amount");
|
|
237
|
-
}
|
|
238
|
-
const sendAmount = totalAmount - feeAmount;
|
|
239
|
-
if (sendAmount < BigInt(utils_1.DUST_AMOUNT)) {
|
|
240
|
-
throw new Error("send amount is less than dust amount");
|
|
241
|
-
}
|
|
242
|
-
tx.addOutputAddress(outputAddress, sendAmount, wallet.network);
|
|
243
|
-
const signedTx = await wallet.identity.sign(tx);
|
|
244
|
-
signedTx.finalize();
|
|
245
|
-
return signedTx;
|
|
246
|
-
}
|
|
247
|
-
function sleep(ms) {
|
|
248
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
249
|
-
}
|
|
250
|
-
function doUnroll(onchainProvider, pkg) {
|
|
251
|
-
return () => onchainProvider.broadcastTransaction(...pkg).then(() => undefined);
|
|
252
|
-
}
|
|
253
|
-
function doWait(onchainProvider, txid) {
|
|
254
|
-
return () => {
|
|
255
|
-
return new Promise((resolve, reject) => {
|
|
256
|
-
const interval = setInterval(async () => {
|
|
257
|
-
try {
|
|
258
|
-
const txInfo = await onchainProvider.getTxStatus(txid);
|
|
259
|
-
if (txInfo.confirmed) {
|
|
260
|
-
clearInterval(interval);
|
|
261
|
-
resolve();
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
catch (e) {
|
|
265
|
-
clearInterval(interval);
|
|
266
|
-
reject(e);
|
|
267
|
-
}
|
|
268
|
-
}, 5000);
|
|
269
|
-
});
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
function availableExitPath(confirmedAt, current, vtxo) {
|
|
273
|
-
const exits = base_2.VtxoScript.decode(vtxo.tapTree).exitPaths();
|
|
274
|
-
for (const exit of exits) {
|
|
275
|
-
if (exit.params.timelock.type === "blocks") {
|
|
276
|
-
if (current.height >=
|
|
277
|
-
confirmedAt.height + Number(exit.params.timelock.value)) {
|
|
278
|
-
return exit;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
if (current.time >=
|
|
283
|
-
confirmedAt.time + Number(exit.params.timelock.value)) {
|
|
284
|
-
return exit;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return undefined;
|
|
289
|
-
}
|
package/dist/cjs/wallet/utils.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DUST_AMOUNT = void 0;
|
|
4
|
-
exports.extendCoin = extendCoin;
|
|
5
|
-
exports.extendVirtualCoinForContract = extendVirtualCoinForContract;
|
|
6
|
-
exports.getRandomId = getRandomId;
|
|
7
|
-
exports.isValidArkAddress = isValidArkAddress;
|
|
8
|
-
exports.validateRecipients = validateRecipients;
|
|
9
|
-
const __1 = require("..");
|
|
10
|
-
const handlers_1 = require("../contracts/handlers");
|
|
11
|
-
const base_1 = require("@scure/base");
|
|
12
|
-
exports.DUST_AMOUNT = 546; // sats
|
|
13
|
-
function extendCoin(wallet, utxo) {
|
|
14
|
-
return {
|
|
15
|
-
...utxo,
|
|
16
|
-
forfeitTapLeafScript: wallet.boardingTapscript.forfeit(),
|
|
17
|
-
intentTapLeafScript: wallet.boardingTapscript.forfeit(),
|
|
18
|
-
tapTree: wallet.boardingTapscript.encode(),
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function extendVtxoFromContract(vtxo, contract) {
|
|
22
|
-
const handler = handlers_1.contractHandlers.get(contract.type);
|
|
23
|
-
if (!handler) {
|
|
24
|
-
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
25
|
-
}
|
|
26
|
-
const script = handler.createScript(contract.params);
|
|
27
|
-
return {
|
|
28
|
-
...vtxo,
|
|
29
|
-
forfeitTapLeafScript: script.forfeit(),
|
|
30
|
-
intentTapLeafScript: script.forfeit(),
|
|
31
|
-
tapTree: script.encode(),
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Extend a VirtualCoin with the tap scripts of whichever contract locks it.
|
|
36
|
-
*
|
|
37
|
-
* The second argument accepts either form, so each callsite passes what it
|
|
38
|
-
* already has:
|
|
39
|
-
* - a single `Contract` (when the caller already knows the owning contract,
|
|
40
|
-
* e.g. the contract manager iterating its own `scriptToContract` map), or
|
|
41
|
-
* - a `ReadonlyMap<script, Contract>` (when the caller resolves by
|
|
42
|
-
* `vtxo.script`, populated by the indexer).
|
|
43
|
-
*
|
|
44
|
-
* Throws when no contract can be resolved — there is intentionally no
|
|
45
|
-
* default-tapscript fallback. When the wallet owns multiple contracts
|
|
46
|
-
* (default + delegate, several active vHTLCs, etc.) a default-tapscript path
|
|
47
|
-
* silently stamps every VTXO with the same forfeit/intent data, overwriting
|
|
48
|
-
* the correct data for any VTXO locked to a non-default contract. Callers
|
|
49
|
-
* must feed a Contract or a populated script→Contract map; otherwise the
|
|
50
|
-
* caller (typically `ContractManager.annotateVtxos`) should fetch the owning
|
|
51
|
-
* contract first.
|
|
52
|
-
*/
|
|
53
|
-
function extendVirtualCoinForContract(vtxo, contractOrMap) {
|
|
54
|
-
const contract = resolveContract(vtxo, contractOrMap);
|
|
55
|
-
if (!contract) {
|
|
56
|
-
throw new Error("extendVirtualCoinForContract: no contract matched vtxo.script — callers must resolve the owning contract before annotating");
|
|
57
|
-
}
|
|
58
|
-
return extendVtxoFromContract(vtxo, contract);
|
|
59
|
-
}
|
|
60
|
-
function isContractMap(value) {
|
|
61
|
-
// A `Contract` is a plain object with a string `type`. `ReadonlyMap` is
|
|
62
|
-
// an interface so `instanceof Map` is not enough to narrow it — but a
|
|
63
|
-
// contract has no `get` method, so duck-typing on that is unambiguous.
|
|
64
|
-
return typeof value.get === "function";
|
|
65
|
-
}
|
|
66
|
-
function resolveContract(vtxo, contractOrMap) {
|
|
67
|
-
if (!contractOrMap)
|
|
68
|
-
return undefined;
|
|
69
|
-
if (isContractMap(contractOrMap)) {
|
|
70
|
-
return contractOrMap.get(vtxo.script);
|
|
71
|
-
}
|
|
72
|
-
return contractOrMap;
|
|
73
|
-
}
|
|
74
|
-
function getRandomId() {
|
|
75
|
-
const randomValue = crypto.getRandomValues(new Uint8Array(16));
|
|
76
|
-
return base_1.hex.encode(randomValue);
|
|
77
|
-
}
|
|
78
|
-
function isValidArkAddress(address) {
|
|
79
|
-
try {
|
|
80
|
-
__1.ArkAddress.decode(address);
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
catch (e) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function validateRecipients(recipients, dustAmount) {
|
|
88
|
-
const validatedRecipients = [];
|
|
89
|
-
for (const recipient of recipients) {
|
|
90
|
-
let address;
|
|
91
|
-
try {
|
|
92
|
-
address = __1.ArkAddress.decode(recipient.address);
|
|
93
|
-
}
|
|
94
|
-
catch (e) {
|
|
95
|
-
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
96
|
-
}
|
|
97
|
-
const amount = recipient.amount || dustAmount;
|
|
98
|
-
if (amount <= 0) {
|
|
99
|
-
throw new Error("Amount must be positive");
|
|
100
|
-
}
|
|
101
|
-
validatedRecipients.push({
|
|
102
|
-
address: recipient.address,
|
|
103
|
-
assets: recipient.assets ?? [],
|
|
104
|
-
amount,
|
|
105
|
-
script: amount < dustAmount
|
|
106
|
-
? address.subdustPkScript
|
|
107
|
-
: address.pkScript,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
return validatedRecipients;
|
|
111
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrInvalidOffchainOutputAmount = exports.ErrOnchainOutputNotFound = exports.ErrInvalidOnchainOutputAssets = exports.ErrInvalidOnchainOutputAmount = exports.ErrAssetOutputNotFound = exports.ErrAssetGroupNotFound = exports.ErrInvalidAssetOutputAmount = exports.ErrOffchainOutputNotFound = void 0;
|
|
4
|
-
exports.validateBatchRecipients = validateBatchRecipients;
|
|
5
|
-
const utils_js_1 = require("@scure/btc-signer/utils.js");
|
|
6
|
-
const address_1 = require("../script/address");
|
|
7
|
-
const extension_1 = require("../extension");
|
|
8
|
-
const btc_signer_1 = require("@scure/btc-signer");
|
|
9
|
-
const ErrOffchainOutputNotFound = (address) => new Error(`offchain send output not found: ${address}`);
|
|
10
|
-
exports.ErrOffchainOutputNotFound = ErrOffchainOutputNotFound;
|
|
11
|
-
const ErrInvalidAssetOutputAmount = (got, want, assetId) => new Error(`invalid asset output amount for ${assetId}: got ${got}, want ${want}`);
|
|
12
|
-
exports.ErrInvalidAssetOutputAmount = ErrInvalidAssetOutputAmount;
|
|
13
|
-
const ErrAssetGroupNotFound = (assetId) => new Error(`asset group not found in batch leaf: ${assetId}`);
|
|
14
|
-
exports.ErrAssetGroupNotFound = ErrAssetGroupNotFound;
|
|
15
|
-
const ErrAssetOutputNotFound = (assetId, outputIndex) => new Error(`asset output not found in asset group ${assetId} at index ${outputIndex}`);
|
|
16
|
-
exports.ErrAssetOutputNotFound = ErrAssetOutputNotFound;
|
|
17
|
-
const ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
18
|
-
exports.ErrInvalidOnchainOutputAmount = ErrInvalidOnchainOutputAmount;
|
|
19
|
-
const ErrInvalidOnchainOutputAssets = (address) => new Error(`onchain output ${address} cannot have assets`);
|
|
20
|
-
exports.ErrInvalidOnchainOutputAssets = ErrInvalidOnchainOutputAssets;
|
|
21
|
-
const ErrOnchainOutputNotFound = (address) => new Error(`onchain output not found: ${address}`);
|
|
22
|
-
exports.ErrOnchainOutputNotFound = ErrOnchainOutputNotFound;
|
|
23
|
-
const ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain output ${address}, missing amount`);
|
|
24
|
-
exports.ErrInvalidOffchainOutputAmount = ErrInvalidOffchainOutputAmount;
|
|
25
|
-
/**
|
|
26
|
-
* Validates both offchain and onchain recipients.
|
|
27
|
-
* Offchain recipients are checked against vtxo tree leaves for correct amounts and assets.
|
|
28
|
-
* Onchain recipients are validated against the round transaction outputs (amounts and scripts)
|
|
29
|
-
* via validateOnchainRecipient.
|
|
30
|
-
*
|
|
31
|
-
* @param commitmentTx - The commitment transaction to validate against
|
|
32
|
-
* @param vtxoTreeLeaves - The vtxo tree leaves to validate against
|
|
33
|
-
* @param recipients - The expected recipients to validate (both offchain and onchain)
|
|
34
|
-
* @param network - Network for decoding onchain addresses (e.g. mainnet, testnet)
|
|
35
|
-
* @throws {Error} if a recipient is not present or invalid in the vtxo tree or commitment tx
|
|
36
|
-
*/
|
|
37
|
-
function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, network) {
|
|
38
|
-
// usedOutputs is used to track which outputs are validated to handle
|
|
39
|
-
// duplicate recipients in the list
|
|
40
|
-
const usedOutputs = new Set();
|
|
41
|
-
const usedOnchainOutputs = new Set();
|
|
42
|
-
for (const recipient of recipients) {
|
|
43
|
-
let arkAddress;
|
|
44
|
-
try {
|
|
45
|
-
arkAddress = address_1.ArkAddress.decode(recipient.address);
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
validateOffchainRecipient(vtxoTreeLeaves, arkAddress, recipient, usedOutputs);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
// validateOnchainRecipient verifies the given recipient is present in the commitment tx outputs list
|
|
55
|
-
function validateOnchainRecipient(commitmentTx, recipient, network, usedOutputs) {
|
|
56
|
-
const addr = (0, btc_signer_1.Address)(network).decode(recipient.address);
|
|
57
|
-
const expectedPkScript = btc_signer_1.OutScript.encode(addr);
|
|
58
|
-
if (!recipient.amount) {
|
|
59
|
-
throw (0, exports.ErrInvalidOnchainOutputAmount)(recipient.address);
|
|
60
|
-
}
|
|
61
|
-
if (recipient.assets && recipient.assets.length > 0) {
|
|
62
|
-
throw (0, exports.ErrInvalidOnchainOutputAssets)(recipient.address);
|
|
63
|
-
}
|
|
64
|
-
for (let i = 0; i < commitmentTx.outputsLength; i++) {
|
|
65
|
-
if (usedOutputs.has(i)) {
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
const output = commitmentTx.getOutput(i);
|
|
69
|
-
if (!output?.script || output.script.length === 0) {
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
if ((0, utils_js_1.equalBytes)(output.script, expectedPkScript)) {
|
|
73
|
-
if (output.amount !== BigInt(recipient.amount)) {
|
|
74
|
-
continue; // if amount does not match, continue
|
|
75
|
-
}
|
|
76
|
-
// we found the right output, recipient is valid, return
|
|
77
|
-
usedOutputs.add(i);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
// if we get here, the recipient is not present in the commitment tx outputs list
|
|
82
|
-
throw (0, exports.ErrOnchainOutputNotFound)(recipient.address);
|
|
83
|
-
}
|
|
84
|
-
// validate the offchain recipient is present in one of the leaf output
|
|
85
|
-
// also verify the asset packet is here, and point the same output index
|
|
86
|
-
function validateOffchainRecipient(leaves, arkAddress, recipient, usedOutputs // leafIndex:outputIndex
|
|
87
|
-
) {
|
|
88
|
-
const expectedPkScript = arkAddress.pkScript;
|
|
89
|
-
if (!recipient.amount) {
|
|
90
|
-
throw (0, exports.ErrInvalidOffchainOutputAmount)(recipient.address);
|
|
91
|
-
}
|
|
92
|
-
const expectedAmount = BigInt(recipient.amount);
|
|
93
|
-
let found = false;
|
|
94
|
-
for (let leafIdx = 0; leafIdx < leaves.length; leafIdx++) {
|
|
95
|
-
const leaf = leaves[leafIdx];
|
|
96
|
-
for (let outputIndex = 0; outputIndex < leaf.outputsLength; outputIndex++) {
|
|
97
|
-
const output = leaf.getOutput(outputIndex);
|
|
98
|
-
if (!output?.script || output.script.length === 0) {
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
if (!(0, utils_js_1.equalBytes)(output.script, expectedPkScript)) {
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
if (output.amount !== expectedAmount) {
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
const key = `${leafIdx}:${outputIndex}`;
|
|
108
|
-
if (usedOutputs.has(key)) {
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
usedOutputs.add(key);
|
|
112
|
-
found = true;
|
|
113
|
-
// if assets, validate the asset packet
|
|
114
|
-
if (recipient.assets && recipient.assets.length > 0) {
|
|
115
|
-
validateAssetOutputs(leaf, outputIndex, recipient.assets);
|
|
116
|
-
}
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
if (found) {
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (!found) {
|
|
124
|
-
throw (0, exports.ErrOffchainOutputNotFound)(recipient.address);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function validateAssetOutputs(leafTx, outputIndex, expectedAssets) {
|
|
128
|
-
const ext = extension_1.Extension.fromTx(leafTx);
|
|
129
|
-
const assetPacket = ext.getAssetPacket();
|
|
130
|
-
if (!assetPacket) {
|
|
131
|
-
throw new Error("no asset packet found in extension");
|
|
132
|
-
}
|
|
133
|
-
for (const { assetId, amount } of expectedAssets) {
|
|
134
|
-
validateAssetGroupOutput(assetPacket, outputIndex, assetId, amount);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
function validateAssetGroupOutput(packet, outputIndex, assetId, expectedAmount) {
|
|
138
|
-
const assetGroup = packet.groups.find((group) => {
|
|
139
|
-
if (group.isIssuance())
|
|
140
|
-
return false;
|
|
141
|
-
return group.assetId.toString() === assetId;
|
|
142
|
-
});
|
|
143
|
-
if (!assetGroup) {
|
|
144
|
-
throw (0, exports.ErrAssetGroupNotFound)(assetId);
|
|
145
|
-
}
|
|
146
|
-
// find the output at the expected index
|
|
147
|
-
const assetOutput = assetGroup.outputs.find((output) => output.vout === outputIndex);
|
|
148
|
-
if (!assetOutput) {
|
|
149
|
-
throw (0, exports.ErrAssetOutputNotFound)(assetId, outputIndex);
|
|
150
|
-
}
|
|
151
|
-
if (assetOutput.amount !== expectedAmount) {
|
|
152
|
-
throw (0, exports.ErrInvalidAssetOutputAmount)(assetOutput.amount, expectedAmount, assetId);
|
|
153
|
-
}
|
|
154
|
-
}
|