@arkade-os/sdk 0.4.27 → 0.4.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -100
- package/dist/adapters/asyncStorage.cjs +48 -0
- package/dist/adapters/asyncStorage.cjs.map +1 -0
- package/dist/adapters/asyncStorage.d.cts +16 -0
- package/dist/{types/storage → adapters}/asyncStorage.d.ts +5 -2
- package/dist/adapters/asyncStorage.js +46 -0
- package/dist/adapters/asyncStorage.js.map +1 -0
- package/dist/adapters/expo.cjs +19 -0
- package/dist/adapters/expo.cjs.map +1 -0
- package/dist/adapters/expo.d.cts +48 -0
- package/dist/adapters/expo.d.ts +48 -0
- package/dist/adapters/expo.js +6 -0
- package/dist/adapters/expo.js.map +1 -0
- package/dist/adapters/fileSystem.cjs +116 -0
- package/dist/adapters/fileSystem.cjs.map +1 -0
- package/dist/adapters/fileSystem.d.cts +17 -0
- package/dist/{types/storage → adapters}/fileSystem.d.ts +5 -2
- package/dist/adapters/fileSystem.js +93 -0
- package/dist/adapters/fileSystem.js.map +1 -0
- package/dist/adapters/indexedDB.cjs +103 -0
- package/dist/adapters/indexedDB.cjs.map +1 -0
- package/dist/adapters/indexedDB.d.cts +18 -0
- package/dist/{types/storage → adapters}/indexedDB.d.ts +5 -2
- package/dist/adapters/indexedDB.js +101 -0
- package/dist/adapters/indexedDB.js.map +1 -0
- package/dist/adapters/localStorage.cjs +50 -0
- package/dist/adapters/localStorage.cjs.map +1 -0
- package/dist/{types/storage/inMemory.d.ts → adapters/localStorage.d.cts} +6 -3
- package/dist/{types/storage → adapters}/localStorage.d.ts +5 -2
- package/dist/adapters/localStorage.js +48 -0
- package/dist/adapters/localStorage.js.map +1 -0
- package/dist/ark-TZ1gXAXU.d.cts +3880 -0
- package/dist/ark-TZ1gXAXU.d.ts +3880 -0
- package/dist/{types/worker/expo/asyncStorageTaskQueue.d.ts → asyncStorageTaskQueue-Cb1F_Z9s.d.ts} +6 -3
- package/dist/asyncStorageTaskQueue-EFqSmYTg.d.cts +49 -0
- package/dist/chunk-5BLDMQED.cjs +18 -0
- package/dist/chunk-5BLDMQED.cjs.map +1 -0
- package/dist/chunk-5PG7DV7A.cjs +805 -0
- package/dist/chunk-5PG7DV7A.cjs.map +1 -0
- package/dist/chunk-A3EMF7RN.js +95 -0
- package/dist/chunk-A3EMF7RN.js.map +1 -0
- package/dist/chunk-ADV27S4N.cjs +2701 -0
- package/dist/chunk-ADV27S4N.cjs.map +1 -0
- package/dist/chunk-BQLHADL7.js +13805 -0
- package/dist/chunk-BQLHADL7.js.map +1 -0
- package/dist/chunk-CFZMTDWI.js +209 -0
- package/dist/chunk-CFZMTDWI.js.map +1 -0
- package/dist/chunk-FG5ACJJW.cjs +212 -0
- package/dist/chunk-FG5ACJJW.cjs.map +1 -0
- package/dist/chunk-HW3JJ323.js +768 -0
- package/dist/chunk-HW3JJ323.js.map +1 -0
- package/dist/chunk-I3DGUUCT.cjs +838 -0
- package/dist/chunk-I3DGUUCT.cjs.map +1 -0
- package/dist/chunk-IPX2R7FR.cjs +100 -0
- package/dist/chunk-IPX2R7FR.cjs.map +1 -0
- package/dist/chunk-NSBPE2FW.js +15 -0
- package/dist/chunk-NSBPE2FW.js.map +1 -0
- package/dist/chunk-T64LAI7L.js +829 -0
- package/dist/chunk-T64LAI7L.js.map +1 -0
- package/dist/chunk-ZBUDLTBO.js +2671 -0
- package/dist/chunk-ZBUDLTBO.js.map +1 -0
- package/dist/chunk-ZLO6NETT.cjs +13910 -0
- package/dist/chunk-ZLO6NETT.cjs.map +1 -0
- package/dist/contracts/handlers/index.cjs +26 -0
- package/dist/contracts/handlers/index.cjs.map +1 -0
- package/dist/contracts/handlers/index.d.cts +7 -0
- package/dist/contracts/handlers/index.d.ts +7 -0
- package/dist/contracts/handlers/index.js +5 -0
- package/dist/contracts/handlers/index.js.map +1 -0
- package/dist/delegate-BFZs69hp.d.cts +84 -0
- package/dist/delegate-aaVGfWsV.d.ts +84 -0
- package/dist/index-B22cA64m.d.cts +199 -0
- package/dist/{types/storage/index.d.ts → index-C0IanN1m.d.cts} +3 -1
- package/dist/index-C0IanN1m.d.ts +11 -0
- package/dist/index-NDla_UoJ.d.ts +199 -0
- package/dist/index.cjs +480 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3343 -0
- package/dist/index.d.ts +3343 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/repositories/realm/index.cjs +513 -0
- package/dist/repositories/realm/index.cjs.map +1 -0
- package/dist/repositories/realm/index.d.cts +217 -0
- package/dist/{types/repositories/realm/schemas.d.ts → repositories/realm/index.d.ts} +80 -112
- package/dist/repositories/realm/index.js +507 -0
- package/dist/repositories/realm/index.js.map +1 -0
- package/dist/repositories/sqlite/index.cjs +588 -0
- package/dist/repositories/sqlite/index.cjs.map +1 -0
- package/dist/repositories/sqlite/index.d.cts +118 -0
- package/dist/{types/repositories/sqlite/walletRepository.d.ts → repositories/sqlite/index.d.ts} +58 -5
- package/dist/repositories/sqlite/index.js +585 -0
- package/dist/repositories/sqlite/index.js.map +1 -0
- package/dist/taskRunner-C6Ff4OaU.d.cts +114 -0
- package/dist/taskRunner-yvPN8Z0K.d.ts +114 -0
- package/dist/wallet/expo/background.cjs +93 -0
- package/dist/wallet/expo/background.cjs.map +1 -0
- package/dist/wallet/expo/background.d.cts +84 -0
- package/dist/wallet/expo/background.d.ts +84 -0
- package/dist/wallet/expo/background.js +68 -0
- package/dist/wallet/expo/background.js.map +1 -0
- package/dist/wallet/expo/index.cjs +171 -0
- package/dist/wallet/expo/index.cjs.map +1 -0
- package/dist/wallet/expo/index.d.cts +122 -0
- package/dist/{types/wallet/expo/wallet.d.ts → wallet/expo/index.d.ts} +45 -22
- package/dist/wallet/expo/index.js +169 -0
- package/dist/wallet/expo/index.js.map +1 -0
- package/dist/wallet-AF-p-OWj.d.cts +774 -0
- package/dist/wallet-D9NBRqvC.d.ts +774 -0
- package/dist/worker/expo/index.cjs +140 -0
- package/dist/worker/expo/index.cjs.map +1 -0
- package/dist/worker/expo/index.d.cts +29 -0
- package/dist/worker/expo/index.d.ts +29 -0
- package/dist/worker/expo/index.js +121 -0
- package/dist/worker/expo/index.js.map +1 -0
- package/package.json +110 -76
- package/dist/cjs/adapters/asyncStorage.js +0 -5
- package/dist/cjs/adapters/expo.js +0 -8
- package/dist/cjs/adapters/fileSystem.js +0 -5
- package/dist/cjs/adapters/indexedDB.js +0 -5
- package/dist/cjs/adapters/localStorage.js +0 -5
- package/dist/cjs/arkfee/celenv.js +0 -43
- package/dist/cjs/arkfee/estimator.js +0 -143
- package/dist/cjs/arkfee/index.js +0 -5
- package/dist/cjs/arkfee/types.js +0 -26
- package/dist/cjs/arknote/index.js +0 -128
- package/dist/cjs/bip322/index.js +0 -270
- package/dist/cjs/contracts/arkcontract.js +0 -147
- package/dist/cjs/contracts/contractManager.js +0 -649
- package/dist/cjs/contracts/contractWatcher.js +0 -598
- package/dist/cjs/contracts/handlers/default.js +0 -93
- package/dist/cjs/contracts/handlers/delegate.js +0 -90
- package/dist/cjs/contracts/handlers/helpers.js +0 -115
- package/dist/cjs/contracts/handlers/index.js +0 -19
- package/dist/cjs/contracts/handlers/registry.js +0 -89
- package/dist/cjs/contracts/handlers/vhtlc.js +0 -194
- package/dist/cjs/contracts/index.js +0 -41
- package/dist/cjs/contracts/types.js +0 -2
- package/dist/cjs/contracts/vtxoOwnership.js +0 -78
- package/dist/cjs/extension/asset/assetGroup.js +0 -228
- package/dist/cjs/extension/asset/assetId.js +0 -152
- package/dist/cjs/extension/asset/assetInput.js +0 -222
- package/dist/cjs/extension/asset/assetOutput.js +0 -174
- package/dist/cjs/extension/asset/assetRef.js +0 -148
- package/dist/cjs/extension/asset/index.js +0 -23
- package/dist/cjs/extension/asset/metadata.js +0 -187
- package/dist/cjs/extension/asset/packet.js +0 -114
- package/dist/cjs/extension/asset/types.js +0 -22
- package/dist/cjs/extension/asset/utils.js +0 -105
- package/dist/cjs/extension/index.js +0 -254
- package/dist/cjs/extension/packet.js +0 -20
- package/dist/cjs/forfeit.js +0 -45
- package/dist/cjs/identity/descriptor.js +0 -169
- package/dist/cjs/identity/descriptorProvider.js +0 -2
- package/dist/cjs/identity/hdCapableIdentity.js +0 -20
- package/dist/cjs/identity/index.js +0 -40
- package/dist/cjs/identity/seedIdentity.js +0 -477
- package/dist/cjs/identity/serialize.js +0 -171
- package/dist/cjs/identity/singleKey.js +0 -126
- package/dist/cjs/identity/staticDescriptorProvider.js +0 -65
- package/dist/cjs/index.js +0 -202
- package/dist/cjs/intent/index.js +0 -259
- package/dist/cjs/musig2/index.js +0 -11
- package/dist/cjs/musig2/keys.js +0 -57
- package/dist/cjs/musig2/nonces.js +0 -48
- package/dist/cjs/musig2/sign.js +0 -102
- package/dist/cjs/networks.js +0 -26
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/providers/ark.js +0 -577
- package/dist/cjs/providers/delegator.js +0 -85
- package/dist/cjs/providers/electrum.js +0 -869
- package/dist/cjs/providers/errors.js +0 -59
- package/dist/cjs/providers/expoArk.js +0 -82
- package/dist/cjs/providers/expoIndexer.js +0 -111
- package/dist/cjs/providers/expoUtils.js +0 -124
- package/dist/cjs/providers/indexer.js +0 -630
- package/dist/cjs/providers/onchain.js +0 -262
- package/dist/cjs/providers/utils.js +0 -121
- package/dist/cjs/repositories/contractRepository.js +0 -2
- package/dist/cjs/repositories/inMemory/contractRepository.js +0 -55
- package/dist/cjs/repositories/inMemory/walletRepository.js +0 -115
- package/dist/cjs/repositories/index.js +0 -34
- package/dist/cjs/repositories/indexedDB/contractRepository.js +0 -187
- package/dist/cjs/repositories/indexedDB/db.js +0 -19
- package/dist/cjs/repositories/indexedDB/manager.js +0 -100
- package/dist/cjs/repositories/indexedDB/schema.js +0 -204
- package/dist/cjs/repositories/indexedDB/walletRepository.js +0 -474
- package/dist/cjs/repositories/indexedDB/websqlAdapter.js +0 -144
- package/dist/cjs/repositories/migrations/contractRepositoryImpl.js +0 -127
- package/dist/cjs/repositories/migrations/fromStorageAdapter.js +0 -66
- package/dist/cjs/repositories/migrations/walletRepositoryImpl.js +0 -184
- package/dist/cjs/repositories/realm/contractRepository.js +0 -116
- package/dist/cjs/repositories/realm/index.js +0 -11
- package/dist/cjs/repositories/realm/schemas.js +0 -157
- package/dist/cjs/repositories/realm/types.js +0 -7
- package/dist/cjs/repositories/realm/walletRepository.js +0 -305
- package/dist/cjs/repositories/scriptFromAddress.js +0 -16
- package/dist/cjs/repositories/serialization.js +0 -82
- package/dist/cjs/repositories/sqlite/contractRepository.js +0 -135
- package/dist/cjs/repositories/sqlite/index.js +0 -7
- package/dist/cjs/repositories/sqlite/types.js +0 -2
- package/dist/cjs/repositories/sqlite/walletRepository.js +0 -441
- package/dist/cjs/repositories/walletRepository.js +0 -2
- package/dist/cjs/script/address.js +0 -108
- package/dist/cjs/script/base.js +0 -185
- package/dist/cjs/script/default.js +0 -57
- package/dist/cjs/script/delegate.js +0 -53
- package/dist/cjs/script/tapscript.js +0 -619
- package/dist/cjs/script/vhtlc.js +0 -170
- package/dist/cjs/storage/asyncStorage.js +0 -50
- package/dist/cjs/storage/fileSystem.js +0 -141
- package/dist/cjs/storage/inMemory.js +0 -24
- package/dist/cjs/storage/index.js +0 -2
- package/dist/cjs/storage/indexedDB.js +0 -101
- package/dist/cjs/storage/localStorage.js +0 -51
- package/dist/cjs/tree/signingSession.js +0 -229
- package/dist/cjs/tree/txTree.js +0 -192
- package/dist/cjs/tree/validation.js +0 -107
- package/dist/cjs/utils/anchor.js +0 -35
- package/dist/cjs/utils/arkTransaction.js +0 -271
- package/dist/cjs/utils/bip21.js +0 -127
- package/dist/cjs/utils/syncCursors.js +0 -128
- package/dist/cjs/utils/timelock.js +0 -59
- package/dist/cjs/utils/transaction.js +0 -28
- package/dist/cjs/utils/transactionHistory.js +0 -183
- package/dist/cjs/utils/txSizeEstimator.js +0 -132
- package/dist/cjs/utils/unknownFields.js +0 -174
- package/dist/cjs/wallet/asset-manager.js +0 -330
- package/dist/cjs/wallet/asset.js +0 -119
- package/dist/cjs/wallet/batch.js +0 -183
- package/dist/cjs/wallet/delegator.js +0 -308
- package/dist/cjs/wallet/expo/background.js +0 -116
- package/dist/cjs/wallet/expo/index.js +0 -9
- package/dist/cjs/wallet/expo/wallet.js +0 -230
- package/dist/cjs/wallet/hdDescriptorProvider.js +0 -188
- package/dist/cjs/wallet/index.js +0 -82
- package/dist/cjs/wallet/inputSignerRouter.js +0 -98
- package/dist/cjs/wallet/onchain.js +0 -290
- package/dist/cjs/wallet/ramps.js +0 -216
- package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +0 -953
- package/dist/cjs/wallet/serviceWorker/wallet.js +0 -1174
- package/dist/cjs/wallet/signingErrors.js +0 -32
- package/dist/cjs/wallet/unroll.js +0 -293
- package/dist/cjs/wallet/utils.js +0 -111
- package/dist/cjs/wallet/validation.js +0 -154
- package/dist/cjs/wallet/vtxo-manager.js +0 -1142
- package/dist/cjs/wallet/wallet.js +0 -2195
- package/dist/cjs/wallet/walletReceiveRotator.js +0 -547
- package/dist/cjs/worker/browser/service-worker-manager.js +0 -183
- package/dist/cjs/worker/browser/utils.js +0 -67
- package/dist/cjs/worker/errors.js +0 -16
- package/dist/cjs/worker/expo/asyncStorageTaskQueue.js +0 -78
- package/dist/cjs/worker/expo/index.js +0 -13
- package/dist/cjs/worker/expo/processors/contractPollProcessor.js +0 -62
- package/dist/cjs/worker/expo/processors/index.js +0 -6
- package/dist/cjs/worker/expo/taskQueue.js +0 -41
- package/dist/cjs/worker/expo/taskRunner.js +0 -73
- package/dist/cjs/worker/messageBus.js +0 -474
- package/dist/esm/adapters/asyncStorage.js +0 -1
- package/dist/esm/adapters/expo.js +0 -3
- package/dist/esm/adapters/fileSystem.js +0 -1
- package/dist/esm/adapters/indexedDB.js +0 -1
- package/dist/esm/adapters/localStorage.js +0 -1
- package/dist/esm/arkfee/celenv.js +0 -40
- package/dist/esm/arkfee/estimator.js +0 -139
- package/dist/esm/arkfee/index.js +0 -1
- package/dist/esm/arkfee/types.js +0 -22
- package/dist/esm/arknote/index.js +0 -124
- package/dist/esm/bip322/index.js +0 -267
- package/dist/esm/contracts/arkcontract.js +0 -140
- package/dist/esm/contracts/contractManager.js +0 -645
- package/dist/esm/contracts/contractWatcher.js +0 -594
- package/dist/esm/contracts/handlers/default.js +0 -90
- package/dist/esm/contracts/handlers/delegate.js +0 -87
- package/dist/esm/contracts/handlers/helpers.js +0 -110
- package/dist/esm/contracts/handlers/index.js +0 -12
- package/dist/esm/contracts/handlers/registry.js +0 -86
- package/dist/esm/contracts/handlers/vhtlc.js +0 -191
- package/dist/esm/contracts/index.js +0 -13
- package/dist/esm/contracts/types.js +0 -1
- package/dist/esm/contracts/vtxoOwnership.js +0 -69
- package/dist/esm/extension/asset/assetGroup.js +0 -224
- package/dist/esm/extension/asset/assetId.js +0 -148
- package/dist/esm/extension/asset/assetInput.js +0 -217
- package/dist/esm/extension/asset/assetOutput.js +0 -169
- package/dist/esm/extension/asset/assetRef.js +0 -144
- package/dist/esm/extension/asset/index.js +0 -8
- package/dist/esm/extension/asset/metadata.js +0 -182
- package/dist/esm/extension/asset/packet.js +0 -110
- package/dist/esm/extension/asset/types.js +0 -19
- package/dist/esm/extension/asset/utils.js +0 -99
- package/dist/esm/extension/index.js +0 -248
- package/dist/esm/extension/packet.js +0 -16
- package/dist/esm/forfeit.js +0 -41
- package/dist/esm/identity/descriptor.js +0 -161
- package/dist/esm/identity/descriptorProvider.js +0 -1
- package/dist/esm/identity/hdCapableIdentity.js +0 -17
- package/dist/esm/identity/index.js +0 -13
- package/dist/esm/identity/seedIdentity.js +0 -469
- package/dist/esm/identity/serialize.js +0 -164
- package/dist/esm/identity/singleKey.js +0 -121
- package/dist/esm/identity/staticDescriptorProvider.js +0 -61
- package/dist/esm/index.js +0 -87
- package/dist/esm/intent/index.js +0 -255
- package/dist/esm/musig2/index.js +0 -3
- package/dist/esm/musig2/keys.js +0 -21
- package/dist/esm/musig2/nonces.js +0 -11
- package/dist/esm/musig2/sign.js +0 -63
- package/dist/esm/networks.js +0 -22
- package/dist/esm/package.json +0 -3
- package/dist/esm/providers/ark.js +0 -572
- package/dist/esm/providers/delegator.js +0 -81
- package/dist/esm/providers/electrum.js +0 -864
- package/dist/esm/providers/errors.js +0 -54
- package/dist/esm/providers/expoArk.js +0 -78
- package/dist/esm/providers/expoIndexer.js +0 -107
- package/dist/esm/providers/expoUtils.js +0 -87
- package/dist/esm/providers/indexer.js +0 -626
- package/dist/esm/providers/onchain.js +0 -258
- package/dist/esm/providers/utils.js +0 -117
- package/dist/esm/repositories/contractRepository.js +0 -1
- package/dist/esm/repositories/inMemory/contractRepository.js +0 -51
- package/dist/esm/repositories/inMemory/walletRepository.js +0 -111
- package/dist/esm/repositories/index.js +0 -10
- package/dist/esm/repositories/indexedDB/contractRepository.js +0 -183
- package/dist/esm/repositories/indexedDB/db.js +0 -4
- package/dist/esm/repositories/indexedDB/manager.js +0 -95
- package/dist/esm/repositories/indexedDB/schema.js +0 -199
- package/dist/esm/repositories/indexedDB/walletRepository.js +0 -470
- package/dist/esm/repositories/indexedDB/websqlAdapter.js +0 -138
- package/dist/esm/repositories/migrations/contractRepositoryImpl.js +0 -121
- package/dist/esm/repositories/migrations/fromStorageAdapter.js +0 -58
- package/dist/esm/repositories/migrations/walletRepositoryImpl.js +0 -180
- package/dist/esm/repositories/realm/contractRepository.js +0 -112
- package/dist/esm/repositories/realm/index.js +0 -3
- package/dist/esm/repositories/realm/schemas.js +0 -153
- package/dist/esm/repositories/realm/types.js +0 -6
- package/dist/esm/repositories/realm/walletRepository.js +0 -301
- package/dist/esm/repositories/scriptFromAddress.js +0 -13
- package/dist/esm/repositories/serialization.js +0 -67
- package/dist/esm/repositories/sqlite/contractRepository.js +0 -131
- package/dist/esm/repositories/sqlite/index.js +0 -2
- package/dist/esm/repositories/sqlite/types.js +0 -1
- package/dist/esm/repositories/sqlite/walletRepository.js +0 -437
- package/dist/esm/repositories/walletRepository.js +0 -1
- package/dist/esm/script/address.js +0 -104
- package/dist/esm/script/base.js +0 -179
- package/dist/esm/script/default.js +0 -54
- package/dist/esm/script/delegate.js +0 -50
- package/dist/esm/script/tapscript.js +0 -615
- package/dist/esm/script/vhtlc.js +0 -167
- package/dist/esm/storage/asyncStorage.js +0 -46
- package/dist/esm/storage/fileSystem.js +0 -104
- package/dist/esm/storage/inMemory.js +0 -20
- package/dist/esm/storage/index.js +0 -1
- package/dist/esm/storage/indexedDB.js +0 -97
- package/dist/esm/storage/localStorage.js +0 -47
- package/dist/esm/tree/signingSession.js +0 -191
- package/dist/esm/tree/txTree.js +0 -188
- package/dist/esm/tree/validation.js +0 -101
- package/dist/esm/utils/anchor.js +0 -31
- package/dist/esm/utils/arkTransaction.js +0 -264
- package/dist/esm/utils/bip21.js +0 -123
- package/dist/esm/utils/syncCursors.js +0 -119
- package/dist/esm/utils/timelock.js +0 -22
- package/dist/esm/utils/transaction.js +0 -24
- package/dist/esm/utils/transactionHistory.js +0 -180
- package/dist/esm/utils/txSizeEstimator.js +0 -128
- package/dist/esm/utils/unknownFields.js +0 -169
- package/dist/esm/wallet/asset-manager.js +0 -325
- package/dist/esm/wallet/asset.js +0 -113
- package/dist/esm/wallet/batch.js +0 -180
- package/dist/esm/wallet/delegator.js +0 -303
- package/dist/esm/wallet/expo/background.js +0 -111
- package/dist/esm/wallet/expo/index.js +0 -2
- package/dist/esm/wallet/expo/wallet.js +0 -193
- package/dist/esm/wallet/hdDescriptorProvider.js +0 -184
- package/dist/esm/wallet/index.js +0 -75
- package/dist/esm/wallet/inputSignerRouter.js +0 -94
- package/dist/esm/wallet/onchain.js +0 -285
- package/dist/esm/wallet/ramps.js +0 -212
- package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +0 -946
- package/dist/esm/wallet/serviceWorker/wallet.js +0 -1169
- package/dist/esm/wallet/signingErrors.js +0 -27
- package/dist/esm/wallet/unroll.js +0 -289
- package/dist/esm/wallet/utils.js +0 -103
- package/dist/esm/wallet/validation.js +0 -142
- package/dist/esm/wallet/vtxo-manager.js +0 -1136
- package/dist/esm/wallet/wallet.js +0 -2186
- package/dist/esm/wallet/walletReceiveRotator.js +0 -540
- package/dist/esm/worker/browser/service-worker-manager.js +0 -177
- package/dist/esm/worker/browser/utils.js +0 -63
- package/dist/esm/worker/errors.js +0 -11
- package/dist/esm/worker/expo/asyncStorageTaskQueue.js +0 -74
- package/dist/esm/worker/expo/index.js +0 -4
- package/dist/esm/worker/expo/processors/contractPollProcessor.js +0 -59
- package/dist/esm/worker/expo/processors/index.js +0 -1
- package/dist/esm/worker/expo/taskQueue.js +0 -37
- package/dist/esm/worker/expo/taskRunner.js +0 -69
- package/dist/esm/worker/messageBus.js +0 -470
- package/dist/types/adapters/asyncStorage.d.ts +0 -2
- package/dist/types/adapters/expo.d.ts +0 -4
- package/dist/types/adapters/fileSystem.d.ts +0 -2
- package/dist/types/adapters/indexedDB.d.ts +0 -2
- package/dist/types/adapters/localStorage.d.ts +0 -2
- package/dist/types/arkfee/celenv.d.ts +0 -25
- package/dist/types/arkfee/estimator.d.ts +0 -49
- package/dist/types/arkfee/index.d.ts +0 -2
- package/dist/types/arkfee/types.d.ts +0 -38
- package/dist/types/arknote/index.d.ts +0 -84
- package/dist/types/bip322/index.d.ts +0 -55
- package/dist/types/contracts/arkcontract.d.ts +0 -99
- package/dist/types/contracts/contractManager.d.ts +0 -411
- package/dist/types/contracts/contractWatcher.d.ts +0 -217
- package/dist/types/contracts/handlers/default.d.ts +0 -19
- package/dist/types/contracts/handlers/delegate.d.ts +0 -21
- package/dist/types/contracts/handlers/helpers.d.ts +0 -19
- package/dist/types/contracts/handlers/index.d.ts +0 -7
- package/dist/types/contracts/handlers/registry.d.ts +0 -65
- package/dist/types/contracts/handlers/vhtlc.d.ts +0 -32
- package/dist/types/contracts/index.d.ts +0 -14
- package/dist/types/contracts/types.d.ts +0 -250
- package/dist/types/contracts/vtxoOwnership.d.ts +0 -33
- package/dist/types/extension/asset/assetGroup.d.ts +0 -119
- package/dist/types/extension/asset/assetId.d.ts +0 -83
- package/dist/types/extension/asset/assetInput.d.ts +0 -64
- package/dist/types/extension/asset/assetOutput.d.ts +0 -54
- package/dist/types/extension/asset/assetRef.d.ts +0 -91
- package/dist/types/extension/asset/index.d.ts +0 -8
- package/dist/types/extension/asset/metadata.d.ts +0 -52
- package/dist/types/extension/asset/packet.d.ts +0 -41
- package/dist/types/extension/asset/types.d.ts +0 -16
- package/dist/types/extension/asset/utils.d.ts +0 -21
- package/dist/types/extension/index.d.ts +0 -56
- package/dist/types/extension/packet.d.ts +0 -21
- package/dist/types/forfeit.d.ts +0 -18
- package/dist/types/identity/descriptor.d.ts +0 -61
- package/dist/types/identity/descriptorProvider.d.ts +0 -42
- package/dist/types/identity/hdCapableIdentity.d.ts +0 -71
- package/dist/types/identity/index.d.ts +0 -57
- package/dist/types/identity/seedIdentity.d.ts +0 -270
- package/dist/types/identity/serialize.d.ts +0 -96
- package/dist/types/identity/singleKey.d.ts +0 -62
- package/dist/types/identity/staticDescriptorProvider.d.ts +0 -18
- package/dist/types/index.d.ts +0 -59
- package/dist/types/intent/index.d.ts +0 -86
- package/dist/types/musig2/index.d.ts +0 -4
- package/dist/types/musig2/keys.d.ts +0 -9
- package/dist/types/musig2/nonces.d.ts +0 -14
- package/dist/types/musig2/sign.d.ts +0 -27
- package/dist/types/networks.d.ts +0 -16
- package/dist/types/providers/ark.d.ts +0 -369
- package/dist/types/providers/delegator.d.ts +0 -82
- package/dist/types/providers/electrum.d.ts +0 -312
- package/dist/types/providers/errors.d.ts +0 -13
- package/dist/types/providers/expoArk.d.ts +0 -22
- package/dist/types/providers/expoIndexer.d.ts +0 -18
- package/dist/types/providers/expoUtils.d.ts +0 -18
- package/dist/types/providers/indexer.d.ts +0 -301
- package/dist/types/providers/onchain.d.ts +0 -148
- package/dist/types/providers/utils.d.ts +0 -12
- package/dist/types/repositories/contractRepository.d.ts +0 -32
- package/dist/types/repositories/inMemory/contractRepository.d.ts +0 -17
- package/dist/types/repositories/inMemory/walletRepository.d.ts +0 -29
- package/dist/types/repositories/index.d.ts +0 -9
- package/dist/types/repositories/indexedDB/contractRepository.d.ts +0 -21
- package/dist/types/repositories/indexedDB/db.d.ts +0 -4
- package/dist/types/repositories/indexedDB/manager.d.ts +0 -25
- package/dist/types/repositories/indexedDB/schema.d.ts +0 -9
- package/dist/types/repositories/indexedDB/walletRepository.d.ts +0 -28
- package/dist/types/repositories/indexedDB/websqlAdapter.d.ts +0 -49
- package/dist/types/repositories/migrations/contractRepositoryImpl.d.ts +0 -24
- package/dist/types/repositories/migrations/fromStorageAdapter.d.ts +0 -19
- package/dist/types/repositories/migrations/walletRepositoryImpl.d.ts +0 -27
- package/dist/types/repositories/realm/contractRepository.d.ts +0 -24
- package/dist/types/repositories/realm/index.d.ts +0 -4
- package/dist/types/repositories/realm/types.d.ts +0 -16
- package/dist/types/repositories/realm/walletRepository.d.ts +0 -34
- package/dist/types/repositories/scriptFromAddress.d.ts +0 -9
- package/dist/types/repositories/serialization.d.ts +0 -65
- package/dist/types/repositories/sqlite/contractRepository.d.ts +0 -33
- package/dist/types/repositories/sqlite/index.d.ts +0 -3
- package/dist/types/repositories/sqlite/types.d.ts +0 -18
- package/dist/types/repositories/walletRepository.d.ts +0 -72
- package/dist/types/script/address.d.ts +0 -67
- package/dist/types/script/base.d.ts +0 -105
- package/dist/types/script/default.d.ts +0 -44
- package/dist/types/script/delegate.d.ts +0 -40
- package/dist/types/script/tapscript.d.ts +0 -169
- package/dist/types/script/vhtlc.d.ts +0 -66
- package/dist/types/tree/signingSession.d.ts +0 -37
- package/dist/types/tree/txTree.d.ts +0 -28
- package/dist/types/tree/validation.d.ts +0 -15
- package/dist/types/utils/anchor.d.ts +0 -19
- package/dist/types/utils/arkTransaction.d.ts +0 -49
- package/dist/types/utils/bip21.d.ts +0 -38
- package/dist/types/utils/syncCursors.d.ts +0 -60
- package/dist/types/utils/timelock.d.ts +0 -9
- package/dist/types/utils/transaction.d.ts +0 -13
- package/dist/types/utils/transactionHistory.d.ts +0 -15
- package/dist/types/utils/txSizeEstimator.d.ts +0 -40
- package/dist/types/utils/unknownFields.d.ts +0 -83
- package/dist/types/wallet/asset-manager.d.ts +0 -69
- package/dist/types/wallet/asset.d.ts +0 -21
- package/dist/types/wallet/batch.d.ts +0 -107
- package/dist/types/wallet/delegator.d.ts +0 -48
- package/dist/types/wallet/expo/background.d.ts +0 -66
- package/dist/types/wallet/expo/index.d.ts +0 -4
- package/dist/types/wallet/hdDescriptorProvider.d.ts +0 -114
- package/dist/types/wallet/index.d.ts +0 -789
- package/dist/types/wallet/inputSignerRouter.d.ts +0 -35
- package/dist/types/wallet/onchain.d.ts +0 -109
- package/dist/types/wallet/ramps.d.ts +0 -64
- package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +0 -543
- package/dist/types/wallet/serviceWorker/wallet.d.ts +0 -248
- package/dist/types/wallet/signingErrors.d.ts +0 -19
- package/dist/types/wallet/unroll.d.ts +0 -114
- package/dist/types/wallet/utils.d.ts +0 -36
- package/dist/types/wallet/validation.d.ts +0 -24
- package/dist/types/wallet/vtxo-manager.d.ts +0 -476
- package/dist/types/wallet/wallet.d.ts +0 -409
- package/dist/types/wallet/walletReceiveRotator.d.ts +0 -306
- package/dist/types/worker/browser/service-worker-manager.d.ts +0 -32
- package/dist/types/worker/browser/utils.d.ts +0 -17
- package/dist/types/worker/errors.d.ts +0 -7
- package/dist/types/worker/expo/index.d.ts +0 -7
- package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +0 -19
- package/dist/types/worker/expo/processors/index.d.ts +0 -1
- package/dist/types/worker/expo/taskQueue.d.ts +0 -50
- package/dist/types/worker/expo/taskRunner.d.ts +0 -66
- package/dist/types/worker/messageBus.d.ts +0 -189
package/dist/esm/arkfee/types.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FeeAmount is a wrapper around a number that represents a fee amount in satoshis floating point.
|
|
3
|
-
* @param value - The fee amount in floating point.
|
|
4
|
-
* @example
|
|
5
|
-
* const fee = new FeeAmount(1.23456789);
|
|
6
|
-
* console.log(fee.value); // 1.23456789
|
|
7
|
-
* console.log(fee.satoshis); // 2
|
|
8
|
-
*/
|
|
9
|
-
export class FeeAmount {
|
|
10
|
-
constructor(value) {
|
|
11
|
-
this.value = value;
|
|
12
|
-
}
|
|
13
|
-
/** Returns the fee amount rounded up to whole satoshis. */
|
|
14
|
-
get satoshis() {
|
|
15
|
-
return this.value ? Math.ceil(this.value) : 0;
|
|
16
|
-
}
|
|
17
|
-
/** Add two fee amounts together. */
|
|
18
|
-
add(other) {
|
|
19
|
-
return new FeeAmount(this.value + other.value);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
FeeAmount.ZERO = new FeeAmount(0);
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { base58, hex } from "@scure/base";
|
|
2
|
-
import { sha256 } from "@scure/btc-signer/utils.js";
|
|
3
|
-
import { Script } from "@scure/btc-signer";
|
|
4
|
-
import { VtxoScript } from "../script/base.js";
|
|
5
|
-
/**
|
|
6
|
-
* ArkNotes are special virtual outputs in the Arkade protocol that
|
|
7
|
-
* can be created and spent without requiring any transactions.
|
|
8
|
-
* The server mints them, and they are encoded as base58 strings
|
|
9
|
-
* with a human-readable prefix, a preimage and a value.
|
|
10
|
-
*
|
|
11
|
-
* @see VtxoScript
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* // Create an ArkNote
|
|
16
|
-
* const note = new ArkNote(preimage, 50000);
|
|
17
|
-
*
|
|
18
|
-
* // Encode to string
|
|
19
|
-
* const noteString = note.toString();
|
|
20
|
-
*
|
|
21
|
-
* // Decode from string
|
|
22
|
-
* const decodedNote = ArkNote.fromString(noteString);
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export class ArkNote {
|
|
26
|
-
/**
|
|
27
|
-
* Create an ArkNote from a preimage and value.
|
|
28
|
-
*
|
|
29
|
-
* @param preimage - 32-byte preimage revealed to spend the note
|
|
30
|
-
* @param value - Note value in satoshis
|
|
31
|
-
* @param HRP - Optional human-readable prefix for string encoding
|
|
32
|
-
*/
|
|
33
|
-
constructor(preimage, value, HRP = ArkNote.DefaultHRP) {
|
|
34
|
-
this.preimage = preimage;
|
|
35
|
-
this.value = value;
|
|
36
|
-
this.HRP = HRP;
|
|
37
|
-
this.vout = 0;
|
|
38
|
-
const preimageHash = sha256(this.preimage);
|
|
39
|
-
this.vtxoScript = new VtxoScript([noteTapscript(preimageHash)]);
|
|
40
|
-
const leaf = this.vtxoScript.leaves[0];
|
|
41
|
-
this.txid = hex.encode(new Uint8Array(preimageHash).reverse());
|
|
42
|
-
this.tapTree = this.vtxoScript.encode();
|
|
43
|
-
this.forfeitTapLeafScript = leaf;
|
|
44
|
-
this.intentTapLeafScript = leaf;
|
|
45
|
-
this.value = value;
|
|
46
|
-
this.status = { confirmed: true };
|
|
47
|
-
this.extraWitness = [this.preimage];
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Encode the note as raw bytes.
|
|
51
|
-
*
|
|
52
|
-
* @returns Serialized note bytes
|
|
53
|
-
* @see decode
|
|
54
|
-
*/
|
|
55
|
-
encode() {
|
|
56
|
-
const result = new Uint8Array(ArkNote.Length);
|
|
57
|
-
result.set(this.preimage, 0);
|
|
58
|
-
writeUInt32BE(result, this.value, this.preimage.length);
|
|
59
|
-
return result;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Decode a note from raw bytes.
|
|
63
|
-
*
|
|
64
|
-
* @param data - Serialized note bytes
|
|
65
|
-
* @param hrp - Human-readable prefix expected for future string encoding
|
|
66
|
-
* @returns Decoded ArkNote
|
|
67
|
-
* @throws Error if the payload length is invalid
|
|
68
|
-
* @see encode
|
|
69
|
-
*/
|
|
70
|
-
static decode(data, hrp = ArkNote.DefaultHRP) {
|
|
71
|
-
if (data.length !== ArkNote.Length) {
|
|
72
|
-
throw new Error(`invalid data length: expected ${ArkNote.Length} bytes, got ${data.length}`);
|
|
73
|
-
}
|
|
74
|
-
const preimage = data.subarray(0, ArkNote.PreimageLength);
|
|
75
|
-
const value = readUInt32BE(data, ArkNote.PreimageLength);
|
|
76
|
-
return new ArkNote(preimage, value, hrp);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Decode a note from its base58 string form.
|
|
80
|
-
*
|
|
81
|
-
* @param noteStr - Base58-encoded note string
|
|
82
|
-
* @param hrp - Human-readable prefix expected on the note string
|
|
83
|
-
* @returns Decoded ArkNote
|
|
84
|
-
* @throws Error if the prefix or base58 payload is invalid
|
|
85
|
-
* @see toString
|
|
86
|
-
*/
|
|
87
|
-
static fromString(noteStr, hrp = ArkNote.DefaultHRP) {
|
|
88
|
-
noteStr = noteStr.trim();
|
|
89
|
-
if (!noteStr.startsWith(hrp)) {
|
|
90
|
-
throw new Error(`invalid human-readable part: expected ${hrp} prefix (note '${noteStr}')`);
|
|
91
|
-
}
|
|
92
|
-
const encoded = noteStr.slice(hrp.length);
|
|
93
|
-
const decoded = base58.decode(encoded);
|
|
94
|
-
if (decoded.length === 0) {
|
|
95
|
-
throw new Error("failed to decode base58 string");
|
|
96
|
-
}
|
|
97
|
-
return ArkNote.decode(decoded, hrp);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Encode the note to its human-readable base58 string form.
|
|
101
|
-
*
|
|
102
|
-
* @returns Base58-encoded note string
|
|
103
|
-
* @see fromString
|
|
104
|
-
*/
|
|
105
|
-
toString() {
|
|
106
|
-
return this.HRP + base58.encode(this.encode());
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
ArkNote.DefaultHRP = "arknote";
|
|
110
|
-
ArkNote.PreimageLength = 32; // 32 bytes for the preimage
|
|
111
|
-
ArkNote.ValueLength = 4; // 4 bytes for the value
|
|
112
|
-
ArkNote.Length = ArkNote.PreimageLength + ArkNote.ValueLength;
|
|
113
|
-
ArkNote.FakeOutpointIndex = 0;
|
|
114
|
-
function writeUInt32BE(array, value, offset) {
|
|
115
|
-
const view = new DataView(array.buffer, array.byteOffset + offset, 4);
|
|
116
|
-
view.setUint32(0, value, false);
|
|
117
|
-
}
|
|
118
|
-
function readUInt32BE(array, offset) {
|
|
119
|
-
const view = new DataView(array.buffer, array.byteOffset + offset, 4);
|
|
120
|
-
return view.getUint32(0, false);
|
|
121
|
-
}
|
|
122
|
-
function noteTapscript(preimageHash) {
|
|
123
|
-
return Script.encode(["SHA256", preimageHash, "EQUAL"]);
|
|
124
|
-
}
|
package/dist/esm/bip322/index.js
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import { p2tr, p2wpkh, Address, OutScript, RawWitness, SigHash, } from "@scure/btc-signer";
|
|
2
|
-
import { concatBytes, hash160, sha256x2, } from "@scure/btc-signer/utils.js";
|
|
3
|
-
import { schnorr, secp256k1 } from "@noble/curves/secp256k1.js";
|
|
4
|
-
import { equalBytes } from "@noble/curves/utils.js";
|
|
5
|
-
import { base64 } from "@scure/base";
|
|
6
|
-
import { Transaction } from "../utils/transaction.js";
|
|
7
|
-
import { craftToSpendTx, OP_RETURN_EMPTY_PKSCRIPT } from "../intent/index.js";
|
|
8
|
-
const TAG_BIP322 = "BIP0322-signed-message";
|
|
9
|
-
/**
|
|
10
|
-
* BIP-322 simple message signing and verification.
|
|
11
|
-
*
|
|
12
|
-
* Supports P2TR (Taproot) signing and verification, P2WPKH verification,
|
|
13
|
-
* and legacy P2PKH verification (Bitcoin Core signmessage format).
|
|
14
|
-
*
|
|
15
|
-
* Reuses the same toSpend/toSign transaction construction as Intent proofs,
|
|
16
|
-
* but with the standard BIP-322 tagged hash ("BIP0322-signed-message")
|
|
17
|
-
* instead of the Arkade-specific tag.
|
|
18
|
-
*
|
|
19
|
-
* @see https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* // Sign a message (P2TR)
|
|
24
|
-
* const signature = await BIP322.sign("Hello Bitcoin!", identity);
|
|
25
|
-
*
|
|
26
|
-
* // Verify a signature (P2TR or P2WPKH)
|
|
27
|
-
* const valid = BIP322.verify("Hello Bitcoin!", signature, "bc1p...");
|
|
28
|
-
* const valid2 = BIP322.verify("Hello Bitcoin!", signature, "bc1q...");
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export var BIP322;
|
|
32
|
-
(function (BIP322) {
|
|
33
|
-
/**
|
|
34
|
-
* Sign a message using the BIP-322 simple signature scheme.
|
|
35
|
-
*
|
|
36
|
-
* Constructs the standard BIP-322 toSpend and toSign transactions,
|
|
37
|
-
* signs via the Identity interface, and returns the base64-encoded
|
|
38
|
-
* witness stack.
|
|
39
|
-
*
|
|
40
|
-
* @param message - The message to sign
|
|
41
|
-
* @param identity - Identity instance (holds the private key internally)
|
|
42
|
-
* @param network - Optional Bitcoin network for P2TR address derivation
|
|
43
|
-
* @returns Base64-encoded BIP-322 simple signature (witness stack)
|
|
44
|
-
*/
|
|
45
|
-
async function sign(message, identity, network) {
|
|
46
|
-
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
47
|
-
const payment = p2tr(xOnlyPubKey, undefined, network);
|
|
48
|
-
// Build BIP-322 toSpend using shared construction with BIP-322 tag
|
|
49
|
-
const toSpend = craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
50
|
-
// Build BIP-322 toSign: version 0, single input spending toSpend, OP_RETURN output
|
|
51
|
-
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
52
|
-
// Sign with identity (handles P2TR key-spend internally)
|
|
53
|
-
const signed = await identity.sign(toSign, [0]);
|
|
54
|
-
// Finalize and extract witness
|
|
55
|
-
signed.finalizeIdx(0);
|
|
56
|
-
const input = signed.getInput(0);
|
|
57
|
-
if (!input.finalScriptWitness) {
|
|
58
|
-
throw new Error("BIP-322: failed to produce witness after signing");
|
|
59
|
-
}
|
|
60
|
-
return base64.encode(RawWitness.encode(input.finalScriptWitness));
|
|
61
|
-
}
|
|
62
|
-
BIP322.sign = sign;
|
|
63
|
-
/**
|
|
64
|
-
* Verify a BIP-322 signature for a P2TR, P2WPKH, or legacy P2PKH address.
|
|
65
|
-
*
|
|
66
|
-
* For segwit addresses (P2TR, P2WPKH), reconstructs the BIP-322
|
|
67
|
-
* toSpend/toSign transactions and verifies the witness signature.
|
|
68
|
-
*
|
|
69
|
-
* For P2PKH addresses, verifies using the Bitcoin Core legacy
|
|
70
|
-
* `signmessage` format (compact recoverable ECDSA signature).
|
|
71
|
-
*
|
|
72
|
-
* @param message - The original message that was signed
|
|
73
|
-
* @param signature - Base64-encoded signature (BIP-322 witness or legacy compact)
|
|
74
|
-
* @param address - P2TR, P2WPKH, or P2PKH address of the signer
|
|
75
|
-
* @param network - Optional Bitcoin network for address decoding
|
|
76
|
-
* @returns true if the signature is valid
|
|
77
|
-
*/
|
|
78
|
-
function verify(message, signature, address, network) {
|
|
79
|
-
let decoded;
|
|
80
|
-
try {
|
|
81
|
-
decoded = Address(network).decode(address);
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
// Legacy P2PKH: signature is base64 of 65 raw bytes, not a witness
|
|
87
|
-
if (decoded.type === "pkh") {
|
|
88
|
-
try {
|
|
89
|
-
return verifyLegacy(message, base64.decode(signature), decoded.hash);
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
// BIP-322 simple: signature is base64 of RawWitness
|
|
96
|
-
let pkScript;
|
|
97
|
-
let witnessItems;
|
|
98
|
-
try {
|
|
99
|
-
pkScript = OutScript.encode(decoded);
|
|
100
|
-
witnessItems = RawWitness.decode(base64.decode(signature));
|
|
101
|
-
}
|
|
102
|
-
catch {
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
if (witnessItems.length === 0) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
if (decoded.type === "tr") {
|
|
109
|
-
return verifyP2TR(message, witnessItems, pkScript, decoded.pubkey);
|
|
110
|
-
}
|
|
111
|
-
if (decoded.type === "wpkh") {
|
|
112
|
-
return verifyP2WPKH(message, witnessItems, pkScript, decoded.hash);
|
|
113
|
-
}
|
|
114
|
-
throw new Error(`BIP-322 verify: unsupported address type '${decoded.type}'`);
|
|
115
|
-
}
|
|
116
|
-
BIP322.verify = verify;
|
|
117
|
-
})(BIP322 || (BIP322 = {}));
|
|
118
|
-
function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
119
|
-
// P2TR key-spend witness is exactly [schnorr_signature].
|
|
120
|
-
// Multiple items indicates a script-path spend, which BIP-322 simple doesn't cover.
|
|
121
|
-
if (witnessItems.length !== 1) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
const sig = witnessItems[0];
|
|
125
|
-
if (sig.length !== 64 && sig.length !== 65) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
// BIP-322 simple only allows SIGHASH_DEFAULT (64-byte sig) or SIGHASH_ALL (0x01).
|
|
129
|
-
const sighashType = sig.length === 65 ? sig[64] : SigHash.DEFAULT;
|
|
130
|
-
if (sighashType !== SigHash.DEFAULT && sighashType !== SigHash.ALL) {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
const toSpend = craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
134
|
-
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
135
|
-
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
136
|
-
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
137
|
-
return schnorr.verify(rawSig, sighash, pubkey);
|
|
138
|
-
}
|
|
139
|
-
function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
140
|
-
// P2WPKH witness: [der_signature || sighash_byte, compressed_pubkey]
|
|
141
|
-
if (witnessItems.length !== 2) {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
const sigWithHash = witnessItems[0];
|
|
145
|
-
const pubkey = witnessItems[1];
|
|
146
|
-
if (pubkey.length !== 33 || sigWithHash.length < 2) {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
// Verify the pubkey matches the address hash
|
|
150
|
-
const derived = p2wpkh(pubkey);
|
|
151
|
-
if (!equalBytes(derived.hash, addressHash)) {
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
// Extract sighash type (last byte) and DER signature
|
|
155
|
-
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
156
|
-
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
157
|
-
// Build toSpend and toSign
|
|
158
|
-
const toSpend = craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
159
|
-
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
160
|
-
// BIP-143 scriptCode for P2WPKH: equivalent P2PKH script
|
|
161
|
-
const scriptCode = OutScript.encode({ type: "pkh", hash: addressHash });
|
|
162
|
-
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
163
|
-
return secp256k1.verify(derSig, sighash, pubkey, {
|
|
164
|
-
prehash: false,
|
|
165
|
-
format: "der",
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Verify a legacy Bitcoin Core signmessage signature for a P2PKH address.
|
|
170
|
-
*
|
|
171
|
-
* The signature is 65 bytes: [recovery_flag, r(32), s(32)].
|
|
172
|
-
* The recovery flag encodes both the recovery ID and whether the key is
|
|
173
|
-
* compressed: flag = 27 + recovery_id (+ 4 if compressed).
|
|
174
|
-
*/
|
|
175
|
-
function verifyLegacy(message, sigBytes, addressHash) {
|
|
176
|
-
if (sigBytes.length !== 65) {
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
const flag = sigBytes[0];
|
|
180
|
-
if (flag < 27 || flag > 34) {
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
const compressed = flag >= 31;
|
|
184
|
-
const recoveryId = compressed ? flag - 31 : flag - 27;
|
|
185
|
-
const compactSig = sigBytes.subarray(1, 65);
|
|
186
|
-
const msgHash = bitcoinMessageHash(message);
|
|
187
|
-
try {
|
|
188
|
-
const sig = secp256k1.Signature.fromBytes(compactSig, "compact").addRecoveryBit(recoveryId);
|
|
189
|
-
const point = sig.recoverPublicKey(msgHash);
|
|
190
|
-
const pubkeyBytes = point.toBytes(compressed);
|
|
191
|
-
return equalBytes(hash160(pubkeyBytes), addressHash);
|
|
192
|
-
}
|
|
193
|
-
catch {
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Compute the Bitcoin message hash: SHA256d(magic_prefix + CompactSize(len) + message).
|
|
199
|
-
*/
|
|
200
|
-
function bitcoinMessageHash(message) {
|
|
201
|
-
const MAGIC = new TextEncoder().encode("\x18Bitcoin Signed Message:\n");
|
|
202
|
-
const msgBytes = new TextEncoder().encode(message);
|
|
203
|
-
return sha256x2(concatBytes(MAGIC, encodeCompactSize(msgBytes.length), msgBytes));
|
|
204
|
-
}
|
|
205
|
-
function encodeCompactSize(n) {
|
|
206
|
-
if (n < 253)
|
|
207
|
-
return new Uint8Array([n]);
|
|
208
|
-
if (n <= 0xffff) {
|
|
209
|
-
const buf = new Uint8Array(3);
|
|
210
|
-
buf[0] = 253;
|
|
211
|
-
buf[1] = n & 0xff;
|
|
212
|
-
buf[2] = (n >> 8) & 0xff;
|
|
213
|
-
return buf;
|
|
214
|
-
}
|
|
215
|
-
const buf = new Uint8Array(5);
|
|
216
|
-
buf[0] = 254;
|
|
217
|
-
buf[1] = n & 0xff;
|
|
218
|
-
buf[2] = (n >> 8) & 0xff;
|
|
219
|
-
buf[3] = (n >> 16) & 0xff;
|
|
220
|
-
buf[4] = (n >> 24) & 0xff;
|
|
221
|
-
return buf;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Build the BIP-322 "toSign" transaction for P2TR key-spend.
|
|
225
|
-
*/
|
|
226
|
-
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
227
|
-
const tx = new Transaction({ version: 0 });
|
|
228
|
-
tx.addInput({
|
|
229
|
-
txid: toSpend.id,
|
|
230
|
-
index: 0,
|
|
231
|
-
sequence: 0,
|
|
232
|
-
witnessUtxo: {
|
|
233
|
-
script: pkScript,
|
|
234
|
-
amount: 0n,
|
|
235
|
-
},
|
|
236
|
-
tapInternalKey,
|
|
237
|
-
sighashType: SigHash.DEFAULT,
|
|
238
|
-
});
|
|
239
|
-
tx.addOutput({
|
|
240
|
-
amount: 0n,
|
|
241
|
-
script: OP_RETURN_EMPTY_PKSCRIPT,
|
|
242
|
-
});
|
|
243
|
-
return tx;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Build the BIP-322 "toSign" transaction (generic, no key metadata).
|
|
247
|
-
*
|
|
248
|
-
* Used for P2WPKH verification where the toSign only needs
|
|
249
|
-
* the witnessUtxo, not tapInternalKey.
|
|
250
|
-
*/
|
|
251
|
-
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
252
|
-
const tx = new Transaction({ version: 0 });
|
|
253
|
-
tx.addInput({
|
|
254
|
-
txid: toSpend.id,
|
|
255
|
-
index: 0,
|
|
256
|
-
sequence: 0,
|
|
257
|
-
witnessUtxo: {
|
|
258
|
-
script: pkScript,
|
|
259
|
-
amount: 0n,
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
tx.addOutput({
|
|
263
|
-
amount: 0n,
|
|
264
|
-
script: OP_RETURN_EMPTY_PKSCRIPT,
|
|
265
|
-
});
|
|
266
|
-
return tx;
|
|
267
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { hex } from "@scure/base";
|
|
2
|
-
import { contractHandlers } from "./handlers/index.js";
|
|
3
|
-
import { DEFAULT_ARKADE_HRP } from "../wallet/index.js";
|
|
4
|
-
/**
|
|
5
|
-
* Prefix for arkcontract strings.
|
|
6
|
-
*/
|
|
7
|
-
const ARKCONTRACT_PREFIX = "arkcontract";
|
|
8
|
-
/**
|
|
9
|
-
* Encode a contract to the arkcontract string format.
|
|
10
|
-
*
|
|
11
|
-
* Format: arkcontract={type}&{key1}={value1}&{key2}={value2}...
|
|
12
|
-
*
|
|
13
|
-
* This format is compatible with NArk and allows contracts to be
|
|
14
|
-
* shared/imported across different Arkade SDKs.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const contract: Contract = {
|
|
19
|
-
* type: "vhtlc",
|
|
20
|
-
* params: { sender: "ab12...", receiver: "cd34...", ... },
|
|
21
|
-
* // ...
|
|
22
|
-
* };
|
|
23
|
-
*
|
|
24
|
-
* const encoded = encodeArkContract(contract);
|
|
25
|
-
* // "arkcontract=vhtlc&sender=ab12...&receiver=cd34...&..."
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export function encodeArkContract(contract) {
|
|
29
|
-
const params = new URLSearchParams();
|
|
30
|
-
// Add contract type first
|
|
31
|
-
params.set(ARKCONTRACT_PREFIX, contract.type);
|
|
32
|
-
// Add all params
|
|
33
|
-
for (const [key, value] of Object.entries(contract.params)) {
|
|
34
|
-
params.set(key, value);
|
|
35
|
-
}
|
|
36
|
-
return params.toString();
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Decode an arkcontract string into raw type and data.
|
|
40
|
-
*
|
|
41
|
-
* This is a low-level function that parses the URL-encoded format.
|
|
42
|
-
* For creating typed Contract objects, use `contractFromArkContract`
|
|
43
|
-
* or `contractFromArkContractWithAddress` instead.
|
|
44
|
-
*
|
|
45
|
-
* @param encoded - The arkcontract string
|
|
46
|
-
* @returns Parsed type and key-value data
|
|
47
|
-
* @throws If the string is not a valid arkcontract
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```typescript
|
|
51
|
-
* const parsed = decodeArkContract("arkcontract=vhtlc&sender=ab12...");
|
|
52
|
-
* // { type: "vhtlc", data: { sender: "ab12...", ... } }
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
export function decodeArkContract(encoded) {
|
|
56
|
-
const params = new URLSearchParams(encoded);
|
|
57
|
-
// Extract type from the arkcontract key
|
|
58
|
-
const type = params.get(ARKCONTRACT_PREFIX);
|
|
59
|
-
if (!type) {
|
|
60
|
-
throw new Error(`Invalid arkcontract string: missing '${ARKCONTRACT_PREFIX}' key`);
|
|
61
|
-
}
|
|
62
|
-
// Build data object from all other params
|
|
63
|
-
const data = {};
|
|
64
|
-
for (const [key, value] of params.entries()) {
|
|
65
|
-
if (key !== ARKCONTRACT_PREFIX) {
|
|
66
|
-
data[key] = value;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return { type, data };
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Create a Contract from an arkcontract string.
|
|
73
|
-
*
|
|
74
|
-
* This requires a handler to be registered for the contract type.
|
|
75
|
-
*
|
|
76
|
-
* @param encoded - The arkcontract string
|
|
77
|
-
* @param options - Additional options for the contract
|
|
78
|
-
* @returns A Contract object
|
|
79
|
-
* @throws If the string is invalid or no handler exists for the type
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```typescript
|
|
83
|
-
* const contract = contractFromArkContract(
|
|
84
|
-
* "arkcontract=vhtlc&sender=ab12...",
|
|
85
|
-
* {
|
|
86
|
-
* label: "Lightning Receive",
|
|
87
|
-
* }
|
|
88
|
-
* );
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
export function contractFromArkContract(encoded, options = {}) {
|
|
92
|
-
const parsed = decodeArkContract(encoded);
|
|
93
|
-
const handler = contractHandlers.get(parsed.type);
|
|
94
|
-
if (!handler) {
|
|
95
|
-
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
96
|
-
}
|
|
97
|
-
// Separate params from runtime data
|
|
98
|
-
// This is type-specific - the handler knows which keys are params
|
|
99
|
-
// For now, we treat all data as params
|
|
100
|
-
const params = parsed.data;
|
|
101
|
-
return {
|
|
102
|
-
label: options.label,
|
|
103
|
-
type: parsed.type,
|
|
104
|
-
params,
|
|
105
|
-
state: options.state || "active",
|
|
106
|
-
createdAt: Date.now(),
|
|
107
|
-
metadata: options.metadata,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Create a full Contract with derived script and address.
|
|
112
|
-
*
|
|
113
|
-
* @param encoded - The arkcontract string
|
|
114
|
-
* @param serverPubKey - Server public key (for address derivation)
|
|
115
|
-
* @param addressPrefix - Address prefix (e.g., "tark" for testnet)
|
|
116
|
-
* @param options - Additional options
|
|
117
|
-
* @returns A complete Contract object
|
|
118
|
-
*/
|
|
119
|
-
export function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = DEFAULT_ARKADE_HRP, options = {}) {
|
|
120
|
-
const parsed = decodeArkContract(encoded);
|
|
121
|
-
const handler = contractHandlers.getOrThrow(parsed.type);
|
|
122
|
-
const params = parsed.data;
|
|
123
|
-
const vtxoScript = handler.createScript(params);
|
|
124
|
-
return {
|
|
125
|
-
label: options.label,
|
|
126
|
-
type: parsed.type,
|
|
127
|
-
params,
|
|
128
|
-
script: hex.encode(vtxoScript.pkScript),
|
|
129
|
-
address: vtxoScript.address(addressPrefix, serverPubKey).encode(),
|
|
130
|
-
state: options.state || "active",
|
|
131
|
-
createdAt: Date.now(),
|
|
132
|
-
metadata: options.metadata,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Check if a string is an arkcontract.
|
|
137
|
-
*/
|
|
138
|
-
export function isArkContract(str) {
|
|
139
|
-
return str.startsWith(ARKCONTRACT_PREFIX + "=");
|
|
140
|
-
}
|