@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
package/dist/esm/utils/bip21.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
export var BIP21Error;
|
|
2
|
-
(function (BIP21Error) {
|
|
3
|
-
BIP21Error["INVALID_URI"] = "Invalid BIP21 URI";
|
|
4
|
-
BIP21Error["INVALID_ADDRESS"] = "Invalid address";
|
|
5
|
-
})(BIP21Error || (BIP21Error = {}));
|
|
6
|
-
export class BIP21 {
|
|
7
|
-
/**
|
|
8
|
-
* Create a BIP21 URI from the provided parameters.
|
|
9
|
-
*
|
|
10
|
-
* @param params - BIP21 parameters to encode
|
|
11
|
-
* @returns Encoded BIP21 URI
|
|
12
|
-
*/
|
|
13
|
-
static create(params) {
|
|
14
|
-
const { address, ...options } = params;
|
|
15
|
-
// Build query string
|
|
16
|
-
const queryParams = {};
|
|
17
|
-
for (const [key, value] of Object.entries(options)) {
|
|
18
|
-
if (value === undefined)
|
|
19
|
-
continue;
|
|
20
|
-
if (key === "amount") {
|
|
21
|
-
if (!isFinite(value)) {
|
|
22
|
-
console.warn("Invalid amount");
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
if (value < 0) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
queryParams[key] = value;
|
|
29
|
-
}
|
|
30
|
-
else if (key === "ark") {
|
|
31
|
-
// Validate Arkade address format
|
|
32
|
-
if (typeof value === "string" &&
|
|
33
|
-
(value.startsWith("ark") || value.startsWith("tark"))) {
|
|
34
|
-
queryParams[key] = value;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
console.warn("Invalid ARK address format");
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else if (key === "sp") {
|
|
41
|
-
// Validate Silent Payment address format (placeholder)
|
|
42
|
-
if (typeof value === "string" && value.startsWith("sp")) {
|
|
43
|
-
queryParams[key] = value;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
console.warn("Invalid Silent Payment address format");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else if (typeof value === "string" || typeof value === "number") {
|
|
50
|
-
queryParams[key] = value;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const query = Object.keys(queryParams).length > 0
|
|
54
|
-
? "?" +
|
|
55
|
-
new URLSearchParams(Object.fromEntries(Object.entries(queryParams).map(([k, v]) => [
|
|
56
|
-
k,
|
|
57
|
-
String(v),
|
|
58
|
-
]))).toString()
|
|
59
|
-
: "";
|
|
60
|
-
return `bitcoin:${address ? address.toLowerCase() : ""}${query}`;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Parse a BIP21 URI and return its decoded parameters.
|
|
64
|
-
*
|
|
65
|
-
* @param uri - BIP21 URI to parse
|
|
66
|
-
* @returns Parsed BIP21 URI data
|
|
67
|
-
* @throws Error if the URI does not start with the `bitcoin:` scheme
|
|
68
|
-
*/
|
|
69
|
-
static parse(uri) {
|
|
70
|
-
if (!uri.toLowerCase().startsWith("bitcoin:")) {
|
|
71
|
-
throw new Error(BIP21Error.INVALID_URI);
|
|
72
|
-
}
|
|
73
|
-
// Remove the `bitcoin:` prefix while preserving the case of the rest.
|
|
74
|
-
const withoutPrefix = uri.slice(uri.toLowerCase().indexOf("bitcoin:") + 8);
|
|
75
|
-
const [address, query] = withoutPrefix.split("?");
|
|
76
|
-
const params = {};
|
|
77
|
-
if (address) {
|
|
78
|
-
params.address = address.toLowerCase();
|
|
79
|
-
}
|
|
80
|
-
if (query) {
|
|
81
|
-
const queryParams = new URLSearchParams(query);
|
|
82
|
-
for (const [key, value] of queryParams.entries()) {
|
|
83
|
-
if (!value)
|
|
84
|
-
continue;
|
|
85
|
-
if (key === "amount") {
|
|
86
|
-
const amount = Number(value);
|
|
87
|
-
if (!isFinite(amount)) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (amount < 0) {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
params[key] = amount;
|
|
94
|
-
}
|
|
95
|
-
else if (key === "ark") {
|
|
96
|
-
// Validate Arkade address format
|
|
97
|
-
if (value.startsWith("ark") || value.startsWith("tark")) {
|
|
98
|
-
params[key] = value;
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
console.warn("Invalid ARK address format");
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
else if (key === "sp") {
|
|
105
|
-
// Validate Silent Payment address format (placeholder)
|
|
106
|
-
if (value.startsWith("sp")) {
|
|
107
|
-
params[key] = value;
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
console.warn("Invalid Silent Payment address format");
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
params[key] = value;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return {
|
|
119
|
-
originalString: uri,
|
|
120
|
-
params,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/** Lag behind real-time to avoid racing with indexer writes. */
|
|
2
|
-
export const SAFETY_LAG_MS = 30000;
|
|
3
|
-
/** Overlap window so boundary virtual outputs are never missed. */
|
|
4
|
-
export const OVERLAP_MS = 24 * 60 * 60 * 1000;
|
|
5
|
-
/**
|
|
6
|
-
* Per-repository mutex that serializes wallet-state mutations so that
|
|
7
|
-
* concurrent read-modify-write cycles never silently overwrite
|
|
8
|
-
* each other's changes.
|
|
9
|
-
*/
|
|
10
|
-
const walletStateLocks = new WeakMap();
|
|
11
|
-
/**
|
|
12
|
-
* Atomically read, mutate, and persist wallet state.
|
|
13
|
-
* All callers that modify wallet state should go through this helper
|
|
14
|
-
* to avoid lost-update races between interleaved async operations.
|
|
15
|
-
*/
|
|
16
|
-
export async function updateWalletState(repo, updater) {
|
|
17
|
-
const prev = walletStateLocks.get(repo) ?? Promise.resolve();
|
|
18
|
-
const op = prev.then(async () => {
|
|
19
|
-
const state = (await repo.getWalletState()) ?? {};
|
|
20
|
-
await repo.saveWalletState(updater(state));
|
|
21
|
-
});
|
|
22
|
-
// Store a version that never rejects so the chain doesn't break.
|
|
23
|
-
walletStateLocks.set(repo, op.catch(() => { }));
|
|
24
|
-
return op;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Settings key that gates interpretation of the `lastSyncTime` field.
|
|
28
|
-
*
|
|
29
|
-
* The `lastSyncTime` column existed pre-PR with a different semantic
|
|
30
|
-
* (wall-clock at sync completion, written by the buggy sync loop this
|
|
31
|
-
* PR fixes). On upgrade we cannot trust any pre-existing value, so the
|
|
32
|
-
* cursor is only honoured after the first successful post-upgrade
|
|
33
|
-
* advance writes this marker into the `settings` JSON blob. Reusing
|
|
34
|
-
* `settings` avoids any schema migration.
|
|
35
|
-
*/
|
|
36
|
-
const CURSOR_MIGRATED_KEY = "vtxoCursorMigrated";
|
|
37
|
-
function hasMigrationMarker(state) {
|
|
38
|
-
return state?.settings?.[CURSOR_MIGRATED_KEY] === true;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Read the global high-water mark for VTXO indexer syncs.
|
|
42
|
-
*
|
|
43
|
-
* Returns `0` when:
|
|
44
|
-
* - the wallet has never been synced (bootstrap case), or
|
|
45
|
-
* - the stored `lastSyncTime` was written by pre-PR code and is not
|
|
46
|
-
* safe to reuse under the new semantics (see {@link CURSOR_MIGRATED_KEY}).
|
|
47
|
-
*/
|
|
48
|
-
export async function getSyncCursor(repo) {
|
|
49
|
-
const state = await repo.getWalletState();
|
|
50
|
-
if (!hasMigrationMarker(state))
|
|
51
|
-
return 0;
|
|
52
|
-
return state?.lastSyncTime ?? 0;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Advance the global cursor after a successful full-scope delta sync.
|
|
56
|
-
*
|
|
57
|
-
* Clamped with `Math.max` against the current value so concurrent syncs
|
|
58
|
-
* that finish out of order can't rewind the cursor: `lastUpdatedAt` is
|
|
59
|
-
* captured before each sync enters the `updateWalletState` mutex, and
|
|
60
|
-
* the later-started sync would otherwise overwrite the earlier-captured
|
|
61
|
-
* one with a smaller value. The legacy value is discarded on the first
|
|
62
|
-
* advance if the migration marker is absent so pre-PR data doesn't
|
|
63
|
-
* survive the upgrade.
|
|
64
|
-
*/
|
|
65
|
-
export async function advanceSyncCursor(repo, lastUpdatedAt) {
|
|
66
|
-
await updateWalletState(repo, (state) => {
|
|
67
|
-
const current = hasMigrationMarker(state)
|
|
68
|
-
? (state.lastSyncTime ?? 0)
|
|
69
|
-
: 0;
|
|
70
|
-
return {
|
|
71
|
-
...state,
|
|
72
|
-
lastSyncTime: Math.max(current, lastUpdatedAt),
|
|
73
|
-
settings: {
|
|
74
|
-
...(state.settings ?? {}),
|
|
75
|
-
[CURSOR_MIGRATED_KEY]: true,
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Remove the sync cursor, forcing a full re-bootstrap on next sync.
|
|
82
|
-
*
|
|
83
|
-
* Also clears the migration marker so any stored `lastSyncTime` is
|
|
84
|
-
* treated as untrusted on the next read.
|
|
85
|
-
*/
|
|
86
|
-
export async function clearSyncCursor(repo) {
|
|
87
|
-
await updateWalletState(repo, (state) => {
|
|
88
|
-
const { [CURSOR_MIGRATED_KEY]: _, ...restSettings } = state.settings ?? {};
|
|
89
|
-
return {
|
|
90
|
-
...state,
|
|
91
|
-
lastSyncTime: undefined,
|
|
92
|
-
settings: restSettings,
|
|
93
|
-
};
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Compute the `after` lower-bound for a delta sync query.
|
|
98
|
-
*
|
|
99
|
-
* No upper bound (`before`) is applied to the query so that freshly
|
|
100
|
-
* created virtual outputs are never excluded. The safety lag is applied only
|
|
101
|
-
* when advancing the cursor (see @see cursorCutoff).
|
|
102
|
-
*/
|
|
103
|
-
export function computeSyncWindow(cursor) {
|
|
104
|
-
const after = Math.max(0, cursor - OVERLAP_MS);
|
|
105
|
-
return { after };
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* The safe high-water mark for cursor advancement.
|
|
109
|
-
* Lags behind real-time by @see SAFETY_LAG_MS so that virtual outputs still
|
|
110
|
-
* being indexed are re-queried on the next sync.
|
|
111
|
-
*
|
|
112
|
-
* When `requestStartedAt` is provided the cutoff is frozen to the
|
|
113
|
-
* request start rather than wall-clock at commit time, preventing
|
|
114
|
-
* long-running paginated fetches from advancing the cursor past the
|
|
115
|
-
* data they actually observed.
|
|
116
|
-
*/
|
|
117
|
-
export function cursorCutoff(requestStartedAt) {
|
|
118
|
-
return (requestStartedAt ?? Date.now()) - SAFETY_LAG_MS;
|
|
119
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as bip68 from "bip68";
|
|
2
|
-
/**
|
|
3
|
-
* Convert RelativeTimelock to BIP68 sequence number.
|
|
4
|
-
*/
|
|
5
|
-
export function timelockToSequence(timelock) {
|
|
6
|
-
return bip68.encode(timelock.type === "blocks"
|
|
7
|
-
? { blocks: Number(timelock.value) }
|
|
8
|
-
: { seconds: Number(timelock.value) });
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Convert BIP68 sequence number back to RelativeTimelock.
|
|
12
|
-
*/
|
|
13
|
-
export function sequenceToTimelock(sequence) {
|
|
14
|
-
const decoded = bip68.decode(sequence);
|
|
15
|
-
if ("blocks" in decoded && decoded.blocks !== undefined) {
|
|
16
|
-
return { type: "blocks", value: BigInt(decoded.blocks) };
|
|
17
|
-
}
|
|
18
|
-
if ("seconds" in decoded && decoded.seconds !== undefined) {
|
|
19
|
-
return { type: "seconds", value: BigInt(decoded.seconds) };
|
|
20
|
-
}
|
|
21
|
-
throw new Error(`Invalid BIP68 sequence: ${sequence}`);
|
|
22
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Transaction as BtcSignerTransaction } from "@scure/btc-signer";
|
|
2
|
-
/**
|
|
3
|
-
* Transaction is a wrapper around the @scure/btc-signer Transaction class.
|
|
4
|
-
* It adds the Arkade protocol specific options to the transaction.
|
|
5
|
-
*/
|
|
6
|
-
export class Transaction extends BtcSignerTransaction {
|
|
7
|
-
constructor(opts) {
|
|
8
|
-
super(withArkOpts(opts));
|
|
9
|
-
}
|
|
10
|
-
static fromPSBT(psbt_, opts) {
|
|
11
|
-
return BtcSignerTransaction.fromPSBT(psbt_, withArkOpts(opts));
|
|
12
|
-
}
|
|
13
|
-
static fromRaw(raw, opts) {
|
|
14
|
-
return BtcSignerTransaction.fromRaw(raw, withArkOpts(opts));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
Transaction.ARK_TX_OPTS = {
|
|
18
|
-
allowUnknown: true,
|
|
19
|
-
allowUnknownOutputs: true,
|
|
20
|
-
allowUnknownInputs: true,
|
|
21
|
-
};
|
|
22
|
-
function withArkOpts(opts) {
|
|
23
|
-
return { ...Transaction.ARK_TX_OPTS, ...opts };
|
|
24
|
-
}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { TxType } from "../wallet/index.js";
|
|
2
|
-
const txKey = {
|
|
3
|
-
commitmentTxid: "",
|
|
4
|
-
boardingTxid: "",
|
|
5
|
-
arkTxid: "",
|
|
6
|
-
};
|
|
7
|
-
function collectAssets(vtxos) {
|
|
8
|
-
const map = new Map();
|
|
9
|
-
for (const vtxo of vtxos) {
|
|
10
|
-
if (vtxo.assets) {
|
|
11
|
-
for (const a of vtxo.assets) {
|
|
12
|
-
map.set(a.assetId, (map.get(a.assetId) ?? 0n) + a.amount);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
if (map.size === 0)
|
|
17
|
-
return undefined;
|
|
18
|
-
return Array.from(map, ([assetId, amount]) => ({ assetId, amount }));
|
|
19
|
-
}
|
|
20
|
-
function subtractAssets(spent, change) {
|
|
21
|
-
const map = new Map();
|
|
22
|
-
for (const vtxo of change) {
|
|
23
|
-
if (vtxo.assets) {
|
|
24
|
-
for (const a of vtxo.assets) {
|
|
25
|
-
map.set(a.assetId, (map.get(a.assetId) ?? 0n) + a.amount);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
for (const vtxo of spent) {
|
|
30
|
-
if (vtxo.assets) {
|
|
31
|
-
for (const a of vtxo.assets) {
|
|
32
|
-
const current = map.get(a.assetId) ?? 0n;
|
|
33
|
-
const remaining = current - a.amount;
|
|
34
|
-
if (remaining !== 0n) {
|
|
35
|
-
map.set(a.assetId, remaining);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
map.delete(a.assetId);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (map.size === 0)
|
|
44
|
-
return undefined;
|
|
45
|
-
return Array.from(map, ([assetId, amount]) => ({ assetId, amount }));
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Builds the transaction history by analyzing virtual outputs, boarding transactions, and ignored commitments.
|
|
49
|
-
* History is sorted from newest to oldest and is composed only of SENT and RECEIVED transactions.
|
|
50
|
-
*
|
|
51
|
-
* @param {VirtualCoin[]} vtxos - An array of virtual outputs representing the user's transactions and balances.
|
|
52
|
-
* @param {ArkTransaction[]} allBoardingTxs - An array of boarding transactions to include in the history.
|
|
53
|
-
* @param {Set<string>} commitmentsToIgnore - A set of commitment IDs that should be excluded from processing.
|
|
54
|
-
* @return {ExtendedArkTransaction[]} A sorted array of extended Arkade transactions, representing the transaction history.
|
|
55
|
-
*/
|
|
56
|
-
export async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, getTxCreatedAt) {
|
|
57
|
-
const fromOldestVtxo = [...vtxos].sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
58
|
-
const sent = [];
|
|
59
|
-
let received = [];
|
|
60
|
-
for (const vtxo of fromOldestVtxo) {
|
|
61
|
-
if (vtxo.status.isLeaf) {
|
|
62
|
-
// If this virtual output is a leaf and it's not the settlement of a boarding or there's no virtual output refreshed by it,
|
|
63
|
-
// it's translated into a received batch transaction
|
|
64
|
-
if (!commitmentsToIgnore.has(vtxo.virtualStatus.commitmentTxIds[0]) &&
|
|
65
|
-
fromOldestVtxo.filter((v) => v.settledBy === vtxo.virtualStatus.commitmentTxIds[0]).length === 0) {
|
|
66
|
-
const assets = collectAssets([vtxo]);
|
|
67
|
-
received.push({
|
|
68
|
-
key: {
|
|
69
|
-
...txKey,
|
|
70
|
-
commitmentTxid: vtxo.virtualStatus.commitmentTxIds[0],
|
|
71
|
-
},
|
|
72
|
-
tag: "batch",
|
|
73
|
-
type: TxType.TxReceived,
|
|
74
|
-
amount: vtxo.value,
|
|
75
|
-
settled: vtxo.status.isLeaf || vtxo.isSpent,
|
|
76
|
-
createdAt: vtxo.createdAt.getTime(),
|
|
77
|
-
...(assets && { assets }),
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else if (fromOldestVtxo.filter((v) => v.arkTxId === vtxo.txid).length === 0) {
|
|
82
|
-
// If this virtual output is preconfirmed and does not spend any other virtual outputs,
|
|
83
|
-
// it's translated into a received offchain transaction
|
|
84
|
-
const assets = collectAssets([vtxo]);
|
|
85
|
-
received.push({
|
|
86
|
-
key: { ...txKey, arkTxid: vtxo.txid },
|
|
87
|
-
tag: "offchain",
|
|
88
|
-
type: TxType.TxReceived,
|
|
89
|
-
amount: vtxo.value,
|
|
90
|
-
settled: vtxo.status.isLeaf || vtxo.isSpent,
|
|
91
|
-
createdAt: vtxo.createdAt.getTime(),
|
|
92
|
-
...(assets && { assets }),
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
// If the virtual output is spent, it's translated into a sent transaction unless:
|
|
96
|
-
// - it's been refreshed (we don't want to add any record in this case)
|
|
97
|
-
// - a sent transaction has been already added to avoid duplicates (can happen if many virtual outputs have been spent in the same tx or forfeited in the same batch)
|
|
98
|
-
if (vtxo.isSpent) {
|
|
99
|
-
// If the virtual output is spent offchain, it's translated into an offchain sent tx
|
|
100
|
-
if (vtxo.arkTxId &&
|
|
101
|
-
!sent.some((s) => s.key.arkTxid === vtxo.arkTxId)) {
|
|
102
|
-
const changes = fromOldestVtxo.filter((_) => _.txid === vtxo.arkTxId);
|
|
103
|
-
// We want to find all the other virtual outputs spent by the same transaction to
|
|
104
|
-
// calculate the full amount of the change.
|
|
105
|
-
const allSpent = fromOldestVtxo.filter((v) => v.arkTxId === vtxo.arkTxId);
|
|
106
|
-
const spentAmount = allSpent.reduce((acc, v) => acc + v.value, 0);
|
|
107
|
-
let txAmount = 0;
|
|
108
|
-
let txTime = 0;
|
|
109
|
-
if (changes.length > 0) {
|
|
110
|
-
const changeAmount = changes.reduce((acc, v) => acc + v.value, 0);
|
|
111
|
-
txAmount = spentAmount - changeAmount;
|
|
112
|
-
txTime = changes[0].createdAt.getTime();
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
txAmount = spentAmount;
|
|
116
|
-
// TODO: fetch the virtual output with /v1/indexer/vtxos?outpoints=<vtxo.arkTxid:0> to know when the tx was made
|
|
117
|
-
txTime = getTxCreatedAt
|
|
118
|
-
? ((await getTxCreatedAt(vtxo.arkTxId)) ??
|
|
119
|
-
vtxo.createdAt.getTime() + 1)
|
|
120
|
-
: vtxo.createdAt.getTime() + 1;
|
|
121
|
-
}
|
|
122
|
-
const assets = subtractAssets(allSpent, changes);
|
|
123
|
-
sent.push({
|
|
124
|
-
key: { ...txKey, arkTxid: vtxo.arkTxId },
|
|
125
|
-
tag: "offchain",
|
|
126
|
-
type: TxType.TxSent,
|
|
127
|
-
amount: txAmount,
|
|
128
|
-
settled: true,
|
|
129
|
-
createdAt: txTime,
|
|
130
|
-
...(assets && { assets }),
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
// If the virtual output is forfeited in a batch and the total sum of forfeited virtual outputs is bigger than the sum of new virtual outputs,
|
|
134
|
-
// it's translated into an exit sent tx
|
|
135
|
-
if (vtxo.settledBy &&
|
|
136
|
-
!commitmentsToIgnore.has(vtxo.settledBy) &&
|
|
137
|
-
!sent.some((s) => s.key.commitmentTxid === vtxo.settledBy)) {
|
|
138
|
-
const changes = fromOldestVtxo.filter((v) => v.status.isLeaf &&
|
|
139
|
-
v.virtualStatus.commitmentTxIds?.every((_) => vtxo.settledBy === _));
|
|
140
|
-
const forfeitVtxos = fromOldestVtxo.filter((v) => v.settledBy === vtxo.settledBy);
|
|
141
|
-
const forfeitAmount = forfeitVtxos.reduce((acc, v) => acc + v.value, 0);
|
|
142
|
-
if (changes.length > 0) {
|
|
143
|
-
const settledAmount = changes.reduce((acc, v) => acc + v.value, 0);
|
|
144
|
-
// forfeitAmount > settledAmount --> collaborative exit with offchain change
|
|
145
|
-
// TODO: make this support fees!
|
|
146
|
-
if (forfeitAmount > settledAmount) {
|
|
147
|
-
const assets = subtractAssets(forfeitVtxos, changes);
|
|
148
|
-
sent.push({
|
|
149
|
-
key: { ...txKey, commitmentTxid: vtxo.settledBy },
|
|
150
|
-
tag: "exit",
|
|
151
|
-
type: TxType.TxSent,
|
|
152
|
-
amount: forfeitAmount - settledAmount,
|
|
153
|
-
settled: true,
|
|
154
|
-
createdAt: changes[0].createdAt.getTime(),
|
|
155
|
-
...(assets && { assets }),
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
// forfeitAmount > 0 && settledAmount == 0 --> collaborative exit without any offchain change
|
|
161
|
-
const assets = subtractAssets(forfeitVtxos, []);
|
|
162
|
-
sent.push({
|
|
163
|
-
key: { ...txKey, commitmentTxid: vtxo.settledBy },
|
|
164
|
-
tag: "exit",
|
|
165
|
-
type: TxType.TxSent,
|
|
166
|
-
amount: forfeitAmount,
|
|
167
|
-
settled: true,
|
|
168
|
-
// TODO: fetch commitment tx with /v1/indexer/commitmentTx/<commitmentTxid> to know when the tx was made
|
|
169
|
-
createdAt: vtxo.createdAt.getTime() + 1,
|
|
170
|
-
...(assets && { assets }),
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
// Boardings are always inbound amounts, and we only hide the ones to ignore.
|
|
177
|
-
const boardingTx = allBoardingTxs.map((tx) => ({ ...tx, tag: "boarding" }));
|
|
178
|
-
const sorted = [...boardingTx, ...sent, ...received].sort((a, b) => b.createdAt - a.createdAt);
|
|
179
|
-
return sorted;
|
|
180
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { Address, OutScript } from "@scure/btc-signer";
|
|
2
|
-
/**
|
|
3
|
-
* Calculates the byte size required to store a variable-length integer (VarInt).
|
|
4
|
-
* Bitcoin uses VarInts to compact integer data (like array lengths).
|
|
5
|
-
*
|
|
6
|
-
* @param n - The integer value to check
|
|
7
|
-
* @returns The size in bytes (1, 3, 5, or 9)
|
|
8
|
-
*/
|
|
9
|
-
const getVarIntSize = (n) => {
|
|
10
|
-
if (n < 0xfd)
|
|
11
|
-
return 1;
|
|
12
|
-
if (n <= 0xffff)
|
|
13
|
-
return 3;
|
|
14
|
-
if (n <= 0xffffffff)
|
|
15
|
-
return 5;
|
|
16
|
-
return 9;
|
|
17
|
-
};
|
|
18
|
-
export class TxWeightEstimator {
|
|
19
|
-
constructor(hasWitness, inputCount, outputCount, inputSize, inputWitnessSize, outputSize) {
|
|
20
|
-
this.hasWitness = hasWitness;
|
|
21
|
-
this.inputCount = inputCount;
|
|
22
|
-
this.outputCount = outputCount;
|
|
23
|
-
this.inputSize = inputSize;
|
|
24
|
-
this.inputWitnessSize = inputWitnessSize;
|
|
25
|
-
this.outputSize = outputSize;
|
|
26
|
-
}
|
|
27
|
-
static create() {
|
|
28
|
-
return new TxWeightEstimator(false, 0, 0, 0, 0, 0);
|
|
29
|
-
}
|
|
30
|
-
addP2AInput() {
|
|
31
|
-
this.inputCount++;
|
|
32
|
-
this.inputSize += TxWeightEstimator.INPUT_SIZE;
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
addKeySpendInput(isDefault = true) {
|
|
36
|
-
this.inputCount++;
|
|
37
|
-
this.inputWitnessSize += 64 + 1 + (isDefault ? 0 : 1);
|
|
38
|
-
this.inputSize += TxWeightEstimator.INPUT_SIZE;
|
|
39
|
-
this.hasWitness = true;
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
addP2PKHInput() {
|
|
43
|
-
this.inputCount++;
|
|
44
|
-
this.inputWitnessSize++;
|
|
45
|
-
this.inputSize +=
|
|
46
|
-
TxWeightEstimator.INPUT_SIZE +
|
|
47
|
-
TxWeightEstimator.P2PKH_SCRIPT_SIG_SIZE;
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
addTapscriptInput(leafWitnessSize, leafScriptSize, leafControlBlockSize) {
|
|
51
|
-
const controlBlockWitnessSize = 1 +
|
|
52
|
-
TxWeightEstimator.BASE_CONTROL_BLOCK_SIZE +
|
|
53
|
-
1 +
|
|
54
|
-
leafScriptSize +
|
|
55
|
-
1 +
|
|
56
|
-
leafControlBlockSize;
|
|
57
|
-
this.inputCount++;
|
|
58
|
-
this.inputWitnessSize += leafWitnessSize + 1 + controlBlockWitnessSize;
|
|
59
|
-
this.inputSize += TxWeightEstimator.INPUT_SIZE;
|
|
60
|
-
this.hasWitness = true;
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
addP2WPKHOutput() {
|
|
64
|
-
this.outputCount++;
|
|
65
|
-
this.outputSize +=
|
|
66
|
-
TxWeightEstimator.OUTPUT_SIZE +
|
|
67
|
-
TxWeightEstimator.P2WPKH_OUTPUT_SIZE;
|
|
68
|
-
return this;
|
|
69
|
-
}
|
|
70
|
-
addP2TROutput() {
|
|
71
|
-
this.outputCount++;
|
|
72
|
-
this.outputSize +=
|
|
73
|
-
TxWeightEstimator.OUTPUT_SIZE + TxWeightEstimator.P2TR_OUTPUT_SIZE;
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Adds an output given a raw script.
|
|
78
|
-
* Cost = 8 bytes (amount) + varint(scriptLen) + scriptLen
|
|
79
|
-
*/
|
|
80
|
-
addOutputScript(script) {
|
|
81
|
-
this.outputCount++;
|
|
82
|
-
this.outputSize += 8 + getVarIntSize(script.length) + script.length;
|
|
83
|
-
return this;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Adds an output by decoding the address to get the exact script size.
|
|
87
|
-
*/
|
|
88
|
-
addOutputAddress(address, network) {
|
|
89
|
-
const payment = Address(network).decode(address);
|
|
90
|
-
const script = OutScript.encode(payment);
|
|
91
|
-
return this.addOutputScript(script);
|
|
92
|
-
}
|
|
93
|
-
vsize() {
|
|
94
|
-
const inputCount = getVarIntSize(this.inputCount);
|
|
95
|
-
const outputCount = getVarIntSize(this.outputCount);
|
|
96
|
-
// Calculate the size of the transaction without witness data
|
|
97
|
-
const txSizeStripped = TxWeightEstimator.BASE_TX_SIZE +
|
|
98
|
-
inputCount +
|
|
99
|
-
this.inputSize +
|
|
100
|
-
outputCount +
|
|
101
|
-
this.outputSize;
|
|
102
|
-
// Calculate the total weight
|
|
103
|
-
let weight = txSizeStripped * TxWeightEstimator.WITNESS_SCALE_FACTOR;
|
|
104
|
-
// Add witness data if present
|
|
105
|
-
if (this.hasWitness) {
|
|
106
|
-
weight +=
|
|
107
|
-
TxWeightEstimator.WITNESS_HEADER_SIZE + this.inputWitnessSize;
|
|
108
|
-
}
|
|
109
|
-
// Convert weight to vsize (weight / 4, rounded up)
|
|
110
|
-
return vsize(weight);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
TxWeightEstimator.P2PKH_SCRIPT_SIG_SIZE = 1 + 73 + 1 + 33;
|
|
114
|
-
TxWeightEstimator.INPUT_SIZE = 32 + 4 + 1 + 4;
|
|
115
|
-
TxWeightEstimator.BASE_CONTROL_BLOCK_SIZE = 1 + 32;
|
|
116
|
-
TxWeightEstimator.OUTPUT_SIZE = 8 + 1;
|
|
117
|
-
TxWeightEstimator.P2WPKH_OUTPUT_SIZE = 1 + 1 + 20;
|
|
118
|
-
TxWeightEstimator.BASE_TX_SIZE = 8 + 2; // Version + LockTime
|
|
119
|
-
TxWeightEstimator.WITNESS_HEADER_SIZE = 2; // Flag + Marker
|
|
120
|
-
TxWeightEstimator.WITNESS_SCALE_FACTOR = 4;
|
|
121
|
-
TxWeightEstimator.P2TR_OUTPUT_SIZE = 1 + 1 + 32;
|
|
122
|
-
const vsize = (weight) => {
|
|
123
|
-
const value = BigInt(Math.ceil(weight / TxWeightEstimator.WITNESS_SCALE_FACTOR));
|
|
124
|
-
return {
|
|
125
|
-
value,
|
|
126
|
-
fee: (feeRate) => feeRate * value,
|
|
127
|
-
};
|
|
128
|
-
};
|