@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,99 +0,0 @@
|
|
|
1
|
-
export class BufferWriter {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.buffer = [];
|
|
4
|
-
}
|
|
5
|
-
write(data) {
|
|
6
|
-
for (const byte of data) {
|
|
7
|
-
this.buffer.push(byte);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
writeByte(byte) {
|
|
11
|
-
this.buffer.push(byte & 0xff);
|
|
12
|
-
}
|
|
13
|
-
writeUint16LE(value) {
|
|
14
|
-
const buf = new Uint8Array(2);
|
|
15
|
-
new DataView(buf.buffer).setUint16(0, value, true); // true = little endian
|
|
16
|
-
this.write(buf);
|
|
17
|
-
}
|
|
18
|
-
writeVarUint(value) {
|
|
19
|
-
if (typeof value === "number") {
|
|
20
|
-
if (!Number.isInteger(value) || value < 0) {
|
|
21
|
-
throw new RangeError("writeVarUint: value must be a non-negative integer");
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
else if (value < 0n) {
|
|
25
|
-
throw new RangeError("writeVarUint: value must be a non-negative integer");
|
|
26
|
-
}
|
|
27
|
-
const val = typeof value === "number" ? BigInt(value) : value;
|
|
28
|
-
const bytes = [];
|
|
29
|
-
let remaining = val;
|
|
30
|
-
do {
|
|
31
|
-
let byte = Number(remaining & 0x7fn);
|
|
32
|
-
remaining >>= 7n;
|
|
33
|
-
if (remaining > 0n) {
|
|
34
|
-
byte |= 0x80;
|
|
35
|
-
}
|
|
36
|
-
bytes.push(byte);
|
|
37
|
-
} while (remaining > 0n);
|
|
38
|
-
this.write(new Uint8Array(bytes));
|
|
39
|
-
}
|
|
40
|
-
writeVarSlice(data) {
|
|
41
|
-
this.writeVarUint(data.length);
|
|
42
|
-
this.write(data);
|
|
43
|
-
}
|
|
44
|
-
toBytes() {
|
|
45
|
-
return new Uint8Array(this.buffer);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
export class BufferReader {
|
|
49
|
-
constructor(data) {
|
|
50
|
-
this.offset = 0;
|
|
51
|
-
this.view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
52
|
-
}
|
|
53
|
-
remaining() {
|
|
54
|
-
return this.view.byteLength - this.offset;
|
|
55
|
-
}
|
|
56
|
-
readByte() {
|
|
57
|
-
if (this.offset >= this.view.byteLength) {
|
|
58
|
-
throw new Error("unexpected end of buffer");
|
|
59
|
-
}
|
|
60
|
-
return this.view.getUint8(this.offset++);
|
|
61
|
-
}
|
|
62
|
-
readSlice(size) {
|
|
63
|
-
if (this.offset + size > this.view.byteLength) {
|
|
64
|
-
throw new Error("unexpected end of buffer");
|
|
65
|
-
}
|
|
66
|
-
const result = new Uint8Array(this.view.buffer, this.view.byteOffset + this.offset, size);
|
|
67
|
-
this.offset += size;
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
readUint16LE() {
|
|
71
|
-
if (this.offset + 2 > this.view.byteLength) {
|
|
72
|
-
throw new Error("unexpected end of buffer");
|
|
73
|
-
}
|
|
74
|
-
const value = this.view.getUint16(this.offset, true);
|
|
75
|
-
this.offset += 2;
|
|
76
|
-
return value;
|
|
77
|
-
}
|
|
78
|
-
readVarUint() {
|
|
79
|
-
let result = 0n;
|
|
80
|
-
let shift = 0n;
|
|
81
|
-
let byte;
|
|
82
|
-
do {
|
|
83
|
-
if (this.offset >= this.view.byteLength) {
|
|
84
|
-
throw new Error("unexpected end of buffer");
|
|
85
|
-
}
|
|
86
|
-
byte = this.view.getUint8(this.offset++);
|
|
87
|
-
result |= BigInt(byte & 0x7f) << shift;
|
|
88
|
-
shift += 7n;
|
|
89
|
-
} while (byte & 0x80);
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
readVarSlice() {
|
|
93
|
-
const length = Number(this.readVarUint());
|
|
94
|
-
return this.readSlice(length);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
export function isZeroBytes(bytes) {
|
|
98
|
-
return bytes.every((byte) => byte === 0);
|
|
99
|
-
}
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import { hex } from "@scure/base";
|
|
2
|
-
import { Script } from "@scure/btc-signer";
|
|
3
|
-
import { equalBytes } from "@scure/btc-signer/utils.js";
|
|
4
|
-
import { Packet } from "./asset/packet.js";
|
|
5
|
-
import { BufferReader } from "./asset/utils.js";
|
|
6
|
-
import { UnknownPacket } from "./packet.js";
|
|
7
|
-
export { UnknownPacket } from "./packet.js";
|
|
8
|
-
/**
|
|
9
|
-
* ArkadeMagic is the 3-byte magic prefix ("ARK") that identifies an OP_RETURN
|
|
10
|
-
* output as an Arkade extension blob.
|
|
11
|
-
*/
|
|
12
|
-
export const ARKADE_MAGIC = new Uint8Array([0x41, 0x52, 0x4b]); // "ARK"
|
|
13
|
-
/**
|
|
14
|
-
* ErrExtensionNotFound is thrown when no extension output is found in a transaction.
|
|
15
|
-
*/
|
|
16
|
-
export class ExtensionNotFoundError extends Error {
|
|
17
|
-
constructor() {
|
|
18
|
-
super("no extension output found in transaction");
|
|
19
|
-
this.name = "ExtensionNotFoundError";
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Extension is a set of typed packets encoded in an OP_RETURN output.
|
|
24
|
-
*
|
|
25
|
-
* Wire format:
|
|
26
|
-
* OP_RETURN | <push> | ARK(3B) | [type(1B) | varint_len | data]...
|
|
27
|
-
*/
|
|
28
|
-
export class Extension {
|
|
29
|
-
constructor(packets) {
|
|
30
|
-
this.packets = packets;
|
|
31
|
-
}
|
|
32
|
-
static create(packets) {
|
|
33
|
-
if (packets.length === 0) {
|
|
34
|
-
throw new Error("missing packets");
|
|
35
|
-
}
|
|
36
|
-
const seen = new Set();
|
|
37
|
-
for (const p of packets) {
|
|
38
|
-
if (seen.has(p.type())) {
|
|
39
|
-
throw new Error(`duplicate packet type ${p.type()}`);
|
|
40
|
-
}
|
|
41
|
-
seen.add(p.type());
|
|
42
|
-
}
|
|
43
|
-
return new Extension(packets);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* isExtension returns true if the script is an OP_RETURN whose push data
|
|
47
|
-
* begins with the ARK magic bytes.
|
|
48
|
-
*/
|
|
49
|
-
static isExtension(script) {
|
|
50
|
-
try {
|
|
51
|
-
const decoded = Script.decode(script);
|
|
52
|
-
if (decoded.length < 2 || decoded[0] !== "RETURN")
|
|
53
|
-
return false;
|
|
54
|
-
const data = decoded[1];
|
|
55
|
-
if (!(data instanceof Uint8Array))
|
|
56
|
-
return false;
|
|
57
|
-
return (data.length >= ARKADE_MAGIC.length &&
|
|
58
|
-
equalBytes(data.slice(0, ARKADE_MAGIC.length), ARKADE_MAGIC));
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* fromBytes parses an Extension from a raw OP_RETURN script.
|
|
66
|
-
*/
|
|
67
|
-
static fromBytes(script) {
|
|
68
|
-
if (!script || script.length === 0) {
|
|
69
|
-
throw new Error("missing OP_RETURN");
|
|
70
|
-
}
|
|
71
|
-
let decoded;
|
|
72
|
-
try {
|
|
73
|
-
decoded = Script.decode(script);
|
|
74
|
-
}
|
|
75
|
-
catch {
|
|
76
|
-
throw new Error("expected OP_RETURN");
|
|
77
|
-
}
|
|
78
|
-
if (decoded.length === 0 || decoded[0] !== "RETURN") {
|
|
79
|
-
throw new Error("expected OP_RETURN");
|
|
80
|
-
}
|
|
81
|
-
const dataPushes = decoded
|
|
82
|
-
.slice(1)
|
|
83
|
-
.filter((x) => x instanceof Uint8Array);
|
|
84
|
-
if (dataPushes.length === 0) {
|
|
85
|
-
throw new Error("missing magic prefix: EOF");
|
|
86
|
-
}
|
|
87
|
-
// Concatenate all data pushes (handles OP_PUSHDATA1/2/4)
|
|
88
|
-
const payload = new Uint8Array(dataPushes.reduce((acc, d) => acc + d.length, 0));
|
|
89
|
-
let offset = 0;
|
|
90
|
-
for (const d of dataPushes) {
|
|
91
|
-
payload.set(d, offset);
|
|
92
|
-
offset += d.length;
|
|
93
|
-
}
|
|
94
|
-
// Check ARK magic
|
|
95
|
-
if (payload.length < ARKADE_MAGIC.length ||
|
|
96
|
-
!equalBytes(payload.slice(0, ARKADE_MAGIC.length), ARKADE_MAGIC)) {
|
|
97
|
-
throw new Error(`expected magic prefix ${hex.encode(ARKADE_MAGIC)}, got ${hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`);
|
|
98
|
-
}
|
|
99
|
-
// Parse TLV records
|
|
100
|
-
const reader = new BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
101
|
-
const packets = [];
|
|
102
|
-
while (reader.remaining() > 0) {
|
|
103
|
-
const packetType = reader.readByte();
|
|
104
|
-
let data;
|
|
105
|
-
try {
|
|
106
|
-
data = reader.readVarSlice();
|
|
107
|
-
}
|
|
108
|
-
catch {
|
|
109
|
-
throw new Error("missing packet data");
|
|
110
|
-
}
|
|
111
|
-
packets.push(parsePacket(packetType, data));
|
|
112
|
-
}
|
|
113
|
-
if (packets.length === 0) {
|
|
114
|
-
throw new Error("missing packets");
|
|
115
|
-
}
|
|
116
|
-
// Reject duplicate packet types
|
|
117
|
-
const seen = new Set();
|
|
118
|
-
for (const p of packets) {
|
|
119
|
-
if (seen.has(p.type())) {
|
|
120
|
-
throw new Error(`duplicate packet type ${p.type()}`);
|
|
121
|
-
}
|
|
122
|
-
seen.add(p.type());
|
|
123
|
-
}
|
|
124
|
-
return new Extension(packets);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* fromTx searches the transaction outputs for an extension blob and parses it.
|
|
128
|
-
* Throws ExtensionNotFoundError if none is found.
|
|
129
|
-
*/
|
|
130
|
-
static fromTx(tx) {
|
|
131
|
-
for (let i = 0; i < tx.outputsLength; i++) {
|
|
132
|
-
const output = tx.getOutput(i);
|
|
133
|
-
if (!output?.script)
|
|
134
|
-
continue;
|
|
135
|
-
if (Extension.isExtension(output.script)) {
|
|
136
|
-
return Extension.fromBytes(output.script);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
throw new ExtensionNotFoundError();
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* serialize encodes the extension as an OP_RETURN script.
|
|
143
|
-
*
|
|
144
|
-
* Layout: OP_RETURN | <push> | ARK | [type | varint_len | data]...
|
|
145
|
-
*/
|
|
146
|
-
serialize() {
|
|
147
|
-
// Build payload: ARK magic + TLV records
|
|
148
|
-
const parts = [ARKADE_MAGIC];
|
|
149
|
-
for (const p of this.packets) {
|
|
150
|
-
const data = p.serialize();
|
|
151
|
-
// type (1 byte)
|
|
152
|
-
const typeByte = new Uint8Array([p.type()]);
|
|
153
|
-
// varint length prefix + data
|
|
154
|
-
const lengthBuf = encodeVarUint(data.length);
|
|
155
|
-
parts.push(typeByte, lengthBuf, data);
|
|
156
|
-
}
|
|
157
|
-
const totalLen = parts.reduce((acc, p) => acc + p.length, 0);
|
|
158
|
-
const payload = new Uint8Array(totalLen);
|
|
159
|
-
let off = 0;
|
|
160
|
-
for (const p of parts) {
|
|
161
|
-
payload.set(p, off);
|
|
162
|
-
off += p.length;
|
|
163
|
-
}
|
|
164
|
-
return buildOpReturnScript(payload);
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* txOut returns the extension as a zero-value OP_RETURN transaction output.
|
|
168
|
-
*/
|
|
169
|
-
txOut() {
|
|
170
|
-
return {
|
|
171
|
-
script: this.serialize(),
|
|
172
|
-
amount: 0n,
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* getAssetPacket returns the embedded Packet, or null if not present.
|
|
177
|
-
*/
|
|
178
|
-
getAssetPacket() {
|
|
179
|
-
for (const p of this.packets) {
|
|
180
|
-
if (p instanceof Packet) {
|
|
181
|
-
return p;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* parsePacket dispatches to a known packet type or falls back to UnknownPacket.
|
|
189
|
-
*/
|
|
190
|
-
function parsePacket(packetType, data) {
|
|
191
|
-
if (packetType === Packet.PACKET_TYPE) {
|
|
192
|
-
return Packet.fromBytes(data);
|
|
193
|
-
}
|
|
194
|
-
return new UnknownPacket(packetType, data);
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* encodeVarUint encodes a non-negative integer as a LEB128 unsigned varint.
|
|
198
|
-
*/
|
|
199
|
-
function encodeVarUint(value) {
|
|
200
|
-
const bytes = [];
|
|
201
|
-
let remaining = value;
|
|
202
|
-
do {
|
|
203
|
-
let byte = remaining & 0x7f;
|
|
204
|
-
remaining >>>= 7;
|
|
205
|
-
if (remaining > 0)
|
|
206
|
-
byte |= 0x80;
|
|
207
|
-
bytes.push(byte);
|
|
208
|
-
} while (remaining > 0);
|
|
209
|
-
return new Uint8Array(bytes);
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* buildOpReturnScript builds an OP_RETURN script with an arbitrary-length data push.
|
|
213
|
-
* Manually constructed to avoid the 520-byte cap in some script builders.
|
|
214
|
-
*
|
|
215
|
-
* Opcodes: 0x6a=OP_RETURN, 0x4c=OP_PUSHDATA1, 0x4d=OP_PUSHDATA2, 0x4e=OP_PUSHDATA4
|
|
216
|
-
*/
|
|
217
|
-
function buildOpReturnScript(data) {
|
|
218
|
-
const n = data.length;
|
|
219
|
-
let script;
|
|
220
|
-
if (n <= 75) {
|
|
221
|
-
script = new Uint8Array(2 + n);
|
|
222
|
-
script[0] = 0x6a; // OP_RETURN
|
|
223
|
-
script[1] = n;
|
|
224
|
-
script.set(data, 2);
|
|
225
|
-
}
|
|
226
|
-
else if (n <= 255) {
|
|
227
|
-
script = new Uint8Array(3 + n);
|
|
228
|
-
script[0] = 0x6a;
|
|
229
|
-
script[1] = 0x4c; // OP_PUSHDATA1
|
|
230
|
-
script[2] = n;
|
|
231
|
-
script.set(data, 3);
|
|
232
|
-
}
|
|
233
|
-
else if (n <= 65535) {
|
|
234
|
-
script = new Uint8Array(4 + n);
|
|
235
|
-
script[0] = 0x6a;
|
|
236
|
-
script[1] = 0x4d; // OP_PUSHDATA2
|
|
237
|
-
new DataView(script.buffer).setUint16(2, n, true);
|
|
238
|
-
script.set(data, 4);
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
script = new Uint8Array(6 + n);
|
|
242
|
-
script[0] = 0x6a;
|
|
243
|
-
script[1] = 0x4e; // OP_PUSHDATA4
|
|
244
|
-
new DataView(script.buffer).setUint32(2, n, true);
|
|
245
|
-
script.set(data, 6);
|
|
246
|
-
}
|
|
247
|
-
return script;
|
|
248
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UnknownPacket holds a packet whose type is not recognized by this implementation.
|
|
3
|
-
* It round-trips opaquely: the raw bytes are preserved as-is.
|
|
4
|
-
*/
|
|
5
|
-
export class UnknownPacket {
|
|
6
|
-
constructor(packetType, data) {
|
|
7
|
-
this.packetType = packetType;
|
|
8
|
-
this.data = data;
|
|
9
|
-
}
|
|
10
|
-
type() {
|
|
11
|
-
return this.packetType;
|
|
12
|
-
}
|
|
13
|
-
serialize() {
|
|
14
|
-
return this.data;
|
|
15
|
-
}
|
|
16
|
-
}
|
package/dist/esm/forfeit.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Transaction } from "./utils/transaction.js";
|
|
2
|
-
import { P2A } from "./utils/anchor.js";
|
|
3
|
-
/**
|
|
4
|
-
* Build a forfeit transaction that spends the provided inputs to a single forfeit output.
|
|
5
|
-
*
|
|
6
|
-
* @param inputs - Inputs to include in the forfeit transaction
|
|
7
|
-
* @param forfeitPkScript - ScriptPubKey for the forfeit output
|
|
8
|
-
* @param txLocktime - Optional locktime to apply to the transaction
|
|
9
|
-
*/
|
|
10
|
-
export function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
11
|
-
let amount = 0n;
|
|
12
|
-
for (const input of inputs) {
|
|
13
|
-
if (!input.witnessUtxo) {
|
|
14
|
-
throw new Error("input needs witness utxo");
|
|
15
|
-
}
|
|
16
|
-
amount += input.witnessUtxo.amount;
|
|
17
|
-
}
|
|
18
|
-
return buildForfeitTxWithOutput(inputs, {
|
|
19
|
-
script: forfeitPkScript,
|
|
20
|
-
amount,
|
|
21
|
-
}, txLocktime);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Build a forfeit transaction using an explicit output descriptor (used for delegated renewals)
|
|
25
|
-
*
|
|
26
|
-
* @param inputs - Inputs to include in the forfeit transaction
|
|
27
|
-
* @param output - Primary transaction output
|
|
28
|
-
* @param txLocktime - Optional locktime to apply to the transaction
|
|
29
|
-
*/
|
|
30
|
-
export function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
31
|
-
const tx = new Transaction({
|
|
32
|
-
version: 3,
|
|
33
|
-
lockTime: txLocktime,
|
|
34
|
-
});
|
|
35
|
-
for (const input of inputs) {
|
|
36
|
-
tx.addInput(input);
|
|
37
|
-
}
|
|
38
|
-
tx.addOutput(output);
|
|
39
|
-
tx.addOutput(P2A);
|
|
40
|
-
return tx;
|
|
41
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { expand, networks } from "@bitcoinerlab/descriptors-scure";
|
|
2
|
-
import { hex } from "@scure/base";
|
|
3
|
-
/**
|
|
4
|
-
* True iff `descriptor` is a Bitcoin mainnet descriptor (xpub-prefixed
|
|
5
|
-
* BIP32 key).
|
|
6
|
-
*
|
|
7
|
-
* Note: testnet, signet, regtest, mutinynet, and other non-mainnet
|
|
8
|
-
* networks all share the same `tpub` BIP32 version bytes — they cannot
|
|
9
|
-
* be distinguished from one another at the descriptor level. Callers
|
|
10
|
-
* that need a `Network` constants object for `expand()` pick
|
|
11
|
-
* `networks.bitcoin` vs `networks.testnet` themselves; callers that
|
|
12
|
-
* need the *actual* network the wallet is on must track that
|
|
13
|
-
* out-of-band.
|
|
14
|
-
*/
|
|
15
|
-
export function isMainnetDescriptor(descriptor) {
|
|
16
|
-
return !descriptor.includes("tpub");
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Shared "does `candidate` belong to the identity backed by
|
|
20
|
-
* `ourDescriptor`?" predicate.
|
|
21
|
-
*
|
|
22
|
-
* - HD descriptors (expanding to a `bip32` key) match by account xpub
|
|
23
|
-
* on both sides — index-agnostic, so a wildcard template and any
|
|
24
|
-
* concrete index under it all collapse to the same xpub.
|
|
25
|
-
* - Bare `tr(pubkey)` candidates fall back to comparing the candidate
|
|
26
|
-
* pubkey against `ourXOnlyPubkey` (the cached pubkey on the identity
|
|
27
|
-
* side, since pulling it from `ourDescriptor` would require an index
|
|
28
|
-
* substitution the caller already performed).
|
|
29
|
-
*/
|
|
30
|
-
export function descriptorIsOurs(candidate, ourDescriptor, ourXOnlyPubkey) {
|
|
31
|
-
if (!isDescriptor(candidate))
|
|
32
|
-
return false;
|
|
33
|
-
try {
|
|
34
|
-
const candidateInfo = expand({
|
|
35
|
-
descriptor: candidate,
|
|
36
|
-
network: isMainnetDescriptor(candidate)
|
|
37
|
-
? networks.bitcoin
|
|
38
|
-
: networks.testnet,
|
|
39
|
-
}).expansionMap?.["@0"];
|
|
40
|
-
if (!candidateInfo)
|
|
41
|
-
return false;
|
|
42
|
-
if (candidateInfo.bip32) {
|
|
43
|
-
const ourBip32 = expand({
|
|
44
|
-
descriptor: ourDescriptor,
|
|
45
|
-
network: isMainnetDescriptor(ourDescriptor)
|
|
46
|
-
? networks.bitcoin
|
|
47
|
-
: networks.testnet,
|
|
48
|
-
}).expansionMap?.["@0"]?.bip32;
|
|
49
|
-
if (!ourBip32)
|
|
50
|
-
return false;
|
|
51
|
-
return ourBip32.toBase58() === candidateInfo.bip32.toBase58();
|
|
52
|
-
}
|
|
53
|
-
if (candidateInfo.pubkey) {
|
|
54
|
-
// For tr() the library hands back a 32-byte x-only key, but
|
|
55
|
-
// strip a leading parity byte defensively so a 33-byte
|
|
56
|
-
// compressed key (mismatched length) doesn't silently
|
|
57
|
-
// false-negative against our 32-byte x-only side.
|
|
58
|
-
const candidatePub = candidateInfo.pubkey.length === 33
|
|
59
|
-
? candidateInfo.pubkey.subarray(1)
|
|
60
|
-
: candidateInfo.pubkey;
|
|
61
|
-
if (candidatePub.length !== ourXOnlyPubkey.length)
|
|
62
|
-
return false;
|
|
63
|
-
return hex.encode(candidatePub) === hex.encode(ourXOnlyPubkey);
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Check if a string is a descriptor of the shape `tr(...)`.
|
|
73
|
-
*
|
|
74
|
-
* This is a shape check only — it does not validate the inner key material.
|
|
75
|
-
* Use {@link expand} (via {@link extractPubKey} / {@link parseHDDescriptor})
|
|
76
|
-
* for full parsing. The guard rejects empty bodies and missing/trailing
|
|
77
|
-
* parentheses so callers can safely branch on descriptor vs. raw pubkey.
|
|
78
|
-
*/
|
|
79
|
-
export function isDescriptor(value) {
|
|
80
|
-
if (typeof value !== "string")
|
|
81
|
-
return false;
|
|
82
|
-
if (!value.startsWith("tr(") || !value.endsWith(")"))
|
|
83
|
-
return false;
|
|
84
|
-
// body length > 0 after stripping "tr(" and ")"
|
|
85
|
-
return value.length > "tr()".length;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Normalize a value to descriptor format.
|
|
89
|
-
* If already a descriptor, return as-is. If hex pubkey, wrap as tr(pubkey).
|
|
90
|
-
* Throws when the value is empty or not a string so we never produce
|
|
91
|
-
* malformed descriptors like `tr()` that downstream parsers would reject.
|
|
92
|
-
*/
|
|
93
|
-
export function normalizeToDescriptor(value) {
|
|
94
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
95
|
-
throw new Error("normalizeToDescriptor: expected a non-empty string value");
|
|
96
|
-
}
|
|
97
|
-
if (isDescriptor(value)) {
|
|
98
|
-
return value;
|
|
99
|
-
}
|
|
100
|
-
return `tr(${value})`;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Extract the public key from a simple descriptor.
|
|
104
|
-
* For simple descriptors (tr(pubkey)), extracts the pubkey using the library.
|
|
105
|
-
* For HD descriptors, throws — use DescriptorProvider to derive the key.
|
|
106
|
-
*/
|
|
107
|
-
export function extractPubKey(descriptor) {
|
|
108
|
-
if (!isDescriptor(descriptor)) {
|
|
109
|
-
return descriptor;
|
|
110
|
-
}
|
|
111
|
-
const network = isMainnetDescriptor(descriptor)
|
|
112
|
-
? networks.bitcoin
|
|
113
|
-
: networks.testnet;
|
|
114
|
-
const expansion = expand({ descriptor, network });
|
|
115
|
-
if (!expansion.expansionMap) {
|
|
116
|
-
throw new Error("Cannot extract pubkey from descriptor: expansion failed.");
|
|
117
|
-
}
|
|
118
|
-
const key = expansion.expansionMap["@0"];
|
|
119
|
-
// HD descriptors (have a bip32 key) require DescriptorProvider for derivation
|
|
120
|
-
if (key?.bip32) {
|
|
121
|
-
throw new Error("Cannot extract pubkey from HD descriptor without derivation. " +
|
|
122
|
-
"Use DescriptorProvider to derive the key from the xpub.");
|
|
123
|
-
}
|
|
124
|
-
if (!key?.pubkey) {
|
|
125
|
-
throw new Error("Cannot extract pubkey from descriptor: no key found.");
|
|
126
|
-
}
|
|
127
|
-
return hex.encode(key.pubkey);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Parse an HD descriptor into its components.
|
|
131
|
-
* HD descriptors have the format: tr([fingerprint/path']xpub/derivation)
|
|
132
|
-
* Returns null if the descriptor is not in HD format.
|
|
133
|
-
*/
|
|
134
|
-
export function parseHDDescriptor(descriptor) {
|
|
135
|
-
if (!isDescriptor(descriptor)) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
let expansion;
|
|
139
|
-
try {
|
|
140
|
-
const network = isMainnetDescriptor(descriptor)
|
|
141
|
-
? networks.bitcoin
|
|
142
|
-
: networks.testnet;
|
|
143
|
-
expansion = expand({ descriptor, network });
|
|
144
|
-
}
|
|
145
|
-
catch {
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
const key = expansion.expansionMap?.["@0"];
|
|
149
|
-
if (!key?.masterFingerprint ||
|
|
150
|
-
!key.originPath ||
|
|
151
|
-
!key.keyPath ||
|
|
152
|
-
!key.bip32) {
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
return {
|
|
156
|
-
fingerprint: hex.encode(key.masterFingerprint),
|
|
157
|
-
basePath: key.originPath.replace(/^\//, ""),
|
|
158
|
-
xpub: key.bip32.toBase58(),
|
|
159
|
-
derivationPath: key.keyPath.replace(/^\//, ""),
|
|
160
|
-
};
|
|
161
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structural type guard for {@link HDCapableIdentity}. Returns `true`
|
|
3
|
-
* when the value exposes the four members the HD wallet flow relies on:
|
|
4
|
-
* `descriptor`, `isOurs`, `signWithDescriptor`, and
|
|
5
|
-
* `signMessageWithDescriptor`. Used by callers that need to opt into
|
|
6
|
-
* the HD path (e.g. installing an `HDDescriptorProvider`) without
|
|
7
|
-
* coupling to a concrete identity class.
|
|
8
|
-
*/
|
|
9
|
-
export function isHDCapableIdentity(value) {
|
|
10
|
-
if (typeof value !== "object" || value === null)
|
|
11
|
-
return false;
|
|
12
|
-
const v = value;
|
|
13
|
-
return (typeof v.descriptor === "string" &&
|
|
14
|
-
typeof v.isOurs === "function" &&
|
|
15
|
-
typeof v.signWithDescriptor === "function" &&
|
|
16
|
-
typeof v.signMessageWithDescriptor === "function");
|
|
17
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** Type guard for identities that support batch signing. */
|
|
2
|
-
export function isBatchSignable(identity) {
|
|
3
|
-
return ("signMultiple" in identity &&
|
|
4
|
-
typeof identity.signMultiple === "function");
|
|
5
|
-
}
|
|
6
|
-
export * from "./singleKey.js";
|
|
7
|
-
export { SeedIdentity, MnemonicIdentity, ReadonlyDescriptorIdentity, } from "./seedIdentity.js";
|
|
8
|
-
export * from "./serialize.js";
|
|
9
|
-
// Descriptor utilities
|
|
10
|
-
export { isDescriptor, normalizeToDescriptor, extractPubKey, parseHDDescriptor, } from "./descriptor.js";
|
|
11
|
-
export { isHDCapableIdentity } from "./hdCapableIdentity.js";
|
|
12
|
-
// Static descriptor provider (wrapper for legacy Identity)
|
|
13
|
-
export { StaticDescriptorProvider } from "./staticDescriptorProvider.js";
|