@arkade-os/sdk 0.4.27 → 0.4.29
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 +45 -116
- 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-ChhTwpLf.d.cts +3892 -0
- package/dist/ark-ChhTwpLf.d.ts +3892 -0
- package/dist/asyncStorageTaskQueue-DW1-BpI7.d.cts +49 -0
- package/dist/{types/worker/expo/asyncStorageTaskQueue.d.ts → asyncStorageTaskQueue-DZ0nUuEJ.d.ts} +6 -3
- package/dist/chunk-5BLDMQED.cjs +18 -0
- package/dist/chunk-5BLDMQED.cjs.map +1 -0
- package/dist/chunk-6FLL2Q36.cjs +2701 -0
- package/dist/chunk-6FLL2Q36.cjs.map +1 -0
- package/dist/chunk-6NWNOLL3.js +2671 -0
- package/dist/chunk-6NWNOLL3.js.map +1 -0
- package/dist/chunk-ABWRLTX5.js +210 -0
- package/dist/chunk-ABWRLTX5.js.map +1 -0
- package/dist/chunk-BVP2U66Q.js +13943 -0
- package/dist/chunk-BVP2U66Q.js.map +1 -0
- package/dist/chunk-GDCTOSMV.cjs +14058 -0
- package/dist/chunk-GDCTOSMV.cjs.map +1 -0
- package/dist/chunk-GIGILVVP.cjs +213 -0
- package/dist/chunk-GIGILVVP.cjs.map +1 -0
- package/dist/chunk-IEO3XDKI.cjs +838 -0
- package/dist/chunk-IEO3XDKI.cjs.map +1 -0
- package/dist/chunk-NSBPE2FW.js +15 -0
- package/dist/chunk-NSBPE2FW.js.map +1 -0
- package/dist/chunk-PJUFOJ2L.cjs +100 -0
- package/dist/chunk-PJUFOJ2L.cjs.map +1 -0
- package/dist/chunk-TH6T23XG.js +95 -0
- package/dist/chunk-TH6T23XG.js.map +1 -0
- package/dist/chunk-TU3LVAPX.js +769 -0
- package/dist/chunk-TU3LVAPX.js.map +1 -0
- package/dist/chunk-WMIPYZSB.cjs +803 -0
- package/dist/chunk-WMIPYZSB.cjs.map +1 -0
- package/dist/chunk-YA4G7RFB.js +829 -0
- package/dist/chunk-YA4G7RFB.js.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-4JBUkUhR.d.cts +84 -0
- package/dist/delegate-DN7RELL1.d.ts +84 -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-Cn82bBUu.d.ts +199 -0
- package/dist/index-DfT5xzgY.d.cts +199 -0
- package/dist/index.cjs +504 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3469 -0
- package/dist/index.d.ts +3469 -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-B-aPfHhK.d.cts +114 -0
- package/dist/taskRunner-B-vG08pX.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 +175 -0
- package/dist/wallet/expo/index.cjs.map +1 -0
- package/dist/wallet/expo/index.d.cts +124 -0
- package/dist/wallet/expo/index.d.ts +124 -0
- package/dist/wallet/expo/index.js +173 -0
- package/dist/wallet/expo/index.js.map +1 -0
- package/dist/wallet-CCtqT2Wb.d.ts +778 -0
- package/dist/wallet-DjgFb_4T.d.cts +778 -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/expo/wallet.d.ts +0 -99
- 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,271 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildOffchainTx = buildOffchainTx;
|
|
4
|
-
exports.hasBoardingTxExpired = hasBoardingTxExpired;
|
|
5
|
-
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
6
|
-
exports.combineTapscriptSigs = combineTapscriptSigs;
|
|
7
|
-
exports.isValidArkAddress = isValidArkAddress;
|
|
8
|
-
const secp256k1_js_1 = require("@noble/curves/secp256k1.js");
|
|
9
|
-
const base_1 = require("@scure/base");
|
|
10
|
-
const btc_signer_1 = require("@scure/btc-signer");
|
|
11
|
-
const payment_js_1 = require("@scure/btc-signer/payment.js");
|
|
12
|
-
const tapscript_1 = require("../script/tapscript");
|
|
13
|
-
const base_2 = require("../script/base");
|
|
14
|
-
const anchor_1 = require("./anchor");
|
|
15
|
-
const unknownFields_1 = require("./unknownFields");
|
|
16
|
-
const transaction_1 = require("./transaction");
|
|
17
|
-
const address_1 = require("../script/address");
|
|
18
|
-
const extension_1 = require("../extension");
|
|
19
|
-
/**
|
|
20
|
-
* Builds an offchain transaction with checkpoint transactions.
|
|
21
|
-
*
|
|
22
|
-
* Creates one checkpoint transaction per input and a virtual transaction that
|
|
23
|
-
* combines all the checkpoints, sending to the specified outputs. This is the
|
|
24
|
-
* core function for creating Arkade transactions.
|
|
25
|
-
*
|
|
26
|
-
* @param inputs - Array of virtual transaction inputs
|
|
27
|
-
* @param outputs - Array of transaction outputs
|
|
28
|
-
* @param serverUnrollScript - Server unroll script for checkpoint transactions
|
|
29
|
-
* @returns Object containing the virtual transaction and checkpoint transactions
|
|
30
|
-
*/
|
|
31
|
-
function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
32
|
-
// TODO: use arkd /info
|
|
33
|
-
const MAX_OP_RETURN = 2;
|
|
34
|
-
let countOpReturn = 0;
|
|
35
|
-
let hasExtensionOutput = false;
|
|
36
|
-
for (const [index, output] of outputs.entries()) {
|
|
37
|
-
if (!output.script)
|
|
38
|
-
throw new Error(`missing output script ${index}`);
|
|
39
|
-
const isExtension = extension_1.Extension.isExtension(output.script);
|
|
40
|
-
const isOpReturn = isExtension || btc_signer_1.Script.decode(output.script)[0] === "RETURN";
|
|
41
|
-
if (isOpReturn) {
|
|
42
|
-
countOpReturn++;
|
|
43
|
-
}
|
|
44
|
-
if (!isExtension)
|
|
45
|
-
continue;
|
|
46
|
-
if (hasExtensionOutput)
|
|
47
|
-
throw new Error("multiple extension outputs");
|
|
48
|
-
hasExtensionOutput = true;
|
|
49
|
-
}
|
|
50
|
-
if (countOpReturn > MAX_OP_RETURN) {
|
|
51
|
-
throw new Error(`too many OP_RETURN outputs: ${countOpReturn} > ${MAX_OP_RETURN}`);
|
|
52
|
-
}
|
|
53
|
-
const checkpoints = inputs.map((input) => buildCheckpointTx(input, serverUnrollScript));
|
|
54
|
-
const arkTx = buildVirtualTx(checkpoints.map((c) => c.input), outputs);
|
|
55
|
-
return {
|
|
56
|
-
arkTx,
|
|
57
|
-
checkpoints: checkpoints.map((c) => c.tx),
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function buildVirtualTx(inputs, outputs) {
|
|
61
|
-
let lockTime = 0n;
|
|
62
|
-
for (const input of inputs) {
|
|
63
|
-
const tapscript = (0, tapscript_1.decodeTapscript)((0, base_2.scriptFromTapLeafScript)(input.tapLeafScript));
|
|
64
|
-
if (tapscript_1.CLTVMultisigTapscript.is(tapscript)) {
|
|
65
|
-
if (lockTime !== 0n) {
|
|
66
|
-
// if a locktime is already set, check if the new locktime is in the same unit
|
|
67
|
-
if (isSeconds(lockTime) !==
|
|
68
|
-
isSeconds(tapscript.params.absoluteTimelock)) {
|
|
69
|
-
throw new Error("cannot mix seconds and blocks locktime");
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (tapscript.params.absoluteTimelock > lockTime) {
|
|
73
|
-
lockTime = tapscript.params.absoluteTimelock;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const tx = new transaction_1.Transaction({
|
|
78
|
-
version: 3,
|
|
79
|
-
lockTime: Number(lockTime),
|
|
80
|
-
});
|
|
81
|
-
for (const [i, input] of inputs.entries()) {
|
|
82
|
-
tx.addInput({
|
|
83
|
-
txid: input.txid,
|
|
84
|
-
index: input.vout,
|
|
85
|
-
sequence: lockTime ? btc_signer_1.DEFAULT_SEQUENCE - 1 : undefined,
|
|
86
|
-
witnessUtxo: {
|
|
87
|
-
script: base_2.VtxoScript.decode(input.tapTree).pkScript,
|
|
88
|
-
amount: BigInt(input.value),
|
|
89
|
-
},
|
|
90
|
-
tapLeafScript: [input.tapLeafScript],
|
|
91
|
-
});
|
|
92
|
-
(0, unknownFields_1.setArkPsbtField)(tx, i, unknownFields_1.VtxoTaprootTree, input.tapTree);
|
|
93
|
-
}
|
|
94
|
-
for (const output of outputs) {
|
|
95
|
-
tx.addOutput(output);
|
|
96
|
-
}
|
|
97
|
-
// add the anchor output
|
|
98
|
-
tx.addOutput(anchor_1.P2A);
|
|
99
|
-
return tx;
|
|
100
|
-
}
|
|
101
|
-
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
102
|
-
// create the checkpoint virtual output script from collaborative closure
|
|
103
|
-
const collaborativeClosure = (0, tapscript_1.decodeTapscript)((0, base_2.scriptFromTapLeafScript)(vtxo.tapLeafScript));
|
|
104
|
-
// create the checkpoint virtual output script combining collaborative closure and server unroll script
|
|
105
|
-
const checkpointVtxoScript = new base_2.VtxoScript([
|
|
106
|
-
serverUnrollScript.script,
|
|
107
|
-
collaborativeClosure.script,
|
|
108
|
-
]);
|
|
109
|
-
// build the checkpoint virtual tx
|
|
110
|
-
const checkpointTx = buildVirtualTx([vtxo], [
|
|
111
|
-
{
|
|
112
|
-
amount: BigInt(vtxo.value),
|
|
113
|
-
script: checkpointVtxoScript.pkScript,
|
|
114
|
-
},
|
|
115
|
-
]);
|
|
116
|
-
// get the collaborative leaf proof
|
|
117
|
-
const collaborativeLeafProof = checkpointVtxoScript.findLeaf(base_1.hex.encode(collaborativeClosure.script));
|
|
118
|
-
// create the checkpoint input that will be used as input of the virtual tx
|
|
119
|
-
const checkpointInput = {
|
|
120
|
-
txid: checkpointTx.id,
|
|
121
|
-
vout: 0,
|
|
122
|
-
value: vtxo.value,
|
|
123
|
-
tapLeafScript: collaborativeLeafProof,
|
|
124
|
-
tapTree: checkpointVtxoScript.encode(),
|
|
125
|
-
};
|
|
126
|
-
return {
|
|
127
|
-
tx: checkpointTx,
|
|
128
|
-
input: checkpointInput,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
const nLocktimeMinSeconds = 500000000n;
|
|
132
|
-
function isSeconds(locktime) {
|
|
133
|
-
return locktime >= nLocktimeMinSeconds;
|
|
134
|
-
}
|
|
135
|
-
function hasBoardingTxExpired(coin, boardingTimelock, chainTipHeight) {
|
|
136
|
-
if (!coin.status.block_time)
|
|
137
|
-
return false;
|
|
138
|
-
if (boardingTimelock.value === 0n)
|
|
139
|
-
return true;
|
|
140
|
-
if (boardingTimelock.type === "blocks") {
|
|
141
|
-
if (chainTipHeight === undefined || !coin.status.block_height)
|
|
142
|
-
return false;
|
|
143
|
-
return (BigInt(chainTipHeight - coin.status.block_height) >=
|
|
144
|
-
boardingTimelock.value);
|
|
145
|
-
}
|
|
146
|
-
// validate expiry in terms of seconds
|
|
147
|
-
const now = BigInt(Math.floor(Date.now() / 1000));
|
|
148
|
-
const blockTime = BigInt(Math.floor(coin.status.block_time));
|
|
149
|
-
return blockTime + boardingTimelock.value <= now;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Formats a sighash type as a hex string (e.g., 0x01)
|
|
153
|
-
*/
|
|
154
|
-
function formatSighash(type) {
|
|
155
|
-
return `0x${type.toString(16).padStart(2, "0")}`;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Verify tapscript signatures on a transaction input
|
|
159
|
-
* @param tx Transaction to verify
|
|
160
|
-
* @param inputIndex Index of the input to verify
|
|
161
|
-
* @param requiredSigners List of required signer pubkeys (hex encoded)
|
|
162
|
-
* @param excludePubkeys List of pubkeys to exclude from verification (hex encoded, e.g., server key not yet signed)
|
|
163
|
-
* @param allowedSighashTypes List of allowed sighash types (defaults to [SigHash.DEFAULT])
|
|
164
|
-
* @throws Error if verification fails
|
|
165
|
-
*/
|
|
166
|
-
function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubkeys = [], allowedSighashTypes = [btc_signer_1.SigHash.DEFAULT]) {
|
|
167
|
-
const input = tx.getInput(inputIndex);
|
|
168
|
-
// Collect prevout scripts and amounts for ALL inputs (required for preimageWitnessV1)
|
|
169
|
-
const prevoutScripts = [];
|
|
170
|
-
const prevoutAmounts = [];
|
|
171
|
-
for (let i = 0; i < tx.inputsLength; i++) {
|
|
172
|
-
const inp = tx.getInput(i);
|
|
173
|
-
if (!inp.witnessUtxo) {
|
|
174
|
-
throw new Error(`Input ${i} is missing witnessUtxo`);
|
|
175
|
-
}
|
|
176
|
-
prevoutScripts.push(inp.witnessUtxo.script);
|
|
177
|
-
prevoutAmounts.push(inp.witnessUtxo.amount);
|
|
178
|
-
}
|
|
179
|
-
// Verify tapScriptSig signatures
|
|
180
|
-
if (!input.tapScriptSig || input.tapScriptSig.length === 0) {
|
|
181
|
-
throw new Error(`Input ${inputIndex} is missing tapScriptSig`);
|
|
182
|
-
}
|
|
183
|
-
// Verify each signature in tapScriptSig
|
|
184
|
-
for (const [tapScriptSigData, signature] of input.tapScriptSig) {
|
|
185
|
-
const pubKey = tapScriptSigData.pubKey;
|
|
186
|
-
const pubKeyHex = base_1.hex.encode(pubKey);
|
|
187
|
-
// Skip verification for excluded pubkeys
|
|
188
|
-
if (excludePubkeys.includes(pubKeyHex)) {
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
// Extract sighash type from signature
|
|
192
|
-
// Schnorr signatures are 64 bytes, with optional 1-byte sighash appended
|
|
193
|
-
const sighashType = signature.length === 65 ? signature[64] : btc_signer_1.SigHash.DEFAULT;
|
|
194
|
-
const sig = signature.subarray(0, 64);
|
|
195
|
-
// Verify sighash type is allowed
|
|
196
|
-
if (!allowedSighashTypes.includes(sighashType)) {
|
|
197
|
-
const sighashName = formatSighash(sighashType);
|
|
198
|
-
throw new Error(`Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`);
|
|
199
|
-
}
|
|
200
|
-
// Find the tapLeafScript that matches this signature's leafHash
|
|
201
|
-
if (!input.tapLeafScript || input.tapLeafScript.length === 0) {
|
|
202
|
-
throw new Error();
|
|
203
|
-
}
|
|
204
|
-
// Search for the leaf that matches the leafHash in tapScriptSigData
|
|
205
|
-
const leafHash = tapScriptSigData.leafHash;
|
|
206
|
-
const leafHashHex = base_1.hex.encode(leafHash);
|
|
207
|
-
let matchingScript;
|
|
208
|
-
let matchingVersion;
|
|
209
|
-
for (const [_, scriptWithVersion] of input.tapLeafScript) {
|
|
210
|
-
const script = scriptWithVersion.subarray(0, -1);
|
|
211
|
-
const version = scriptWithVersion[scriptWithVersion.length - 1];
|
|
212
|
-
// Compute the leaf hash for this script and compare as hex strings
|
|
213
|
-
const computedLeafHash = (0, payment_js_1.tapLeafHash)(script, version);
|
|
214
|
-
const computedHex = base_1.hex.encode(computedLeafHash);
|
|
215
|
-
if (computedHex === leafHashHex) {
|
|
216
|
-
matchingScript = script;
|
|
217
|
-
matchingVersion = version;
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
if (!matchingScript || matchingVersion === undefined) {
|
|
222
|
-
throw new Error(`Input ${inputIndex}: No tapLeafScript found matching leafHash ${base_1.hex.encode(leafHash)}`);
|
|
223
|
-
}
|
|
224
|
-
// Reconstruct the message that was signed
|
|
225
|
-
// Note: preimageWitnessV1 requires ALL input prevout scripts and amounts
|
|
226
|
-
const message = tx.preimageWitnessV1(inputIndex, prevoutScripts, sighashType, prevoutAmounts, undefined, matchingScript, matchingVersion);
|
|
227
|
-
// Verify the schnorr signature
|
|
228
|
-
const isValid = secp256k1_js_1.schnorr.verify(sig, message, pubKey);
|
|
229
|
-
if (!isValid) {
|
|
230
|
-
throw new Error(`Invalid signature for input ${inputIndex}, pubkey ${pubKeyHex}`);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
// Verify we have signatures from all required signers (excluding those we're skipping)
|
|
234
|
-
const signedPubkeys = input.tapScriptSig.map(([data]) => base_1.hex.encode(data.pubKey));
|
|
235
|
-
const requiredNotExcluded = requiredSigners.filter((pk) => !excludePubkeys.includes(pk));
|
|
236
|
-
const missingSigners = requiredNotExcluded.filter((pk) => !signedPubkeys.includes(pk));
|
|
237
|
-
if (missingSigners.length > 0) {
|
|
238
|
-
throw new Error(`Missing signatures from: ${missingSigners.map((pk) => pk.slice(0, 16)).join(", ")}...`);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Merges the signed transaction with the original transaction
|
|
243
|
-
* @param signedTx signed transaction
|
|
244
|
-
* @param originalTx original transaction
|
|
245
|
-
*/
|
|
246
|
-
function combineTapscriptSigs(signedTx, originalTx) {
|
|
247
|
-
for (let i = 0; i < signedTx.inputsLength; i++) {
|
|
248
|
-
const input = originalTx.getInput(i);
|
|
249
|
-
const signedInput = signedTx.getInput(i);
|
|
250
|
-
if (!input.tapScriptSig)
|
|
251
|
-
throw new Error("No tapScriptSig");
|
|
252
|
-
originalTx.updateInput(i, {
|
|
253
|
-
tapScriptSig: input.tapScriptSig?.concat(signedInput.tapScriptSig),
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
return originalTx;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Validates if a given string is a valid Arkade address by attempting to decode it.
|
|
260
|
-
* @param address The Arkade address to validate.
|
|
261
|
-
* @returns True if the address is valid, false otherwise.
|
|
262
|
-
*/
|
|
263
|
-
function isValidArkAddress(address) {
|
|
264
|
-
try {
|
|
265
|
-
address_1.ArkAddress.decode(address);
|
|
266
|
-
return true;
|
|
267
|
-
}
|
|
268
|
-
catch (e) {
|
|
269
|
-
return false;
|
|
270
|
-
}
|
|
271
|
-
}
|
package/dist/cjs/utils/bip21.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BIP21 = exports.BIP21Error = void 0;
|
|
4
|
-
var BIP21Error;
|
|
5
|
-
(function (BIP21Error) {
|
|
6
|
-
BIP21Error["INVALID_URI"] = "Invalid BIP21 URI";
|
|
7
|
-
BIP21Error["INVALID_ADDRESS"] = "Invalid address";
|
|
8
|
-
})(BIP21Error || (exports.BIP21Error = BIP21Error = {}));
|
|
9
|
-
class BIP21 {
|
|
10
|
-
/**
|
|
11
|
-
* Create a BIP21 URI from the provided parameters.
|
|
12
|
-
*
|
|
13
|
-
* @param params - BIP21 parameters to encode
|
|
14
|
-
* @returns Encoded BIP21 URI
|
|
15
|
-
*/
|
|
16
|
-
static create(params) {
|
|
17
|
-
const { address, ...options } = params;
|
|
18
|
-
// Build query string
|
|
19
|
-
const queryParams = {};
|
|
20
|
-
for (const [key, value] of Object.entries(options)) {
|
|
21
|
-
if (value === undefined)
|
|
22
|
-
continue;
|
|
23
|
-
if (key === "amount") {
|
|
24
|
-
if (!isFinite(value)) {
|
|
25
|
-
console.warn("Invalid amount");
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
if (value < 0) {
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
queryParams[key] = value;
|
|
32
|
-
}
|
|
33
|
-
else if (key === "ark") {
|
|
34
|
-
// Validate Arkade address format
|
|
35
|
-
if (typeof value === "string" &&
|
|
36
|
-
(value.startsWith("ark") || value.startsWith("tark"))) {
|
|
37
|
-
queryParams[key] = value;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
console.warn("Invalid ARK address format");
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else if (key === "sp") {
|
|
44
|
-
// Validate Silent Payment address format (placeholder)
|
|
45
|
-
if (typeof value === "string" && value.startsWith("sp")) {
|
|
46
|
-
queryParams[key] = value;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
console.warn("Invalid Silent Payment address format");
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else if (typeof value === "string" || typeof value === "number") {
|
|
53
|
-
queryParams[key] = value;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const query = Object.keys(queryParams).length > 0
|
|
57
|
-
? "?" +
|
|
58
|
-
new URLSearchParams(Object.fromEntries(Object.entries(queryParams).map(([k, v]) => [
|
|
59
|
-
k,
|
|
60
|
-
String(v),
|
|
61
|
-
]))).toString()
|
|
62
|
-
: "";
|
|
63
|
-
return `bitcoin:${address ? address.toLowerCase() : ""}${query}`;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Parse a BIP21 URI and return its decoded parameters.
|
|
67
|
-
*
|
|
68
|
-
* @param uri - BIP21 URI to parse
|
|
69
|
-
* @returns Parsed BIP21 URI data
|
|
70
|
-
* @throws Error if the URI does not start with the `bitcoin:` scheme
|
|
71
|
-
*/
|
|
72
|
-
static parse(uri) {
|
|
73
|
-
if (!uri.toLowerCase().startsWith("bitcoin:")) {
|
|
74
|
-
throw new Error(BIP21Error.INVALID_URI);
|
|
75
|
-
}
|
|
76
|
-
// Remove the `bitcoin:` prefix while preserving the case of the rest.
|
|
77
|
-
const withoutPrefix = uri.slice(uri.toLowerCase().indexOf("bitcoin:") + 8);
|
|
78
|
-
const [address, query] = withoutPrefix.split("?");
|
|
79
|
-
const params = {};
|
|
80
|
-
if (address) {
|
|
81
|
-
params.address = address.toLowerCase();
|
|
82
|
-
}
|
|
83
|
-
if (query) {
|
|
84
|
-
const queryParams = new URLSearchParams(query);
|
|
85
|
-
for (const [key, value] of queryParams.entries()) {
|
|
86
|
-
if (!value)
|
|
87
|
-
continue;
|
|
88
|
-
if (key === "amount") {
|
|
89
|
-
const amount = Number(value);
|
|
90
|
-
if (!isFinite(amount)) {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
if (amount < 0) {
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
params[key] = amount;
|
|
97
|
-
}
|
|
98
|
-
else if (key === "ark") {
|
|
99
|
-
// Validate Arkade address format
|
|
100
|
-
if (value.startsWith("ark") || value.startsWith("tark")) {
|
|
101
|
-
params[key] = value;
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
console.warn("Invalid ARK address format");
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else if (key === "sp") {
|
|
108
|
-
// Validate Silent Payment address format (placeholder)
|
|
109
|
-
if (value.startsWith("sp")) {
|
|
110
|
-
params[key] = value;
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
console.warn("Invalid Silent Payment address format");
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
params[key] = value;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
originalString: uri,
|
|
123
|
-
params,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.BIP21 = BIP21;
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OVERLAP_MS = exports.SAFETY_LAG_MS = void 0;
|
|
4
|
-
exports.updateWalletState = updateWalletState;
|
|
5
|
-
exports.getSyncCursor = getSyncCursor;
|
|
6
|
-
exports.advanceSyncCursor = advanceSyncCursor;
|
|
7
|
-
exports.clearSyncCursor = clearSyncCursor;
|
|
8
|
-
exports.computeSyncWindow = computeSyncWindow;
|
|
9
|
-
exports.cursorCutoff = cursorCutoff;
|
|
10
|
-
/** Lag behind real-time to avoid racing with indexer writes. */
|
|
11
|
-
exports.SAFETY_LAG_MS = 30000;
|
|
12
|
-
/** Overlap window so boundary virtual outputs are never missed. */
|
|
13
|
-
exports.OVERLAP_MS = 24 * 60 * 60 * 1000;
|
|
14
|
-
/**
|
|
15
|
-
* Per-repository mutex that serializes wallet-state mutations so that
|
|
16
|
-
* concurrent read-modify-write cycles never silently overwrite
|
|
17
|
-
* each other's changes.
|
|
18
|
-
*/
|
|
19
|
-
const walletStateLocks = new WeakMap();
|
|
20
|
-
/**
|
|
21
|
-
* Atomically read, mutate, and persist wallet state.
|
|
22
|
-
* All callers that modify wallet state should go through this helper
|
|
23
|
-
* to avoid lost-update races between interleaved async operations.
|
|
24
|
-
*/
|
|
25
|
-
async function updateWalletState(repo, updater) {
|
|
26
|
-
const prev = walletStateLocks.get(repo) ?? Promise.resolve();
|
|
27
|
-
const op = prev.then(async () => {
|
|
28
|
-
const state = (await repo.getWalletState()) ?? {};
|
|
29
|
-
await repo.saveWalletState(updater(state));
|
|
30
|
-
});
|
|
31
|
-
// Store a version that never rejects so the chain doesn't break.
|
|
32
|
-
walletStateLocks.set(repo, op.catch(() => { }));
|
|
33
|
-
return op;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Settings key that gates interpretation of the `lastSyncTime` field.
|
|
37
|
-
*
|
|
38
|
-
* The `lastSyncTime` column existed pre-PR with a different semantic
|
|
39
|
-
* (wall-clock at sync completion, written by the buggy sync loop this
|
|
40
|
-
* PR fixes). On upgrade we cannot trust any pre-existing value, so the
|
|
41
|
-
* cursor is only honoured after the first successful post-upgrade
|
|
42
|
-
* advance writes this marker into the `settings` JSON blob. Reusing
|
|
43
|
-
* `settings` avoids any schema migration.
|
|
44
|
-
*/
|
|
45
|
-
const CURSOR_MIGRATED_KEY = "vtxoCursorMigrated";
|
|
46
|
-
function hasMigrationMarker(state) {
|
|
47
|
-
return state?.settings?.[CURSOR_MIGRATED_KEY] === true;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Read the global high-water mark for VTXO indexer syncs.
|
|
51
|
-
*
|
|
52
|
-
* Returns `0` when:
|
|
53
|
-
* - the wallet has never been synced (bootstrap case), or
|
|
54
|
-
* - the stored `lastSyncTime` was written by pre-PR code and is not
|
|
55
|
-
* safe to reuse under the new semantics (see {@link CURSOR_MIGRATED_KEY}).
|
|
56
|
-
*/
|
|
57
|
-
async function getSyncCursor(repo) {
|
|
58
|
-
const state = await repo.getWalletState();
|
|
59
|
-
if (!hasMigrationMarker(state))
|
|
60
|
-
return 0;
|
|
61
|
-
return state?.lastSyncTime ?? 0;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Advance the global cursor after a successful full-scope delta sync.
|
|
65
|
-
*
|
|
66
|
-
* Clamped with `Math.max` against the current value so concurrent syncs
|
|
67
|
-
* that finish out of order can't rewind the cursor: `lastUpdatedAt` is
|
|
68
|
-
* captured before each sync enters the `updateWalletState` mutex, and
|
|
69
|
-
* the later-started sync would otherwise overwrite the earlier-captured
|
|
70
|
-
* one with a smaller value. The legacy value is discarded on the first
|
|
71
|
-
* advance if the migration marker is absent so pre-PR data doesn't
|
|
72
|
-
* survive the upgrade.
|
|
73
|
-
*/
|
|
74
|
-
async function advanceSyncCursor(repo, lastUpdatedAt) {
|
|
75
|
-
await updateWalletState(repo, (state) => {
|
|
76
|
-
const current = hasMigrationMarker(state)
|
|
77
|
-
? (state.lastSyncTime ?? 0)
|
|
78
|
-
: 0;
|
|
79
|
-
return {
|
|
80
|
-
...state,
|
|
81
|
-
lastSyncTime: Math.max(current, lastUpdatedAt),
|
|
82
|
-
settings: {
|
|
83
|
-
...(state.settings ?? {}),
|
|
84
|
-
[CURSOR_MIGRATED_KEY]: true,
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Remove the sync cursor, forcing a full re-bootstrap on next sync.
|
|
91
|
-
*
|
|
92
|
-
* Also clears the migration marker so any stored `lastSyncTime` is
|
|
93
|
-
* treated as untrusted on the next read.
|
|
94
|
-
*/
|
|
95
|
-
async function clearSyncCursor(repo) {
|
|
96
|
-
await updateWalletState(repo, (state) => {
|
|
97
|
-
const { [CURSOR_MIGRATED_KEY]: _, ...restSettings } = state.settings ?? {};
|
|
98
|
-
return {
|
|
99
|
-
...state,
|
|
100
|
-
lastSyncTime: undefined,
|
|
101
|
-
settings: restSettings,
|
|
102
|
-
};
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Compute the `after` lower-bound for a delta sync query.
|
|
107
|
-
*
|
|
108
|
-
* No upper bound (`before`) is applied to the query so that freshly
|
|
109
|
-
* created virtual outputs are never excluded. The safety lag is applied only
|
|
110
|
-
* when advancing the cursor (see @see cursorCutoff).
|
|
111
|
-
*/
|
|
112
|
-
function computeSyncWindow(cursor) {
|
|
113
|
-
const after = Math.max(0, cursor - exports.OVERLAP_MS);
|
|
114
|
-
return { after };
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* The safe high-water mark for cursor advancement.
|
|
118
|
-
* Lags behind real-time by @see SAFETY_LAG_MS so that virtual outputs still
|
|
119
|
-
* being indexed are re-queried on the next sync.
|
|
120
|
-
*
|
|
121
|
-
* When `requestStartedAt` is provided the cutoff is frozen to the
|
|
122
|
-
* request start rather than wall-clock at commit time, preventing
|
|
123
|
-
* long-running paginated fetches from advancing the cursor past the
|
|
124
|
-
* data they actually observed.
|
|
125
|
-
*/
|
|
126
|
-
function cursorCutoff(requestStartedAt) {
|
|
127
|
-
return (requestStartedAt ?? Date.now()) - exports.SAFETY_LAG_MS;
|
|
128
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.timelockToSequence = timelockToSequence;
|
|
37
|
-
exports.sequenceToTimelock = sequenceToTimelock;
|
|
38
|
-
const bip68 = __importStar(require("bip68"));
|
|
39
|
-
/**
|
|
40
|
-
* Convert RelativeTimelock to BIP68 sequence number.
|
|
41
|
-
*/
|
|
42
|
-
function timelockToSequence(timelock) {
|
|
43
|
-
return bip68.encode(timelock.type === "blocks"
|
|
44
|
-
? { blocks: Number(timelock.value) }
|
|
45
|
-
: { seconds: Number(timelock.value) });
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Convert BIP68 sequence number back to RelativeTimelock.
|
|
49
|
-
*/
|
|
50
|
-
function sequenceToTimelock(sequence) {
|
|
51
|
-
const decoded = bip68.decode(sequence);
|
|
52
|
-
if ("blocks" in decoded && decoded.blocks !== undefined) {
|
|
53
|
-
return { type: "blocks", value: BigInt(decoded.blocks) };
|
|
54
|
-
}
|
|
55
|
-
if ("seconds" in decoded && decoded.seconds !== undefined) {
|
|
56
|
-
return { type: "seconds", value: BigInt(decoded.seconds) };
|
|
57
|
-
}
|
|
58
|
-
throw new Error(`Invalid BIP68 sequence: ${sequence}`);
|
|
59
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Transaction = void 0;
|
|
4
|
-
const btc_signer_1 = require("@scure/btc-signer");
|
|
5
|
-
/**
|
|
6
|
-
* Transaction is a wrapper around the @scure/btc-signer Transaction class.
|
|
7
|
-
* It adds the Arkade protocol specific options to the transaction.
|
|
8
|
-
*/
|
|
9
|
-
class Transaction extends btc_signer_1.Transaction {
|
|
10
|
-
constructor(opts) {
|
|
11
|
-
super(withArkOpts(opts));
|
|
12
|
-
}
|
|
13
|
-
static fromPSBT(psbt_, opts) {
|
|
14
|
-
return btc_signer_1.Transaction.fromPSBT(psbt_, withArkOpts(opts));
|
|
15
|
-
}
|
|
16
|
-
static fromRaw(raw, opts) {
|
|
17
|
-
return btc_signer_1.Transaction.fromRaw(raw, withArkOpts(opts));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.Transaction = Transaction;
|
|
21
|
-
Transaction.ARK_TX_OPTS = {
|
|
22
|
-
allowUnknown: true,
|
|
23
|
-
allowUnknownOutputs: true,
|
|
24
|
-
allowUnknownInputs: true,
|
|
25
|
-
};
|
|
26
|
-
function withArkOpts(opts) {
|
|
27
|
-
return { ...Transaction.ARK_TX_OPTS, ...opts };
|
|
28
|
-
}
|