@arkade-os/sdk 0.4.27 → 0.4.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -100
- package/dist/adapters/asyncStorage.cjs +48 -0
- package/dist/adapters/asyncStorage.cjs.map +1 -0
- package/dist/adapters/asyncStorage.d.cts +16 -0
- package/dist/{types/storage → adapters}/asyncStorage.d.ts +5 -2
- package/dist/adapters/asyncStorage.js +46 -0
- package/dist/adapters/asyncStorage.js.map +1 -0
- package/dist/adapters/expo.cjs +19 -0
- package/dist/adapters/expo.cjs.map +1 -0
- package/dist/adapters/expo.d.cts +48 -0
- package/dist/adapters/expo.d.ts +48 -0
- package/dist/adapters/expo.js +6 -0
- package/dist/adapters/expo.js.map +1 -0
- package/dist/adapters/fileSystem.cjs +116 -0
- package/dist/adapters/fileSystem.cjs.map +1 -0
- package/dist/adapters/fileSystem.d.cts +17 -0
- package/dist/{types/storage → adapters}/fileSystem.d.ts +5 -2
- package/dist/adapters/fileSystem.js +93 -0
- package/dist/adapters/fileSystem.js.map +1 -0
- package/dist/adapters/indexedDB.cjs +103 -0
- package/dist/adapters/indexedDB.cjs.map +1 -0
- package/dist/adapters/indexedDB.d.cts +18 -0
- package/dist/{types/storage → adapters}/indexedDB.d.ts +5 -2
- package/dist/adapters/indexedDB.js +101 -0
- package/dist/adapters/indexedDB.js.map +1 -0
- package/dist/adapters/localStorage.cjs +50 -0
- package/dist/adapters/localStorage.cjs.map +1 -0
- package/dist/{types/storage/inMemory.d.ts → adapters/localStorage.d.cts} +6 -3
- package/dist/{types/storage → adapters}/localStorage.d.ts +5 -2
- package/dist/adapters/localStorage.js +48 -0
- package/dist/adapters/localStorage.js.map +1 -0
- package/dist/ark-TZ1gXAXU.d.cts +3880 -0
- package/dist/ark-TZ1gXAXU.d.ts +3880 -0
- package/dist/{types/worker/expo/asyncStorageTaskQueue.d.ts → asyncStorageTaskQueue-Cb1F_Z9s.d.ts} +6 -3
- package/dist/asyncStorageTaskQueue-EFqSmYTg.d.cts +49 -0
- package/dist/chunk-5BLDMQED.cjs +18 -0
- package/dist/chunk-5BLDMQED.cjs.map +1 -0
- package/dist/chunk-5PG7DV7A.cjs +805 -0
- package/dist/chunk-5PG7DV7A.cjs.map +1 -0
- package/dist/chunk-A3EMF7RN.js +95 -0
- package/dist/chunk-A3EMF7RN.js.map +1 -0
- package/dist/chunk-ADV27S4N.cjs +2701 -0
- package/dist/chunk-ADV27S4N.cjs.map +1 -0
- package/dist/chunk-BQLHADL7.js +13805 -0
- package/dist/chunk-BQLHADL7.js.map +1 -0
- package/dist/chunk-CFZMTDWI.js +209 -0
- package/dist/chunk-CFZMTDWI.js.map +1 -0
- package/dist/chunk-FG5ACJJW.cjs +212 -0
- package/dist/chunk-FG5ACJJW.cjs.map +1 -0
- package/dist/chunk-HW3JJ323.js +768 -0
- package/dist/chunk-HW3JJ323.js.map +1 -0
- package/dist/chunk-I3DGUUCT.cjs +838 -0
- package/dist/chunk-I3DGUUCT.cjs.map +1 -0
- package/dist/chunk-IPX2R7FR.cjs +100 -0
- package/dist/chunk-IPX2R7FR.cjs.map +1 -0
- package/dist/chunk-NSBPE2FW.js +15 -0
- package/dist/chunk-NSBPE2FW.js.map +1 -0
- package/dist/chunk-T64LAI7L.js +829 -0
- package/dist/chunk-T64LAI7L.js.map +1 -0
- package/dist/chunk-ZBUDLTBO.js +2671 -0
- package/dist/chunk-ZBUDLTBO.js.map +1 -0
- package/dist/chunk-ZLO6NETT.cjs +13910 -0
- package/dist/chunk-ZLO6NETT.cjs.map +1 -0
- package/dist/contracts/handlers/index.cjs +26 -0
- package/dist/contracts/handlers/index.cjs.map +1 -0
- package/dist/contracts/handlers/index.d.cts +7 -0
- package/dist/contracts/handlers/index.d.ts +7 -0
- package/dist/contracts/handlers/index.js +5 -0
- package/dist/contracts/handlers/index.js.map +1 -0
- package/dist/delegate-BFZs69hp.d.cts +84 -0
- package/dist/delegate-aaVGfWsV.d.ts +84 -0
- package/dist/index-B22cA64m.d.cts +199 -0
- package/dist/{types/storage/index.d.ts → index-C0IanN1m.d.cts} +3 -1
- package/dist/index-C0IanN1m.d.ts +11 -0
- package/dist/index-NDla_UoJ.d.ts +199 -0
- package/dist/index.cjs +480 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3343 -0
- package/dist/index.d.ts +3343 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/repositories/realm/index.cjs +513 -0
- package/dist/repositories/realm/index.cjs.map +1 -0
- package/dist/repositories/realm/index.d.cts +217 -0
- package/dist/{types/repositories/realm/schemas.d.ts → repositories/realm/index.d.ts} +80 -112
- package/dist/repositories/realm/index.js +507 -0
- package/dist/repositories/realm/index.js.map +1 -0
- package/dist/repositories/sqlite/index.cjs +588 -0
- package/dist/repositories/sqlite/index.cjs.map +1 -0
- package/dist/repositories/sqlite/index.d.cts +118 -0
- package/dist/{types/repositories/sqlite/walletRepository.d.ts → repositories/sqlite/index.d.ts} +58 -5
- package/dist/repositories/sqlite/index.js +585 -0
- package/dist/repositories/sqlite/index.js.map +1 -0
- package/dist/taskRunner-C6Ff4OaU.d.cts +114 -0
- package/dist/taskRunner-yvPN8Z0K.d.ts +114 -0
- package/dist/wallet/expo/background.cjs +93 -0
- package/dist/wallet/expo/background.cjs.map +1 -0
- package/dist/wallet/expo/background.d.cts +84 -0
- package/dist/wallet/expo/background.d.ts +84 -0
- package/dist/wallet/expo/background.js +68 -0
- package/dist/wallet/expo/background.js.map +1 -0
- package/dist/wallet/expo/index.cjs +171 -0
- package/dist/wallet/expo/index.cjs.map +1 -0
- package/dist/wallet/expo/index.d.cts +122 -0
- package/dist/{types/wallet/expo/wallet.d.ts → wallet/expo/index.d.ts} +45 -22
- package/dist/wallet/expo/index.js +169 -0
- package/dist/wallet/expo/index.js.map +1 -0
- package/dist/wallet-AF-p-OWj.d.cts +774 -0
- package/dist/wallet-D9NBRqvC.d.ts +774 -0
- package/dist/worker/expo/index.cjs +140 -0
- package/dist/worker/expo/index.cjs.map +1 -0
- package/dist/worker/expo/index.d.cts +29 -0
- package/dist/worker/expo/index.d.ts +29 -0
- package/dist/worker/expo/index.js +121 -0
- package/dist/worker/expo/index.js.map +1 -0
- package/package.json +110 -76
- package/dist/cjs/adapters/asyncStorage.js +0 -5
- package/dist/cjs/adapters/expo.js +0 -8
- package/dist/cjs/adapters/fileSystem.js +0 -5
- package/dist/cjs/adapters/indexedDB.js +0 -5
- package/dist/cjs/adapters/localStorage.js +0 -5
- package/dist/cjs/arkfee/celenv.js +0 -43
- package/dist/cjs/arkfee/estimator.js +0 -143
- package/dist/cjs/arkfee/index.js +0 -5
- package/dist/cjs/arkfee/types.js +0 -26
- package/dist/cjs/arknote/index.js +0 -128
- package/dist/cjs/bip322/index.js +0 -270
- package/dist/cjs/contracts/arkcontract.js +0 -147
- package/dist/cjs/contracts/contractManager.js +0 -649
- package/dist/cjs/contracts/contractWatcher.js +0 -598
- package/dist/cjs/contracts/handlers/default.js +0 -93
- package/dist/cjs/contracts/handlers/delegate.js +0 -90
- package/dist/cjs/contracts/handlers/helpers.js +0 -115
- package/dist/cjs/contracts/handlers/index.js +0 -19
- package/dist/cjs/contracts/handlers/registry.js +0 -89
- package/dist/cjs/contracts/handlers/vhtlc.js +0 -194
- package/dist/cjs/contracts/index.js +0 -41
- package/dist/cjs/contracts/types.js +0 -2
- package/dist/cjs/contracts/vtxoOwnership.js +0 -78
- package/dist/cjs/extension/asset/assetGroup.js +0 -228
- package/dist/cjs/extension/asset/assetId.js +0 -152
- package/dist/cjs/extension/asset/assetInput.js +0 -222
- package/dist/cjs/extension/asset/assetOutput.js +0 -174
- package/dist/cjs/extension/asset/assetRef.js +0 -148
- package/dist/cjs/extension/asset/index.js +0 -23
- package/dist/cjs/extension/asset/metadata.js +0 -187
- package/dist/cjs/extension/asset/packet.js +0 -114
- package/dist/cjs/extension/asset/types.js +0 -22
- package/dist/cjs/extension/asset/utils.js +0 -105
- package/dist/cjs/extension/index.js +0 -254
- package/dist/cjs/extension/packet.js +0 -20
- package/dist/cjs/forfeit.js +0 -45
- package/dist/cjs/identity/descriptor.js +0 -169
- package/dist/cjs/identity/descriptorProvider.js +0 -2
- package/dist/cjs/identity/hdCapableIdentity.js +0 -20
- package/dist/cjs/identity/index.js +0 -40
- package/dist/cjs/identity/seedIdentity.js +0 -477
- package/dist/cjs/identity/serialize.js +0 -171
- package/dist/cjs/identity/singleKey.js +0 -126
- package/dist/cjs/identity/staticDescriptorProvider.js +0 -65
- package/dist/cjs/index.js +0 -202
- package/dist/cjs/intent/index.js +0 -259
- package/dist/cjs/musig2/index.js +0 -11
- package/dist/cjs/musig2/keys.js +0 -57
- package/dist/cjs/musig2/nonces.js +0 -48
- package/dist/cjs/musig2/sign.js +0 -102
- package/dist/cjs/networks.js +0 -26
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/providers/ark.js +0 -577
- package/dist/cjs/providers/delegator.js +0 -85
- package/dist/cjs/providers/electrum.js +0 -869
- package/dist/cjs/providers/errors.js +0 -59
- package/dist/cjs/providers/expoArk.js +0 -82
- package/dist/cjs/providers/expoIndexer.js +0 -111
- package/dist/cjs/providers/expoUtils.js +0 -124
- package/dist/cjs/providers/indexer.js +0 -630
- package/dist/cjs/providers/onchain.js +0 -262
- package/dist/cjs/providers/utils.js +0 -121
- package/dist/cjs/repositories/contractRepository.js +0 -2
- package/dist/cjs/repositories/inMemory/contractRepository.js +0 -55
- package/dist/cjs/repositories/inMemory/walletRepository.js +0 -115
- package/dist/cjs/repositories/index.js +0 -34
- package/dist/cjs/repositories/indexedDB/contractRepository.js +0 -187
- package/dist/cjs/repositories/indexedDB/db.js +0 -19
- package/dist/cjs/repositories/indexedDB/manager.js +0 -100
- package/dist/cjs/repositories/indexedDB/schema.js +0 -204
- package/dist/cjs/repositories/indexedDB/walletRepository.js +0 -474
- package/dist/cjs/repositories/indexedDB/websqlAdapter.js +0 -144
- package/dist/cjs/repositories/migrations/contractRepositoryImpl.js +0 -127
- package/dist/cjs/repositories/migrations/fromStorageAdapter.js +0 -66
- package/dist/cjs/repositories/migrations/walletRepositoryImpl.js +0 -184
- package/dist/cjs/repositories/realm/contractRepository.js +0 -116
- package/dist/cjs/repositories/realm/index.js +0 -11
- package/dist/cjs/repositories/realm/schemas.js +0 -157
- package/dist/cjs/repositories/realm/types.js +0 -7
- package/dist/cjs/repositories/realm/walletRepository.js +0 -305
- package/dist/cjs/repositories/scriptFromAddress.js +0 -16
- package/dist/cjs/repositories/serialization.js +0 -82
- package/dist/cjs/repositories/sqlite/contractRepository.js +0 -135
- package/dist/cjs/repositories/sqlite/index.js +0 -7
- package/dist/cjs/repositories/sqlite/types.js +0 -2
- package/dist/cjs/repositories/sqlite/walletRepository.js +0 -441
- package/dist/cjs/repositories/walletRepository.js +0 -2
- package/dist/cjs/script/address.js +0 -108
- package/dist/cjs/script/base.js +0 -185
- package/dist/cjs/script/default.js +0 -57
- package/dist/cjs/script/delegate.js +0 -53
- package/dist/cjs/script/tapscript.js +0 -619
- package/dist/cjs/script/vhtlc.js +0 -170
- package/dist/cjs/storage/asyncStorage.js +0 -50
- package/dist/cjs/storage/fileSystem.js +0 -141
- package/dist/cjs/storage/inMemory.js +0 -24
- package/dist/cjs/storage/index.js +0 -2
- package/dist/cjs/storage/indexedDB.js +0 -101
- package/dist/cjs/storage/localStorage.js +0 -51
- package/dist/cjs/tree/signingSession.js +0 -229
- package/dist/cjs/tree/txTree.js +0 -192
- package/dist/cjs/tree/validation.js +0 -107
- package/dist/cjs/utils/anchor.js +0 -35
- package/dist/cjs/utils/arkTransaction.js +0 -271
- package/dist/cjs/utils/bip21.js +0 -127
- package/dist/cjs/utils/syncCursors.js +0 -128
- package/dist/cjs/utils/timelock.js +0 -59
- package/dist/cjs/utils/transaction.js +0 -28
- package/dist/cjs/utils/transactionHistory.js +0 -183
- package/dist/cjs/utils/txSizeEstimator.js +0 -132
- package/dist/cjs/utils/unknownFields.js +0 -174
- package/dist/cjs/wallet/asset-manager.js +0 -330
- package/dist/cjs/wallet/asset.js +0 -119
- package/dist/cjs/wallet/batch.js +0 -183
- package/dist/cjs/wallet/delegator.js +0 -308
- package/dist/cjs/wallet/expo/background.js +0 -116
- package/dist/cjs/wallet/expo/index.js +0 -9
- package/dist/cjs/wallet/expo/wallet.js +0 -230
- package/dist/cjs/wallet/hdDescriptorProvider.js +0 -188
- package/dist/cjs/wallet/index.js +0 -82
- package/dist/cjs/wallet/inputSignerRouter.js +0 -98
- package/dist/cjs/wallet/onchain.js +0 -290
- package/dist/cjs/wallet/ramps.js +0 -216
- package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +0 -953
- package/dist/cjs/wallet/serviceWorker/wallet.js +0 -1174
- package/dist/cjs/wallet/signingErrors.js +0 -32
- package/dist/cjs/wallet/unroll.js +0 -293
- package/dist/cjs/wallet/utils.js +0 -111
- package/dist/cjs/wallet/validation.js +0 -154
- package/dist/cjs/wallet/vtxo-manager.js +0 -1142
- package/dist/cjs/wallet/wallet.js +0 -2195
- package/dist/cjs/wallet/walletReceiveRotator.js +0 -547
- package/dist/cjs/worker/browser/service-worker-manager.js +0 -183
- package/dist/cjs/worker/browser/utils.js +0 -67
- package/dist/cjs/worker/errors.js +0 -16
- package/dist/cjs/worker/expo/asyncStorageTaskQueue.js +0 -78
- package/dist/cjs/worker/expo/index.js +0 -13
- package/dist/cjs/worker/expo/processors/contractPollProcessor.js +0 -62
- package/dist/cjs/worker/expo/processors/index.js +0 -6
- package/dist/cjs/worker/expo/taskQueue.js +0 -41
- package/dist/cjs/worker/expo/taskRunner.js +0 -73
- package/dist/cjs/worker/messageBus.js +0 -474
- package/dist/esm/adapters/asyncStorage.js +0 -1
- package/dist/esm/adapters/expo.js +0 -3
- package/dist/esm/adapters/fileSystem.js +0 -1
- package/dist/esm/adapters/indexedDB.js +0 -1
- package/dist/esm/adapters/localStorage.js +0 -1
- package/dist/esm/arkfee/celenv.js +0 -40
- package/dist/esm/arkfee/estimator.js +0 -139
- package/dist/esm/arkfee/index.js +0 -1
- package/dist/esm/arkfee/types.js +0 -22
- package/dist/esm/arknote/index.js +0 -124
- package/dist/esm/bip322/index.js +0 -267
- package/dist/esm/contracts/arkcontract.js +0 -140
- package/dist/esm/contracts/contractManager.js +0 -645
- package/dist/esm/contracts/contractWatcher.js +0 -594
- package/dist/esm/contracts/handlers/default.js +0 -90
- package/dist/esm/contracts/handlers/delegate.js +0 -87
- package/dist/esm/contracts/handlers/helpers.js +0 -110
- package/dist/esm/contracts/handlers/index.js +0 -12
- package/dist/esm/contracts/handlers/registry.js +0 -86
- package/dist/esm/contracts/handlers/vhtlc.js +0 -191
- package/dist/esm/contracts/index.js +0 -13
- package/dist/esm/contracts/types.js +0 -1
- package/dist/esm/contracts/vtxoOwnership.js +0 -69
- package/dist/esm/extension/asset/assetGroup.js +0 -224
- package/dist/esm/extension/asset/assetId.js +0 -148
- package/dist/esm/extension/asset/assetInput.js +0 -217
- package/dist/esm/extension/asset/assetOutput.js +0 -169
- package/dist/esm/extension/asset/assetRef.js +0 -144
- package/dist/esm/extension/asset/index.js +0 -8
- package/dist/esm/extension/asset/metadata.js +0 -182
- package/dist/esm/extension/asset/packet.js +0 -110
- package/dist/esm/extension/asset/types.js +0 -19
- package/dist/esm/extension/asset/utils.js +0 -99
- package/dist/esm/extension/index.js +0 -248
- package/dist/esm/extension/packet.js +0 -16
- package/dist/esm/forfeit.js +0 -41
- package/dist/esm/identity/descriptor.js +0 -161
- package/dist/esm/identity/descriptorProvider.js +0 -1
- package/dist/esm/identity/hdCapableIdentity.js +0 -17
- package/dist/esm/identity/index.js +0 -13
- package/dist/esm/identity/seedIdentity.js +0 -469
- package/dist/esm/identity/serialize.js +0 -164
- package/dist/esm/identity/singleKey.js +0 -121
- package/dist/esm/identity/staticDescriptorProvider.js +0 -61
- package/dist/esm/index.js +0 -87
- package/dist/esm/intent/index.js +0 -255
- package/dist/esm/musig2/index.js +0 -3
- package/dist/esm/musig2/keys.js +0 -21
- package/dist/esm/musig2/nonces.js +0 -11
- package/dist/esm/musig2/sign.js +0 -63
- package/dist/esm/networks.js +0 -22
- package/dist/esm/package.json +0 -3
- package/dist/esm/providers/ark.js +0 -572
- package/dist/esm/providers/delegator.js +0 -81
- package/dist/esm/providers/electrum.js +0 -864
- package/dist/esm/providers/errors.js +0 -54
- package/dist/esm/providers/expoArk.js +0 -78
- package/dist/esm/providers/expoIndexer.js +0 -107
- package/dist/esm/providers/expoUtils.js +0 -87
- package/dist/esm/providers/indexer.js +0 -626
- package/dist/esm/providers/onchain.js +0 -258
- package/dist/esm/providers/utils.js +0 -117
- package/dist/esm/repositories/contractRepository.js +0 -1
- package/dist/esm/repositories/inMemory/contractRepository.js +0 -51
- package/dist/esm/repositories/inMemory/walletRepository.js +0 -111
- package/dist/esm/repositories/index.js +0 -10
- package/dist/esm/repositories/indexedDB/contractRepository.js +0 -183
- package/dist/esm/repositories/indexedDB/db.js +0 -4
- package/dist/esm/repositories/indexedDB/manager.js +0 -95
- package/dist/esm/repositories/indexedDB/schema.js +0 -199
- package/dist/esm/repositories/indexedDB/walletRepository.js +0 -470
- package/dist/esm/repositories/indexedDB/websqlAdapter.js +0 -138
- package/dist/esm/repositories/migrations/contractRepositoryImpl.js +0 -121
- package/dist/esm/repositories/migrations/fromStorageAdapter.js +0 -58
- package/dist/esm/repositories/migrations/walletRepositoryImpl.js +0 -180
- package/dist/esm/repositories/realm/contractRepository.js +0 -112
- package/dist/esm/repositories/realm/index.js +0 -3
- package/dist/esm/repositories/realm/schemas.js +0 -153
- package/dist/esm/repositories/realm/types.js +0 -6
- package/dist/esm/repositories/realm/walletRepository.js +0 -301
- package/dist/esm/repositories/scriptFromAddress.js +0 -13
- package/dist/esm/repositories/serialization.js +0 -67
- package/dist/esm/repositories/sqlite/contractRepository.js +0 -131
- package/dist/esm/repositories/sqlite/index.js +0 -2
- package/dist/esm/repositories/sqlite/types.js +0 -1
- package/dist/esm/repositories/sqlite/walletRepository.js +0 -437
- package/dist/esm/repositories/walletRepository.js +0 -1
- package/dist/esm/script/address.js +0 -104
- package/dist/esm/script/base.js +0 -179
- package/dist/esm/script/default.js +0 -54
- package/dist/esm/script/delegate.js +0 -50
- package/dist/esm/script/tapscript.js +0 -615
- package/dist/esm/script/vhtlc.js +0 -167
- package/dist/esm/storage/asyncStorage.js +0 -46
- package/dist/esm/storage/fileSystem.js +0 -104
- package/dist/esm/storage/inMemory.js +0 -20
- package/dist/esm/storage/index.js +0 -1
- package/dist/esm/storage/indexedDB.js +0 -97
- package/dist/esm/storage/localStorage.js +0 -47
- package/dist/esm/tree/signingSession.js +0 -191
- package/dist/esm/tree/txTree.js +0 -188
- package/dist/esm/tree/validation.js +0 -101
- package/dist/esm/utils/anchor.js +0 -31
- package/dist/esm/utils/arkTransaction.js +0 -264
- package/dist/esm/utils/bip21.js +0 -123
- package/dist/esm/utils/syncCursors.js +0 -119
- package/dist/esm/utils/timelock.js +0 -22
- package/dist/esm/utils/transaction.js +0 -24
- package/dist/esm/utils/transactionHistory.js +0 -180
- package/dist/esm/utils/txSizeEstimator.js +0 -128
- package/dist/esm/utils/unknownFields.js +0 -169
- package/dist/esm/wallet/asset-manager.js +0 -325
- package/dist/esm/wallet/asset.js +0 -113
- package/dist/esm/wallet/batch.js +0 -180
- package/dist/esm/wallet/delegator.js +0 -303
- package/dist/esm/wallet/expo/background.js +0 -111
- package/dist/esm/wallet/expo/index.js +0 -2
- package/dist/esm/wallet/expo/wallet.js +0 -193
- package/dist/esm/wallet/hdDescriptorProvider.js +0 -184
- package/dist/esm/wallet/index.js +0 -75
- package/dist/esm/wallet/inputSignerRouter.js +0 -94
- package/dist/esm/wallet/onchain.js +0 -285
- package/dist/esm/wallet/ramps.js +0 -212
- package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +0 -946
- package/dist/esm/wallet/serviceWorker/wallet.js +0 -1169
- package/dist/esm/wallet/signingErrors.js +0 -27
- package/dist/esm/wallet/unroll.js +0 -289
- package/dist/esm/wallet/utils.js +0 -103
- package/dist/esm/wallet/validation.js +0 -142
- package/dist/esm/wallet/vtxo-manager.js +0 -1136
- package/dist/esm/wallet/wallet.js +0 -2186
- package/dist/esm/wallet/walletReceiveRotator.js +0 -540
- package/dist/esm/worker/browser/service-worker-manager.js +0 -177
- package/dist/esm/worker/browser/utils.js +0 -63
- package/dist/esm/worker/errors.js +0 -11
- package/dist/esm/worker/expo/asyncStorageTaskQueue.js +0 -74
- package/dist/esm/worker/expo/index.js +0 -4
- package/dist/esm/worker/expo/processors/contractPollProcessor.js +0 -59
- package/dist/esm/worker/expo/processors/index.js +0 -1
- package/dist/esm/worker/expo/taskQueue.js +0 -37
- package/dist/esm/worker/expo/taskRunner.js +0 -69
- package/dist/esm/worker/messageBus.js +0 -470
- package/dist/types/adapters/asyncStorage.d.ts +0 -2
- package/dist/types/adapters/expo.d.ts +0 -4
- package/dist/types/adapters/fileSystem.d.ts +0 -2
- package/dist/types/adapters/indexedDB.d.ts +0 -2
- package/dist/types/adapters/localStorage.d.ts +0 -2
- package/dist/types/arkfee/celenv.d.ts +0 -25
- package/dist/types/arkfee/estimator.d.ts +0 -49
- package/dist/types/arkfee/index.d.ts +0 -2
- package/dist/types/arkfee/types.d.ts +0 -38
- package/dist/types/arknote/index.d.ts +0 -84
- package/dist/types/bip322/index.d.ts +0 -55
- package/dist/types/contracts/arkcontract.d.ts +0 -99
- package/dist/types/contracts/contractManager.d.ts +0 -411
- package/dist/types/contracts/contractWatcher.d.ts +0 -217
- package/dist/types/contracts/handlers/default.d.ts +0 -19
- package/dist/types/contracts/handlers/delegate.d.ts +0 -21
- package/dist/types/contracts/handlers/helpers.d.ts +0 -19
- package/dist/types/contracts/handlers/index.d.ts +0 -7
- package/dist/types/contracts/handlers/registry.d.ts +0 -65
- package/dist/types/contracts/handlers/vhtlc.d.ts +0 -32
- package/dist/types/contracts/index.d.ts +0 -14
- package/dist/types/contracts/types.d.ts +0 -250
- package/dist/types/contracts/vtxoOwnership.d.ts +0 -33
- package/dist/types/extension/asset/assetGroup.d.ts +0 -119
- package/dist/types/extension/asset/assetId.d.ts +0 -83
- package/dist/types/extension/asset/assetInput.d.ts +0 -64
- package/dist/types/extension/asset/assetOutput.d.ts +0 -54
- package/dist/types/extension/asset/assetRef.d.ts +0 -91
- package/dist/types/extension/asset/index.d.ts +0 -8
- package/dist/types/extension/asset/metadata.d.ts +0 -52
- package/dist/types/extension/asset/packet.d.ts +0 -41
- package/dist/types/extension/asset/types.d.ts +0 -16
- package/dist/types/extension/asset/utils.d.ts +0 -21
- package/dist/types/extension/index.d.ts +0 -56
- package/dist/types/extension/packet.d.ts +0 -21
- package/dist/types/forfeit.d.ts +0 -18
- package/dist/types/identity/descriptor.d.ts +0 -61
- package/dist/types/identity/descriptorProvider.d.ts +0 -42
- package/dist/types/identity/hdCapableIdentity.d.ts +0 -71
- package/dist/types/identity/index.d.ts +0 -57
- package/dist/types/identity/seedIdentity.d.ts +0 -270
- package/dist/types/identity/serialize.d.ts +0 -96
- package/dist/types/identity/singleKey.d.ts +0 -62
- package/dist/types/identity/staticDescriptorProvider.d.ts +0 -18
- package/dist/types/index.d.ts +0 -59
- package/dist/types/intent/index.d.ts +0 -86
- package/dist/types/musig2/index.d.ts +0 -4
- package/dist/types/musig2/keys.d.ts +0 -9
- package/dist/types/musig2/nonces.d.ts +0 -14
- package/dist/types/musig2/sign.d.ts +0 -27
- package/dist/types/networks.d.ts +0 -16
- package/dist/types/providers/ark.d.ts +0 -369
- package/dist/types/providers/delegator.d.ts +0 -82
- package/dist/types/providers/electrum.d.ts +0 -312
- package/dist/types/providers/errors.d.ts +0 -13
- package/dist/types/providers/expoArk.d.ts +0 -22
- package/dist/types/providers/expoIndexer.d.ts +0 -18
- package/dist/types/providers/expoUtils.d.ts +0 -18
- package/dist/types/providers/indexer.d.ts +0 -301
- package/dist/types/providers/onchain.d.ts +0 -148
- package/dist/types/providers/utils.d.ts +0 -12
- package/dist/types/repositories/contractRepository.d.ts +0 -32
- package/dist/types/repositories/inMemory/contractRepository.d.ts +0 -17
- package/dist/types/repositories/inMemory/walletRepository.d.ts +0 -29
- package/dist/types/repositories/index.d.ts +0 -9
- package/dist/types/repositories/indexedDB/contractRepository.d.ts +0 -21
- package/dist/types/repositories/indexedDB/db.d.ts +0 -4
- package/dist/types/repositories/indexedDB/manager.d.ts +0 -25
- package/dist/types/repositories/indexedDB/schema.d.ts +0 -9
- package/dist/types/repositories/indexedDB/walletRepository.d.ts +0 -28
- package/dist/types/repositories/indexedDB/websqlAdapter.d.ts +0 -49
- package/dist/types/repositories/migrations/contractRepositoryImpl.d.ts +0 -24
- package/dist/types/repositories/migrations/fromStorageAdapter.d.ts +0 -19
- package/dist/types/repositories/migrations/walletRepositoryImpl.d.ts +0 -27
- package/dist/types/repositories/realm/contractRepository.d.ts +0 -24
- package/dist/types/repositories/realm/index.d.ts +0 -4
- package/dist/types/repositories/realm/types.d.ts +0 -16
- package/dist/types/repositories/realm/walletRepository.d.ts +0 -34
- package/dist/types/repositories/scriptFromAddress.d.ts +0 -9
- package/dist/types/repositories/serialization.d.ts +0 -65
- package/dist/types/repositories/sqlite/contractRepository.d.ts +0 -33
- package/dist/types/repositories/sqlite/index.d.ts +0 -3
- package/dist/types/repositories/sqlite/types.d.ts +0 -18
- package/dist/types/repositories/walletRepository.d.ts +0 -72
- package/dist/types/script/address.d.ts +0 -67
- package/dist/types/script/base.d.ts +0 -105
- package/dist/types/script/default.d.ts +0 -44
- package/dist/types/script/delegate.d.ts +0 -40
- package/dist/types/script/tapscript.d.ts +0 -169
- package/dist/types/script/vhtlc.d.ts +0 -66
- package/dist/types/tree/signingSession.d.ts +0 -37
- package/dist/types/tree/txTree.d.ts +0 -28
- package/dist/types/tree/validation.d.ts +0 -15
- package/dist/types/utils/anchor.d.ts +0 -19
- package/dist/types/utils/arkTransaction.d.ts +0 -49
- package/dist/types/utils/bip21.d.ts +0 -38
- package/dist/types/utils/syncCursors.d.ts +0 -60
- package/dist/types/utils/timelock.d.ts +0 -9
- package/dist/types/utils/transaction.d.ts +0 -13
- package/dist/types/utils/transactionHistory.d.ts +0 -15
- package/dist/types/utils/txSizeEstimator.d.ts +0 -40
- package/dist/types/utils/unknownFields.d.ts +0 -83
- package/dist/types/wallet/asset-manager.d.ts +0 -69
- package/dist/types/wallet/asset.d.ts +0 -21
- package/dist/types/wallet/batch.d.ts +0 -107
- package/dist/types/wallet/delegator.d.ts +0 -48
- package/dist/types/wallet/expo/background.d.ts +0 -66
- package/dist/types/wallet/expo/index.d.ts +0 -4
- package/dist/types/wallet/hdDescriptorProvider.d.ts +0 -114
- package/dist/types/wallet/index.d.ts +0 -789
- package/dist/types/wallet/inputSignerRouter.d.ts +0 -35
- package/dist/types/wallet/onchain.d.ts +0 -109
- package/dist/types/wallet/ramps.d.ts +0 -64
- package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +0 -543
- package/dist/types/wallet/serviceWorker/wallet.d.ts +0 -248
- package/dist/types/wallet/signingErrors.d.ts +0 -19
- package/dist/types/wallet/unroll.d.ts +0 -114
- package/dist/types/wallet/utils.d.ts +0 -36
- package/dist/types/wallet/validation.d.ts +0 -24
- package/dist/types/wallet/vtxo-manager.d.ts +0 -476
- package/dist/types/wallet/wallet.d.ts +0 -409
- package/dist/types/wallet/walletReceiveRotator.d.ts +0 -306
- package/dist/types/worker/browser/service-worker-manager.d.ts +0 -32
- package/dist/types/worker/browser/utils.d.ts +0 -17
- package/dist/types/worker/errors.d.ts +0 -7
- package/dist/types/worker/expo/index.d.ts +0 -7
- package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +0 -19
- package/dist/types/worker/expo/processors/index.d.ts +0 -1
- package/dist/types/worker/expo/taskQueue.d.ts +0 -50
- package/dist/types/worker/expo/taskRunner.d.ts +0 -66
- package/dist/types/worker/messageBus.d.ts +0 -189
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Thrown when a rotated contract (default or delegate) is missing the
|
|
3
|
-
* metadata.signingDescriptor required to route it to a descriptor-aware
|
|
4
|
-
* signer.
|
|
5
|
-
*/
|
|
6
|
-
export class MissingSigningDescriptorError extends Error {
|
|
7
|
-
constructor(contractScript, contractType) {
|
|
8
|
-
super(`Cannot sign input for ${contractType} contract ${contractScript}: ` +
|
|
9
|
-
`metadata.signingDescriptor is missing. This wallet was rotated ` +
|
|
10
|
-
`on an earlier build that did not persist signing descriptors. ` +
|
|
11
|
-
`Manually set metadata.signingDescriptor on the contract record, ` +
|
|
12
|
-
`or restore from a pre-rotation snapshot.`);
|
|
13
|
-
this.contractScript = contractScript;
|
|
14
|
-
this.contractType = contractType;
|
|
15
|
-
this.name = "MissingSigningDescriptorError";
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Thrown when an input needs descriptor-aware signing but no
|
|
20
|
-
* DescriptorProvider was wired into the wallet.
|
|
21
|
-
*/
|
|
22
|
-
export class DescriptorSigningProviderMissingError extends Error {
|
|
23
|
-
constructor() {
|
|
24
|
-
super("Descriptor signing requested but no DescriptorProvider was wired into this wallet");
|
|
25
|
-
this.name = "DescriptorSigningProviderMissingError";
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
import { base64, hex } from "@scure/base";
|
|
2
|
-
import { SigHash, TaprootControlBlock } from "@scure/btc-signer";
|
|
3
|
-
import { timelockToSequence } from "../utils/timelock.js";
|
|
4
|
-
import { ChainTxType } from "../providers/indexer.js";
|
|
5
|
-
import { VtxoScript } from "../script/base.js";
|
|
6
|
-
import { TxWeightEstimator } from "../utils/txSizeEstimator.js";
|
|
7
|
-
import { Wallet } from "./wallet.js";
|
|
8
|
-
import { Transaction } from "../utils/transaction.js";
|
|
9
|
-
import { DUST_AMOUNT } from "./utils.js";
|
|
10
|
-
export var Unroll;
|
|
11
|
-
(function (Unroll) {
|
|
12
|
-
let StepType;
|
|
13
|
-
(function (StepType) {
|
|
14
|
-
StepType[StepType["UNROLL"] = 0] = "UNROLL";
|
|
15
|
-
StepType[StepType["WAIT"] = 1] = "WAIT";
|
|
16
|
-
StepType[StepType["DONE"] = 2] = "DONE";
|
|
17
|
-
})(StepType = Unroll.StepType || (Unroll.StepType = {}));
|
|
18
|
-
/**
|
|
19
|
-
* Manages the unrolling process of a virtual output back to the Bitcoin blockchain.
|
|
20
|
-
*
|
|
21
|
-
* The Session class implements an async iterator that processes the unrolling steps:
|
|
22
|
-
* 1. **WAIT**: Waits for a transaction to be confirmed onchain (if it's in mempool)
|
|
23
|
-
* 2. **UNROLL**: Broadcasts the next transaction in the chain to the blockchain
|
|
24
|
-
* 3. **DONE**: Indicates the unrolling process is complete
|
|
25
|
-
*
|
|
26
|
-
* The unrolling process works by traversing the transaction chain from the root (most recent)
|
|
27
|
-
* to the leaf (oldest), broadcasting each transaction that isn't already onchain.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```typescript
|
|
31
|
-
* const session = await Unroll.Session.create(vtxoOutpoint, bumper, explorer, indexer);
|
|
32
|
-
*
|
|
33
|
-
* // iterate over the steps
|
|
34
|
-
* for await (const doneStep of session) {
|
|
35
|
-
* switch (doneStep.type) {
|
|
36
|
-
* case Unroll.StepType.WAIT:
|
|
37
|
-
* console.log(`Transaction ${doneStep.txid} confirmed`);
|
|
38
|
-
* break;
|
|
39
|
-
* case Unroll.StepType.UNROLL:
|
|
40
|
-
* console.log(`Broadcasting transaction ${doneStep.tx.id}`);
|
|
41
|
-
* break;
|
|
42
|
-
* case Unroll.StepType.DONE:
|
|
43
|
-
* console.log(`Unrolling complete for virtual output ${doneStep.vtxoTxid}`);
|
|
44
|
-
* break;
|
|
45
|
-
* }
|
|
46
|
-
* }
|
|
47
|
-
* ```
|
|
48
|
-
**/
|
|
49
|
-
class Session {
|
|
50
|
-
/** Create an unroll session from a virtual output outpoint and its dependency chain. */
|
|
51
|
-
constructor(toUnroll, bumper, explorer, indexer) {
|
|
52
|
-
this.toUnroll = toUnroll;
|
|
53
|
-
this.bumper = bumper;
|
|
54
|
-
this.explorer = explorer;
|
|
55
|
-
this.indexer = indexer;
|
|
56
|
-
}
|
|
57
|
-
/** Create an unroll session by loading the virtual output chain from the indexer. */
|
|
58
|
-
static async create(toUnroll, bumper, explorer, indexer) {
|
|
59
|
-
const { chain } = await indexer.getVtxoChain(toUnroll);
|
|
60
|
-
return new Session({ ...toUnroll, chain }, bumper, explorer, indexer);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Get the next step to be executed
|
|
64
|
-
* @returns The next step to be executed + the function to execute it
|
|
65
|
-
*/
|
|
66
|
-
async next() {
|
|
67
|
-
let nextTxToBroadcast;
|
|
68
|
-
const chain = this.toUnroll.chain;
|
|
69
|
-
// Iterate through the chain from the end (root) to the beginning (leaf)
|
|
70
|
-
for (let i = chain.length - 1; i >= 0; i--) {
|
|
71
|
-
const chainTx = chain[i];
|
|
72
|
-
// Skip commitment transactions as they are always onchain
|
|
73
|
-
if (chainTx.type === ChainTxType.COMMITMENT ||
|
|
74
|
-
chainTx.type === ChainTxType.UNSPECIFIED) {
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
try {
|
|
78
|
-
// Check if the transaction is confirmed onchain
|
|
79
|
-
const txInfo = await this.explorer.getTxStatus(chainTx.txid);
|
|
80
|
-
// If found but not confirmed, it means the tx is in the mempool
|
|
81
|
-
// An unilateral exit is running, we must wait for it to be confirmed
|
|
82
|
-
if (!txInfo.confirmed) {
|
|
83
|
-
return {
|
|
84
|
-
type: StepType.WAIT,
|
|
85
|
-
txid: chainTx.txid,
|
|
86
|
-
do: doWait(this.explorer, chainTx.txid),
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
catch (e) {
|
|
91
|
-
// If the tx is not found, it's offchain, let's break
|
|
92
|
-
nextTxToBroadcast = chainTx;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (!nextTxToBroadcast) {
|
|
97
|
-
return {
|
|
98
|
-
type: StepType.DONE,
|
|
99
|
-
vtxoTxid: this.toUnroll.txid,
|
|
100
|
-
do: () => Promise.resolve(),
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
// Get the virtual transaction data
|
|
104
|
-
const virtualTxs = await this.indexer.getVirtualTxs([
|
|
105
|
-
nextTxToBroadcast.txid,
|
|
106
|
-
]);
|
|
107
|
-
if (virtualTxs.txs.length === 0) {
|
|
108
|
-
throw new Error(`Tx ${nextTxToBroadcast.txid} not found`);
|
|
109
|
-
}
|
|
110
|
-
const tx = Transaction.fromPSBT(base64.decode(virtualTxs.txs[0]));
|
|
111
|
-
// finalize the tree transaction
|
|
112
|
-
if (nextTxToBroadcast.type === ChainTxType.TREE) {
|
|
113
|
-
const input = tx.getInput(0);
|
|
114
|
-
if (!input) {
|
|
115
|
-
throw new Error("Input not found");
|
|
116
|
-
}
|
|
117
|
-
const tapKeySig = input.tapKeySig;
|
|
118
|
-
if (!tapKeySig) {
|
|
119
|
-
throw new Error("Tap key sig not found");
|
|
120
|
-
}
|
|
121
|
-
tx.updateInput(0, {
|
|
122
|
-
finalScriptWitness: [tapKeySig],
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
// finalize Arkade transaction
|
|
127
|
-
tx.finalize();
|
|
128
|
-
}
|
|
129
|
-
const pkg = await this.bumper.bumpP2A(tx);
|
|
130
|
-
return {
|
|
131
|
-
type: StepType.UNROLL,
|
|
132
|
-
tx,
|
|
133
|
-
pkg,
|
|
134
|
-
do: doUnroll(this.explorer, pkg),
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Iterate over the steps to be executed and execute them
|
|
139
|
-
* @returns An async iterator over the executed steps
|
|
140
|
-
*/
|
|
141
|
-
async *[Symbol.asyncIterator]() {
|
|
142
|
-
let lastStep;
|
|
143
|
-
do {
|
|
144
|
-
if (lastStep !== undefined) {
|
|
145
|
-
// wait 1 second before trying the next step in order to give time to the
|
|
146
|
-
// explorer to update the tx status
|
|
147
|
-
await sleep(1000);
|
|
148
|
-
}
|
|
149
|
-
const step = await this.next();
|
|
150
|
-
await step.do();
|
|
151
|
-
yield step;
|
|
152
|
-
lastStep = step.type;
|
|
153
|
-
} while (lastStep !== StepType.DONE);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
Unroll.Session = Session;
|
|
157
|
-
/**
|
|
158
|
-
* Complete the unroll of a virtual output by broadcasting the transaction that spends the CSV path.
|
|
159
|
-
* @param wallet the wallet owning the virtual output(s)
|
|
160
|
-
* @param vtxoTxids the txids of the virtual output(s) to complete unroll
|
|
161
|
-
* @param outputAddress the address to send the unrolled funds to
|
|
162
|
-
* @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
|
|
163
|
-
* @returns the txid of the transaction spending the unrolled funds
|
|
164
|
-
*/
|
|
165
|
-
async function completeUnroll(wallet, vtxoTxids, outputAddress) {
|
|
166
|
-
const signedTx = await prepareUnrollTransaction(wallet, vtxoTxids, outputAddress);
|
|
167
|
-
await wallet.onchainProvider.broadcastTransaction(signedTx.hex);
|
|
168
|
-
return signedTx.id;
|
|
169
|
-
}
|
|
170
|
-
Unroll.completeUnroll = completeUnroll;
|
|
171
|
-
})(Unroll || (Unroll = {}));
|
|
172
|
-
/**
|
|
173
|
-
* Prepares the transaction that spends the CSV path to complete unrolling a VTXO.
|
|
174
|
-
* @param wallet the wallet owning the VTXO(s)
|
|
175
|
-
* @param vtxoTxIds the txids of the VTXO(s) to complete unroll
|
|
176
|
-
* @param outputAddress the address to send the unrolled funds to
|
|
177
|
-
* @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
|
|
178
|
-
* @returns the transaction spending the unrolled funds
|
|
179
|
-
*/
|
|
180
|
-
export async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
181
|
-
const chainTip = await wallet.onchainProvider.getChainTip();
|
|
182
|
-
let vtxos = await wallet.getVtxos({ withUnrolled: true });
|
|
183
|
-
vtxos = vtxos.filter((vtxo) => vtxoTxIds.includes(vtxo.txid));
|
|
184
|
-
if (vtxos.length === 0) {
|
|
185
|
-
throw new Error("No vtxos to complete unroll");
|
|
186
|
-
}
|
|
187
|
-
const inputs = [];
|
|
188
|
-
let totalAmount = 0n;
|
|
189
|
-
const txWeightEstimator = TxWeightEstimator.create();
|
|
190
|
-
for (const vtxo of vtxos) {
|
|
191
|
-
if (!vtxo.isUnrolled) {
|
|
192
|
-
throw new Error(`Vtxo ${vtxo.txid}:${vtxo.vout} is not fully unrolled, use unroll first`);
|
|
193
|
-
}
|
|
194
|
-
const txStatus = await wallet.onchainProvider.getTxStatus(vtxo.txid);
|
|
195
|
-
if (!txStatus.confirmed) {
|
|
196
|
-
throw new Error(`tx ${vtxo.txid} is not confirmed`);
|
|
197
|
-
}
|
|
198
|
-
const exit = availableExitPath({ height: txStatus.blockHeight, time: txStatus.blockTime }, chainTip, vtxo);
|
|
199
|
-
if (!exit) {
|
|
200
|
-
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
201
|
-
}
|
|
202
|
-
const spendingLeaf = VtxoScript.decode(vtxo.tapTree).findLeaf(hex.encode(exit.script));
|
|
203
|
-
if (!spendingLeaf) {
|
|
204
|
-
throw new Error(`spending leaf not found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
205
|
-
}
|
|
206
|
-
totalAmount += BigInt(vtxo.value);
|
|
207
|
-
const sequence = timelockToSequence(exit.params.timelock);
|
|
208
|
-
inputs.push({
|
|
209
|
-
txid: vtxo.txid,
|
|
210
|
-
index: vtxo.vout,
|
|
211
|
-
tapLeafScript: [spendingLeaf],
|
|
212
|
-
sequence,
|
|
213
|
-
witnessUtxo: {
|
|
214
|
-
amount: BigInt(vtxo.value),
|
|
215
|
-
script: VtxoScript.decode(vtxo.tapTree).pkScript,
|
|
216
|
-
},
|
|
217
|
-
sighashType: SigHash.DEFAULT,
|
|
218
|
-
});
|
|
219
|
-
txWeightEstimator.addTapscriptInput(64, spendingLeaf[1].length, TaprootControlBlock.encode(spendingLeaf[0]).length);
|
|
220
|
-
}
|
|
221
|
-
const tx = new Transaction({ version: 2 });
|
|
222
|
-
for (const input of inputs) {
|
|
223
|
-
tx.addInput(input);
|
|
224
|
-
}
|
|
225
|
-
txWeightEstimator.addOutputAddress(outputAddress, wallet.network);
|
|
226
|
-
let feeRate = await wallet.onchainProvider.getFeeRate();
|
|
227
|
-
if (!feeRate || feeRate < Wallet.MIN_FEE_RATE) {
|
|
228
|
-
feeRate = Wallet.MIN_FEE_RATE;
|
|
229
|
-
}
|
|
230
|
-
// Esplora returns a `number` and bitcoind regtest sometimes reports
|
|
231
|
-
// fractional sat/vB (e.g. 1.006). `BigInt(1.006)` throws RangeError
|
|
232
|
-
// — round up so we always pay AT LEAST the advertised rate and
|
|
233
|
-
// satisfy BigInt's integer requirement.
|
|
234
|
-
const feeAmount = txWeightEstimator.vsize().fee(BigInt(Math.ceil(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(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 = 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/esm/wallet/utils.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { ArkAddress, } from "../index.js";
|
|
2
|
-
import { contractHandlers } from "../contracts/handlers/index.js";
|
|
3
|
-
import { hex } from "@scure/base";
|
|
4
|
-
export const DUST_AMOUNT = 546; // sats
|
|
5
|
-
export function extendCoin(wallet, utxo) {
|
|
6
|
-
return {
|
|
7
|
-
...utxo,
|
|
8
|
-
forfeitTapLeafScript: wallet.boardingTapscript.forfeit(),
|
|
9
|
-
intentTapLeafScript: wallet.boardingTapscript.forfeit(),
|
|
10
|
-
tapTree: wallet.boardingTapscript.encode(),
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function extendVtxoFromContract(vtxo, contract) {
|
|
14
|
-
const handler = contractHandlers.get(contract.type);
|
|
15
|
-
if (!handler) {
|
|
16
|
-
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
17
|
-
}
|
|
18
|
-
const script = handler.createScript(contract.params);
|
|
19
|
-
return {
|
|
20
|
-
...vtxo,
|
|
21
|
-
forfeitTapLeafScript: script.forfeit(),
|
|
22
|
-
intentTapLeafScript: script.forfeit(),
|
|
23
|
-
tapTree: script.encode(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Extend a VirtualCoin with the tap scripts of whichever contract locks it.
|
|
28
|
-
*
|
|
29
|
-
* The second argument accepts either form, so each callsite passes what it
|
|
30
|
-
* already has:
|
|
31
|
-
* - a single `Contract` (when the caller already knows the owning contract,
|
|
32
|
-
* e.g. the contract manager iterating its own `scriptToContract` map), or
|
|
33
|
-
* - a `ReadonlyMap<script, Contract>` (when the caller resolves by
|
|
34
|
-
* `vtxo.script`, populated by the indexer).
|
|
35
|
-
*
|
|
36
|
-
* Throws when no contract can be resolved — there is intentionally no
|
|
37
|
-
* default-tapscript fallback. When the wallet owns multiple contracts
|
|
38
|
-
* (default + delegate, several active vHTLCs, etc.) a default-tapscript path
|
|
39
|
-
* silently stamps every VTXO with the same forfeit/intent data, overwriting
|
|
40
|
-
* the correct data for any VTXO locked to a non-default contract. Callers
|
|
41
|
-
* must feed a Contract or a populated script→Contract map; otherwise the
|
|
42
|
-
* caller (typically `ContractManager.annotateVtxos`) should fetch the owning
|
|
43
|
-
* contract first.
|
|
44
|
-
*/
|
|
45
|
-
export function extendVirtualCoinForContract(vtxo, contractOrMap) {
|
|
46
|
-
const contract = resolveContract(vtxo, contractOrMap);
|
|
47
|
-
if (!contract) {
|
|
48
|
-
throw new Error("extendVirtualCoinForContract: no contract matched vtxo.script — callers must resolve the owning contract before annotating");
|
|
49
|
-
}
|
|
50
|
-
return extendVtxoFromContract(vtxo, contract);
|
|
51
|
-
}
|
|
52
|
-
function isContractMap(value) {
|
|
53
|
-
// A `Contract` is a plain object with a string `type`. `ReadonlyMap` is
|
|
54
|
-
// an interface so `instanceof Map` is not enough to narrow it — but a
|
|
55
|
-
// contract has no `get` method, so duck-typing on that is unambiguous.
|
|
56
|
-
return typeof value.get === "function";
|
|
57
|
-
}
|
|
58
|
-
function resolveContract(vtxo, contractOrMap) {
|
|
59
|
-
if (!contractOrMap)
|
|
60
|
-
return undefined;
|
|
61
|
-
if (isContractMap(contractOrMap)) {
|
|
62
|
-
return contractOrMap.get(vtxo.script);
|
|
63
|
-
}
|
|
64
|
-
return contractOrMap;
|
|
65
|
-
}
|
|
66
|
-
export function getRandomId() {
|
|
67
|
-
const randomValue = crypto.getRandomValues(new Uint8Array(16));
|
|
68
|
-
return hex.encode(randomValue);
|
|
69
|
-
}
|
|
70
|
-
export function isValidArkAddress(address) {
|
|
71
|
-
try {
|
|
72
|
-
ArkAddress.decode(address);
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
export function validateRecipients(recipients, dustAmount) {
|
|
80
|
-
const validatedRecipients = [];
|
|
81
|
-
for (const recipient of recipients) {
|
|
82
|
-
let address;
|
|
83
|
-
try {
|
|
84
|
-
address = ArkAddress.decode(recipient.address);
|
|
85
|
-
}
|
|
86
|
-
catch (e) {
|
|
87
|
-
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
88
|
-
}
|
|
89
|
-
const amount = recipient.amount || dustAmount;
|
|
90
|
-
if (amount <= 0) {
|
|
91
|
-
throw new Error("Amount must be positive");
|
|
92
|
-
}
|
|
93
|
-
validatedRecipients.push({
|
|
94
|
-
address: recipient.address,
|
|
95
|
-
assets: recipient.assets ?? [],
|
|
96
|
-
amount,
|
|
97
|
-
script: amount < dustAmount
|
|
98
|
-
? address.subdustPkScript
|
|
99
|
-
: address.pkScript,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
return validatedRecipients;
|
|
103
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { equalBytes } from "@scure/btc-signer/utils.js";
|
|
2
|
-
import { ArkAddress } from "../script/address.js";
|
|
3
|
-
import { Extension } from "../extension/index.js";
|
|
4
|
-
import { Address, OutScript } from "@scure/btc-signer";
|
|
5
|
-
export const ErrOffchainOutputNotFound = (address) => new Error(`offchain send output not found: ${address}`);
|
|
6
|
-
export const ErrInvalidAssetOutputAmount = (got, want, assetId) => new Error(`invalid asset output amount for ${assetId}: got ${got}, want ${want}`);
|
|
7
|
-
export const ErrAssetGroupNotFound = (assetId) => new Error(`asset group not found in batch leaf: ${assetId}`);
|
|
8
|
-
export const ErrAssetOutputNotFound = (assetId, outputIndex) => new Error(`asset output not found in asset group ${assetId} at index ${outputIndex}`);
|
|
9
|
-
export const ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
10
|
-
export const ErrInvalidOnchainOutputAssets = (address) => new Error(`onchain output ${address} cannot have assets`);
|
|
11
|
-
export const ErrOnchainOutputNotFound = (address) => new Error(`onchain output not found: ${address}`);
|
|
12
|
-
export const ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain output ${address}, missing amount`);
|
|
13
|
-
/**
|
|
14
|
-
* Validates both offchain and onchain recipients.
|
|
15
|
-
* Offchain recipients are checked against vtxo tree leaves for correct amounts and assets.
|
|
16
|
-
* Onchain recipients are validated against the round transaction outputs (amounts and scripts)
|
|
17
|
-
* via validateOnchainRecipient.
|
|
18
|
-
*
|
|
19
|
-
* @param commitmentTx - The commitment transaction to validate against
|
|
20
|
-
* @param vtxoTreeLeaves - The vtxo tree leaves to validate against
|
|
21
|
-
* @param recipients - The expected recipients to validate (both offchain and onchain)
|
|
22
|
-
* @param network - Network for decoding onchain addresses (e.g. mainnet, testnet)
|
|
23
|
-
* @throws {Error} if a recipient is not present or invalid in the vtxo tree or commitment tx
|
|
24
|
-
*/
|
|
25
|
-
export function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, network) {
|
|
26
|
-
// usedOutputs is used to track which outputs are validated to handle
|
|
27
|
-
// duplicate recipients in the list
|
|
28
|
-
const usedOutputs = new Set();
|
|
29
|
-
const usedOnchainOutputs = new Set();
|
|
30
|
-
for (const recipient of recipients) {
|
|
31
|
-
let arkAddress;
|
|
32
|
-
try {
|
|
33
|
-
arkAddress = ArkAddress.decode(recipient.address);
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
validateOffchainRecipient(vtxoTreeLeaves, arkAddress, recipient, usedOutputs);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
// validateOnchainRecipient verifies the given recipient is present in the commitment tx outputs list
|
|
43
|
-
function validateOnchainRecipient(commitmentTx, recipient, network, usedOutputs) {
|
|
44
|
-
const addr = Address(network).decode(recipient.address);
|
|
45
|
-
const expectedPkScript = OutScript.encode(addr);
|
|
46
|
-
if (!recipient.amount) {
|
|
47
|
-
throw ErrInvalidOnchainOutputAmount(recipient.address);
|
|
48
|
-
}
|
|
49
|
-
if (recipient.assets && recipient.assets.length > 0) {
|
|
50
|
-
throw ErrInvalidOnchainOutputAssets(recipient.address);
|
|
51
|
-
}
|
|
52
|
-
for (let i = 0; i < commitmentTx.outputsLength; i++) {
|
|
53
|
-
if (usedOutputs.has(i)) {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
const output = commitmentTx.getOutput(i);
|
|
57
|
-
if (!output?.script || output.script.length === 0) {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
if (equalBytes(output.script, expectedPkScript)) {
|
|
61
|
-
if (output.amount !== BigInt(recipient.amount)) {
|
|
62
|
-
continue; // if amount does not match, continue
|
|
63
|
-
}
|
|
64
|
-
// we found the right output, recipient is valid, return
|
|
65
|
-
usedOutputs.add(i);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
// if we get here, the recipient is not present in the commitment tx outputs list
|
|
70
|
-
throw ErrOnchainOutputNotFound(recipient.address);
|
|
71
|
-
}
|
|
72
|
-
// validate the offchain recipient is present in one of the leaf output
|
|
73
|
-
// also verify the asset packet is here, and point the same output index
|
|
74
|
-
function validateOffchainRecipient(leaves, arkAddress, recipient, usedOutputs // leafIndex:outputIndex
|
|
75
|
-
) {
|
|
76
|
-
const expectedPkScript = arkAddress.pkScript;
|
|
77
|
-
if (!recipient.amount) {
|
|
78
|
-
throw ErrInvalidOffchainOutputAmount(recipient.address);
|
|
79
|
-
}
|
|
80
|
-
const expectedAmount = BigInt(recipient.amount);
|
|
81
|
-
let found = false;
|
|
82
|
-
for (let leafIdx = 0; leafIdx < leaves.length; leafIdx++) {
|
|
83
|
-
const leaf = leaves[leafIdx];
|
|
84
|
-
for (let outputIndex = 0; outputIndex < leaf.outputsLength; outputIndex++) {
|
|
85
|
-
const output = leaf.getOutput(outputIndex);
|
|
86
|
-
if (!output?.script || output.script.length === 0) {
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
if (!equalBytes(output.script, expectedPkScript)) {
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (output.amount !== expectedAmount) {
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
const key = `${leafIdx}:${outputIndex}`;
|
|
96
|
-
if (usedOutputs.has(key)) {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
usedOutputs.add(key);
|
|
100
|
-
found = true;
|
|
101
|
-
// if assets, validate the asset packet
|
|
102
|
-
if (recipient.assets && recipient.assets.length > 0) {
|
|
103
|
-
validateAssetOutputs(leaf, outputIndex, recipient.assets);
|
|
104
|
-
}
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
if (found) {
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (!found) {
|
|
112
|
-
throw ErrOffchainOutputNotFound(recipient.address);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
function validateAssetOutputs(leafTx, outputIndex, expectedAssets) {
|
|
116
|
-
const ext = Extension.fromTx(leafTx);
|
|
117
|
-
const assetPacket = ext.getAssetPacket();
|
|
118
|
-
if (!assetPacket) {
|
|
119
|
-
throw new Error("no asset packet found in extension");
|
|
120
|
-
}
|
|
121
|
-
for (const { assetId, amount } of expectedAssets) {
|
|
122
|
-
validateAssetGroupOutput(assetPacket, outputIndex, assetId, amount);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function validateAssetGroupOutput(packet, outputIndex, assetId, expectedAmount) {
|
|
126
|
-
const assetGroup = packet.groups.find((group) => {
|
|
127
|
-
if (group.isIssuance())
|
|
128
|
-
return false;
|
|
129
|
-
return group.assetId.toString() === assetId;
|
|
130
|
-
});
|
|
131
|
-
if (!assetGroup) {
|
|
132
|
-
throw ErrAssetGroupNotFound(assetId);
|
|
133
|
-
}
|
|
134
|
-
// find the output at the expected index
|
|
135
|
-
const assetOutput = assetGroup.outputs.find((output) => output.vout === outputIndex);
|
|
136
|
-
if (!assetOutput) {
|
|
137
|
-
throw ErrAssetOutputNotFound(assetId, outputIndex);
|
|
138
|
-
}
|
|
139
|
-
if (assetOutput.amount !== expectedAmount) {
|
|
140
|
-
throw ErrInvalidAssetOutputAmount(assetOutput.amount, expectedAmount, assetId);
|
|
141
|
-
}
|
|
142
|
-
}
|