@arkade-os/sdk 0.4.24 → 0.4.26
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/dist/cjs/contracts/contractManager.js +44 -8
- package/dist/cjs/contracts/contractWatcher.js +2 -2
- package/dist/cjs/contracts/vtxoOwnership.js +18 -0
- package/dist/cjs/repositories/inMemory/walletRepository.js +35 -0
- package/dist/cjs/repositories/indexedDB/walletRepository.js +117 -0
- package/dist/cjs/repositories/realm/walletRepository.js +28 -0
- package/dist/cjs/repositories/sqlite/walletRepository.js +23 -0
- package/dist/cjs/script/address.js +2 -2
- package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +14 -3
- package/dist/cjs/wallet/serviceWorker/wallet.js +10 -0
- package/dist/cjs/wallet/vtxo-manager.js +112 -16
- package/dist/cjs/wallet/wallet.js +3 -17
- package/dist/cjs/worker/expo/processors/contractPollProcessor.js +1 -1
- package/dist/esm/adapters/asyncStorage.js +1 -1
- package/dist/esm/adapters/expo.js +2 -2
- package/dist/esm/adapters/fileSystem.js +1 -1
- package/dist/esm/adapters/indexedDB.js +1 -1
- package/dist/esm/adapters/localStorage.js +1 -1
- package/dist/esm/arkfee/index.js +1 -1
- package/dist/esm/arknote/index.js +1 -1
- package/dist/esm/bip322/index.js +2 -2
- package/dist/esm/contracts/arkcontract.js +2 -2
- package/dist/esm/contracts/contractManager.js +49 -13
- package/dist/esm/contracts/contractWatcher.js +5 -5
- package/dist/esm/contracts/handlers/default.js +4 -4
- package/dist/esm/contracts/handlers/delegate.js +4 -4
- package/dist/esm/contracts/handlers/helpers.js +2 -2
- package/dist/esm/contracts/handlers/index.js +8 -8
- package/dist/esm/contracts/handlers/vhtlc.js +3 -3
- package/dist/esm/contracts/index.js +8 -8
- package/dist/esm/contracts/vtxoOwnership.js +16 -0
- package/dist/esm/extension/asset/assetGroup.js +7 -7
- package/dist/esm/extension/asset/assetId.js +2 -2
- package/dist/esm/extension/asset/assetInput.js +2 -2
- package/dist/esm/extension/asset/assetOutput.js +1 -1
- package/dist/esm/extension/asset/assetRef.js +3 -3
- package/dist/esm/extension/asset/index.js +8 -8
- package/dist/esm/extension/asset/metadata.js +1 -1
- package/dist/esm/extension/asset/packet.js +3 -3
- package/dist/esm/extension/index.js +4 -4
- package/dist/esm/forfeit.js +2 -2
- package/dist/esm/identity/index.js +5 -5
- package/dist/esm/identity/seedIdentity.js +2 -2
- package/dist/esm/identity/serialize.js +2 -2
- package/dist/esm/identity/singleKey.js +1 -1
- package/dist/esm/identity/staticDescriptorProvider.js +2 -2
- package/dist/esm/index.js +47 -47
- package/dist/esm/intent/index.js +3 -3
- package/dist/esm/musig2/index.js +3 -3
- package/dist/esm/musig2/sign.js +1 -1
- package/dist/esm/providers/ark.js +3 -3
- package/dist/esm/providers/delegator.js +1 -1
- package/dist/esm/providers/electrum.js +2 -2
- package/dist/esm/providers/expoArk.js +2 -2
- package/dist/esm/providers/expoIndexer.js +3 -3
- package/dist/esm/providers/indexer.js +3 -3
- package/dist/esm/repositories/inMemory/walletRepository.js +35 -0
- package/dist/esm/repositories/index.js +9 -9
- package/dist/esm/repositories/indexedDB/contractRepository.js +4 -4
- package/dist/esm/repositories/indexedDB/db.js +2 -2
- package/dist/esm/repositories/indexedDB/schema.js +1 -1
- package/dist/esm/repositories/indexedDB/walletRepository.js +122 -5
- package/dist/esm/repositories/migrations/fromStorageAdapter.js +1 -1
- package/dist/esm/repositories/migrations/walletRepositoryImpl.js +1 -1
- package/dist/esm/repositories/realm/index.js +3 -3
- package/dist/esm/repositories/realm/schemas.js +1 -1
- package/dist/esm/repositories/realm/walletRepository.js +30 -2
- package/dist/esm/repositories/scriptFromAddress.js +1 -1
- package/dist/esm/repositories/sqlite/index.js +2 -2
- package/dist/esm/repositories/sqlite/walletRepository.js +25 -2
- package/dist/esm/script/address.js +3 -3
- package/dist/esm/script/base.js +3 -3
- package/dist/esm/script/default.js +2 -2
- package/dist/esm/script/delegate.js +3 -3
- package/dist/esm/script/tapscript.js +1 -1
- package/dist/esm/script/vhtlc.js +2 -2
- package/dist/esm/storage/indexedDB.js +1 -1
- package/dist/esm/tree/signingSession.js +2 -2
- package/dist/esm/tree/validation.js +2 -2
- package/dist/esm/utils/arkTransaction.js +7 -7
- package/dist/esm/utils/transactionHistory.js +1 -1
- package/dist/esm/utils/unknownFields.js +1 -1
- package/dist/esm/wallet/asset-manager.js +5 -5
- package/dist/esm/wallet/asset.js +1 -1
- package/dist/esm/wallet/batch.js +2 -2
- package/dist/esm/wallet/delegator.js +6 -6
- package/dist/esm/wallet/expo/background.js +5 -5
- package/dist/esm/wallet/expo/index.js +2 -2
- package/dist/esm/wallet/expo/wallet.js +8 -8
- package/dist/esm/wallet/hdDescriptorProvider.js +2 -2
- package/dist/esm/wallet/onchain.js +7 -7
- package/dist/esm/wallet/ramps.js +3 -3
- package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +20 -9
- package/dist/esm/wallet/serviceWorker/wallet.js +17 -7
- package/dist/esm/wallet/unroll.js +7 -7
- package/dist/esm/wallet/utils.js +2 -2
- package/dist/esm/wallet/validation.js +2 -2
- package/dist/esm/wallet/vtxo-manager.js +120 -24
- package/dist/esm/wallet/wallet.js +36 -50
- package/dist/esm/worker/expo/index.js +4 -4
- package/dist/esm/worker/expo/processors/contractPollProcessor.js +2 -2
- package/dist/esm/worker/expo/processors/index.js +1 -1
- package/dist/esm/worker/expo/taskRunner.js +1 -1
- package/dist/esm/worker/messageBus.js +6 -6
- package/dist/types/adapters/asyncStorage.d.ts +2 -2
- package/dist/types/adapters/expo.d.ts +4 -4
- package/dist/types/adapters/fileSystem.d.ts +2 -2
- package/dist/types/adapters/indexedDB.d.ts +2 -2
- package/dist/types/adapters/localStorage.d.ts +2 -2
- package/dist/types/arkfee/index.d.ts +2 -2
- package/dist/types/arknote/index.d.ts +2 -2
- package/dist/types/bip322/index.d.ts +1 -1
- package/dist/types/contracts/arkcontract.d.ts +1 -1
- package/dist/types/contracts/contractManager.d.ts +22 -6
- package/dist/types/contracts/contractWatcher.d.ts +3 -3
- package/dist/types/contracts/handlers/default.d.ts +3 -3
- package/dist/types/contracts/handlers/delegate.d.ts +3 -3
- package/dist/types/contracts/handlers/helpers.d.ts +1 -1
- package/dist/types/contracts/handlers/index.d.ts +7 -7
- package/dist/types/contracts/handlers/registry.d.ts +1 -1
- package/dist/types/contracts/handlers/vhtlc.d.ts +3 -3
- package/dist/types/contracts/index.d.ts +14 -14
- package/dist/types/contracts/types.d.ts +3 -3
- package/dist/types/contracts/vtxoOwnership.d.ts +9 -1
- package/dist/types/extension/asset/assetGroup.d.ts +6 -6
- package/dist/types/extension/asset/assetId.d.ts +1 -1
- package/dist/types/extension/asset/assetInput.d.ts +2 -2
- package/dist/types/extension/asset/assetOutput.d.ts +1 -1
- package/dist/types/extension/asset/assetRef.d.ts +3 -3
- package/dist/types/extension/asset/index.d.ts +8 -8
- package/dist/types/extension/asset/metadata.d.ts +1 -1
- package/dist/types/extension/asset/packet.d.ts +2 -2
- package/dist/types/extension/index.d.ts +6 -6
- package/dist/types/forfeit.d.ts +1 -1
- package/dist/types/identity/descriptorProvider.d.ts +1 -1
- package/dist/types/identity/hdCapableIdentity.d.ts +3 -3
- package/dist/types/identity/index.d.ts +11 -11
- package/dist/types/identity/seedIdentity.d.ts +5 -5
- package/dist/types/identity/serialize.d.ts +1 -1
- package/dist/types/identity/singleKey.d.ts +3 -3
- package/dist/types/identity/staticDescriptorProvider.d.ts +3 -3
- package/dist/types/index.d.ts +57 -57
- package/dist/types/intent/index.d.ts +2 -2
- package/dist/types/musig2/index.d.ts +4 -4
- package/dist/types/providers/ark.d.ts +5 -5
- package/dist/types/providers/delegator.d.ts +2 -2
- package/dist/types/providers/electrum.d.ts +5 -5
- package/dist/types/providers/expoArk.d.ts +1 -1
- package/dist/types/providers/expoIndexer.d.ts +1 -1
- package/dist/types/providers/indexer.d.ts +1 -1
- package/dist/types/providers/onchain.d.ts +2 -2
- package/dist/types/repositories/contractRepository.d.ts +1 -1
- package/dist/types/repositories/inMemory/contractRepository.d.ts +2 -2
- package/dist/types/repositories/inMemory/walletRepository.d.ts +5 -2
- package/dist/types/repositories/index.d.ts +9 -9
- package/dist/types/repositories/indexedDB/contractRepository.d.ts +2 -2
- package/dist/types/repositories/indexedDB/db.d.ts +3 -3
- package/dist/types/repositories/indexedDB/walletRepository.d.ts +5 -2
- package/dist/types/repositories/migrations/contractRepositoryImpl.d.ts +3 -3
- package/dist/types/repositories/migrations/fromStorageAdapter.d.ts +2 -2
- package/dist/types/repositories/migrations/walletRepositoryImpl.d.ts +3 -3
- package/dist/types/repositories/realm/contractRepository.d.ts +3 -3
- package/dist/types/repositories/realm/index.d.ts +4 -4
- package/dist/types/repositories/realm/walletRepository.d.ts +6 -3
- package/dist/types/repositories/serialization.d.ts +11 -11
- package/dist/types/repositories/sqlite/contractRepository.d.ts +3 -3
- package/dist/types/repositories/sqlite/index.d.ts +3 -3
- package/dist/types/repositories/sqlite/walletRepository.d.ts +6 -3
- package/dist/types/repositories/walletRepository.d.ts +22 -1
- package/dist/types/script/address.d.ts +2 -2
- package/dist/types/script/base.d.ts +2 -2
- package/dist/types/script/default.d.ts +2 -2
- package/dist/types/script/delegate.d.ts +3 -3
- package/dist/types/script/vhtlc.d.ts +2 -2
- package/dist/types/storage/asyncStorage.d.ts +1 -1
- package/dist/types/storage/fileSystem.d.ts +1 -1
- package/dist/types/storage/inMemory.d.ts +1 -1
- package/dist/types/storage/indexedDB.d.ts +1 -1
- package/dist/types/storage/localStorage.d.ts +1 -1
- package/dist/types/tree/signingSession.d.ts +2 -2
- package/dist/types/tree/validation.d.ts +1 -1
- package/dist/types/utils/arkTransaction.d.ts +5 -5
- package/dist/types/utils/syncCursors.d.ts +1 -1
- package/dist/types/utils/timelock.d.ts +1 -1
- package/dist/types/utils/transaction.d.ts +2 -2
- package/dist/types/utils/transactionHistory.d.ts +1 -1
- package/dist/types/utils/txSizeEstimator.d.ts +1 -1
- package/dist/types/wallet/asset-manager.d.ts +3 -3
- package/dist/types/wallet/asset.d.ts +2 -2
- package/dist/types/wallet/batch.d.ts +2 -2
- package/dist/types/wallet/delegator.d.ts +5 -5
- package/dist/types/wallet/expo/background.d.ts +4 -4
- package/dist/types/wallet/expo/index.d.ts +4 -4
- package/dist/types/wallet/expo/wallet.d.ts +8 -8
- package/dist/types/wallet/hdDescriptorProvider.d.ts +4 -4
- package/dist/types/wallet/index.d.ts +29 -26
- package/dist/types/wallet/onchain.d.ts +6 -6
- package/dist/types/wallet/ramps.d.ts +2 -2
- package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +21 -9
- package/dist/types/wallet/serviceWorker/wallet.d.ts +10 -10
- package/dist/types/wallet/unroll.d.ts +6 -6
- package/dist/types/wallet/utils.d.ts +5 -5
- package/dist/types/wallet/validation.d.ts +3 -3
- package/dist/types/wallet/vtxo-manager.d.ts +34 -7
- package/dist/types/wallet/wallet.d.ts +20 -20
- package/dist/types/worker/expo/asyncStorageTaskQueue.d.ts +1 -1
- package/dist/types/worker/expo/index.d.ts +7 -7
- package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +1 -1
- package/dist/types/worker/expo/processors/index.d.ts +1 -1
- package/dist/types/worker/expo/taskRunner.d.ts +7 -7
- package/dist/types/worker/messageBus.d.ts +6 -6
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { Transaction } from
|
|
2
|
-
import { SingleKey, ReadonlySingleKey } from
|
|
3
|
-
import { SeedIdentity, MnemonicIdentity, ReadonlyDescriptorIdentity, } from
|
|
4
|
-
import { isBatchSignable, } from
|
|
5
|
-
import { ArkAddress } from
|
|
6
|
-
import { VHTLC } from
|
|
7
|
-
import { DefaultVtxo } from
|
|
8
|
-
import { DelegateVtxo } from
|
|
9
|
-
import { MessageBus, } from
|
|
10
|
-
import { VtxoScript, TapTreeCoder, getSequence, } from
|
|
11
|
-
import { TxType, isSpendable, isSubdust, isRecoverable, isExpired, } from
|
|
12
|
-
import { Batch } from
|
|
13
|
-
import { Wallet, ReadonlyWallet, waitForIncomingFunds, } from
|
|
14
|
-
import { TxTree } from
|
|
15
|
-
import { Ramps } from
|
|
16
|
-
import { HDDescriptorProvider } from
|
|
17
|
-
import { isVtxoExpiringSoon, VtxoManager } from
|
|
18
|
-
import { ServiceWorkerWallet, ServiceWorkerReadonlyWallet, DEFAULT_MESSAGE_TIMEOUTS, } from
|
|
19
|
-
import { OnchainWallet } from
|
|
20
|
-
import { setupServiceWorker } from
|
|
21
|
-
import { ESPLORA_URL, EsploraProvider, } from
|
|
22
|
-
import { ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ElectrumOnchainProvider, WsElectrumChainSource, } from
|
|
23
|
-
import { RestArkProvider, SettlementEventType, } from
|
|
24
|
-
import { RestDelegatorProvider, } from
|
|
25
|
-
import { CLTVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, CSVMultisigTapscript, decodeTapscript, MultisigTapscript, } from
|
|
26
|
-
import { hasBoardingTxExpired, buildOffchainTx, verifyTapscriptSignatures, combineTapscriptSigs, isValidArkAddress, } from
|
|
27
|
-
import { VtxoTaprootTree, ConditionWitness, getArkPsbtFields, setArkPsbtField, ArkPsbtFieldKey, ArkPsbtFieldKeyType, CosignerPublicKey, VtxoTreeExpiry, } from
|
|
28
|
-
import { Intent } from
|
|
29
|
-
import { BIP322 } from
|
|
30
|
-
import { ArkNote } from
|
|
31
|
-
import { networks } from
|
|
32
|
-
import { RestIndexerProvider, IndexerTxType, ChainTxType, } from
|
|
33
|
-
import { P2A } from
|
|
34
|
-
import { TxWeightEstimator } from
|
|
35
|
-
import { Unroll } from
|
|
36
|
-
import { ArkError, maybeArkError } from
|
|
37
|
-
import { validateVtxoTxGraph, validateConnectorsTxGraph, } from
|
|
38
|
-
import { buildForfeitTx } from
|
|
39
|
-
import { IndexedDBWalletRepository, IndexedDBContractRepository, InMemoryWalletRepository, InMemoryContractRepository, MIGRATION_KEY, migrateWalletRepository, requiresMigration, getMigrationStatus, rollbackMigration, WalletRepositoryImpl, ContractRepositoryImpl, } from
|
|
40
|
-
import { DelegatorManagerImpl } from
|
|
41
|
-
export * from
|
|
42
|
-
export * as asset from
|
|
1
|
+
import { Transaction } from "./utils/transaction.js";
|
|
2
|
+
import { SingleKey, ReadonlySingleKey } from "./identity/singleKey.js";
|
|
3
|
+
import { SeedIdentity, MnemonicIdentity, ReadonlyDescriptorIdentity, } from "./identity/seedIdentity.js";
|
|
4
|
+
import { isBatchSignable, } from "./identity/index.js";
|
|
5
|
+
import { ArkAddress } from "./script/address.js";
|
|
6
|
+
import { VHTLC } from "./script/vhtlc.js";
|
|
7
|
+
import { DefaultVtxo } from "./script/default.js";
|
|
8
|
+
import { DelegateVtxo } from "./script/delegate.js";
|
|
9
|
+
import { MessageBus, } from "./worker/messageBus.js";
|
|
10
|
+
import { VtxoScript, TapTreeCoder, getSequence, } from "./script/base.js";
|
|
11
|
+
import { TxType, isSpendable, isSubdust, isRecoverable, isExpired, } from "./wallet/index.js";
|
|
12
|
+
import { Batch } from "./wallet/batch.js";
|
|
13
|
+
import { Wallet, ReadonlyWallet, waitForIncomingFunds, } from "./wallet/wallet.js";
|
|
14
|
+
import { TxTree } from "./tree/txTree.js";
|
|
15
|
+
import { Ramps } from "./wallet/ramps.js";
|
|
16
|
+
import { HDDescriptorProvider } from "./wallet/hdDescriptorProvider.js";
|
|
17
|
+
import { isVtxoExpiringSoon, VtxoManager } from "./wallet/vtxo-manager.js";
|
|
18
|
+
import { ServiceWorkerWallet, ServiceWorkerReadonlyWallet, DEFAULT_MESSAGE_TIMEOUTS, } from "./wallet/serviceWorker/wallet.js";
|
|
19
|
+
import { OnchainWallet } from "./wallet/onchain.js";
|
|
20
|
+
import { setupServiceWorker } from "./worker/browser/utils.js";
|
|
21
|
+
import { ESPLORA_URL, EsploraProvider, } from "./providers/onchain.js";
|
|
22
|
+
import { ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ElectrumOnchainProvider, WsElectrumChainSource, } from "./providers/electrum.js";
|
|
23
|
+
import { RestArkProvider, SettlementEventType, } from "./providers/ark.js";
|
|
24
|
+
import { RestDelegatorProvider, } from "./providers/delegator.js";
|
|
25
|
+
import { CLTVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, CSVMultisigTapscript, decodeTapscript, MultisigTapscript, } from "./script/tapscript.js";
|
|
26
|
+
import { hasBoardingTxExpired, buildOffchainTx, verifyTapscriptSignatures, combineTapscriptSigs, isValidArkAddress, } from "./utils/arkTransaction.js";
|
|
27
|
+
import { VtxoTaprootTree, ConditionWitness, getArkPsbtFields, setArkPsbtField, ArkPsbtFieldKey, ArkPsbtFieldKeyType, CosignerPublicKey, VtxoTreeExpiry, } from "./utils/unknownFields.js";
|
|
28
|
+
import { Intent } from "./intent/index.js";
|
|
29
|
+
import { BIP322 } from "./bip322/index.js";
|
|
30
|
+
import { ArkNote } from "./arknote/index.js";
|
|
31
|
+
import { networks } from "./networks.js";
|
|
32
|
+
import { RestIndexerProvider, IndexerTxType, ChainTxType, } from "./providers/indexer.js";
|
|
33
|
+
import { P2A } from "./utils/anchor.js";
|
|
34
|
+
import { TxWeightEstimator } from "./utils/txSizeEstimator.js";
|
|
35
|
+
import { Unroll } from "./wallet/unroll.js";
|
|
36
|
+
import { ArkError, maybeArkError } from "./providers/errors.js";
|
|
37
|
+
import { validateVtxoTxGraph, validateConnectorsTxGraph, } from "./tree/validation.js";
|
|
38
|
+
import { buildForfeitTx } from "./forfeit.js";
|
|
39
|
+
import { IndexedDBWalletRepository, IndexedDBContractRepository, InMemoryWalletRepository, InMemoryContractRepository, MIGRATION_KEY, migrateWalletRepository, requiresMigration, getMigrationStatus, rollbackMigration, WalletRepositoryImpl, ContractRepositoryImpl, } from "./repositories/index.js";
|
|
40
|
+
import { DelegatorManagerImpl } from "./wallet/delegator.js";
|
|
41
|
+
export * from "./arkfee/index.js";
|
|
42
|
+
export * as asset from "./extension/asset/index.js";
|
|
43
43
|
// Contracts
|
|
44
|
-
import { ContractManager, ContractWatcher, contractHandlers, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, encodeArkContract, decodeArkContract, contractFromArkContract, contractFromArkContractWithAddress, isArkContract, } from
|
|
45
|
-
import { timelockToSequence, sequenceToTimelock } from
|
|
46
|
-
import { closeDatabase, openDatabase } from
|
|
47
|
-
import { WalletMessageHandler, WalletNotInitializedError, ReadonlyWalletError, DelegatorNotConfiguredError, } from
|
|
48
|
-
import { MESSAGE_BUS_NOT_INITIALIZED, MessageBusNotInitializedError, ServiceWorkerTimeoutError, } from
|
|
44
|
+
import { ContractManager, ContractWatcher, contractHandlers, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, encodeArkContract, decodeArkContract, contractFromArkContract, contractFromArkContractWithAddress, isArkContract, } from "./contracts/index.js";
|
|
45
|
+
import { timelockToSequence, sequenceToTimelock } from "./utils/timelock.js";
|
|
46
|
+
import { closeDatabase, openDatabase } from "./repositories/indexedDB/manager.js";
|
|
47
|
+
import { WalletMessageHandler, WalletNotInitializedError, ReadonlyWalletError, DelegatorNotConfiguredError, } from "./wallet/serviceWorker/wallet-message-handler.js";
|
|
48
|
+
import { MESSAGE_BUS_NOT_INITIALIZED, MessageBusNotInitializedError, ServiceWorkerTimeoutError, } from "./worker/errors.js";
|
|
49
49
|
export {
|
|
50
50
|
// Wallets
|
|
51
51
|
Wallet, ReadonlyWallet, SingleKey, ReadonlySingleKey, SeedIdentity, MnemonicIdentity, ReadonlyDescriptorIdentity, isBatchSignable, OnchainWallet, Ramps, VtxoManager, HDDescriptorProvider, DelegatorManagerImpl, RestDelegatorProvider,
|
package/dist/esm/intent/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { OP, Script, SigHash } from "@scure/btc-signer";
|
|
2
2
|
import { schnorr } from "@noble/curves/secp256k1.js";
|
|
3
|
-
import { Transaction } from
|
|
4
|
-
import { ConditionWitness, VtxoTaprootTree } from
|
|
3
|
+
import { Transaction } from "../utils/transaction.js";
|
|
4
|
+
import { ConditionWitness, VtxoTaprootTree } from "../utils/unknownFields.js";
|
|
5
5
|
import { hex } from "@scure/base";
|
|
6
|
-
import { getSequence, VtxoScript } from
|
|
6
|
+
import { getSequence, VtxoScript } from "../script/base.js";
|
|
7
7
|
/**
|
|
8
8
|
* Intent proof implementation for Bitcoin message signing.
|
|
9
9
|
*
|
package/dist/esm/musig2/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { generateNonces, aggregateNonces } from
|
|
2
|
-
export { PartialSig, sign } from
|
|
3
|
-
export { aggregateKeys } from
|
|
1
|
+
export { generateNonces, aggregateNonces } from "./nonces.js";
|
|
2
|
+
export { PartialSig, sign } from "./sign.js";
|
|
3
|
+
export { aggregateKeys } from "./keys.js";
|
package/dist/esm/musig2/sign.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as musig from "@scure/btc-signer/musig2.js";
|
|
2
2
|
import { bytesToNumberBE } from "@noble/curves/utils.js";
|
|
3
3
|
import { Point } from "@noble/secp256k1";
|
|
4
|
-
import { aggregateKeys } from
|
|
4
|
+
import { aggregateKeys } from "./keys.js";
|
|
5
5
|
import { schnorr } from "@noble/curves/secp256k1.js";
|
|
6
6
|
// Add this error type for decode failures
|
|
7
7
|
export class PartialSignatureError extends Error {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { hex } from "@scure/base";
|
|
2
|
-
import { eventSourceIterator, isEventSourceError } from
|
|
3
|
-
import { maybeArkError } from
|
|
4
|
-
import { Intent } from
|
|
2
|
+
import { eventSourceIterator, isEventSourceError } from "./utils.js";
|
|
3
|
+
import { maybeArkError } from "./errors.js";
|
|
4
|
+
import { Intent } from "../intent/index.js";
|
|
5
5
|
export var SettlementEventType;
|
|
6
6
|
(function (SettlementEventType) {
|
|
7
7
|
SettlementEventType["BatchStarted"] = "batch_started";
|
|
@@ -92,8 +92,8 @@ function parseBlockHeader(headerHex) {
|
|
|
92
92
|
* @example
|
|
93
93
|
* ```typescript
|
|
94
94
|
* import { ElectrumWS } from "ws-electrumx-client";
|
|
95
|
-
* import { WsElectrumChainSource } from
|
|
96
|
-
* import { networks } from
|
|
95
|
+
* import { WsElectrumChainSource } from "./providers/electrum.js";
|
|
96
|
+
* import { networks } from "./networks.js";
|
|
97
97
|
*
|
|
98
98
|
* const ws = new ElectrumWS("wss://electrum.blockstream.info:50004");
|
|
99
99
|
* const chain = new WsElectrumChainSource(ws, networks.bitcoin);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RestArkProvider, isFetchTimeoutError, } from
|
|
2
|
-
import { getExpoFetch, sseStreamIterator } from
|
|
1
|
+
import { RestArkProvider, isFetchTimeoutError, } from "./ark.js";
|
|
2
|
+
import { getExpoFetch, sseStreamIterator } from "./expoUtils.js";
|
|
3
3
|
/**
|
|
4
4
|
* Expo-compatible Arkade provider implementation using expo/fetch for SSE support.
|
|
5
5
|
* This provider works specifically in React Native/Expo environments where
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RestIndexerProvider } from
|
|
2
|
-
import { isFetchTimeoutError } from
|
|
3
|
-
import { getExpoFetch, sseStreamIterator } from
|
|
1
|
+
import { RestIndexerProvider } from "./indexer.js";
|
|
2
|
+
import { isFetchTimeoutError } from "./ark.js";
|
|
3
|
+
import { getExpoFetch, sseStreamIterator } from "./expoUtils.js";
|
|
4
4
|
// Helper function to convert Vtxo to VirtualCoin (same as in indexer.ts)
|
|
5
5
|
function convertVtxo(vtxo) {
|
|
6
6
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { hex } from "@scure/base";
|
|
2
|
-
import { isFetchTimeoutError } from
|
|
3
|
-
import { eventSourceIterator, isEventSourceError } from
|
|
4
|
-
import { MetadataList } from
|
|
2
|
+
import { isFetchTimeoutError } from "./ark.js";
|
|
3
|
+
import { eventSourceIterator, isEventSourceError } from "./utils.js";
|
|
4
|
+
import { MetadataList } from "../extension/asset/index.js";
|
|
5
5
|
export var IndexerTxType;
|
|
6
6
|
(function (IndexerTxType) {
|
|
7
7
|
IndexerTxType[IndexerTxType["INDEXER_TX_TYPE_UNSPECIFIED"] = 0] = "INDEXER_TX_TYPE_UNSPECIFIED";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isVtxoForScript } from "../../contracts/vtxoOwnership.js";
|
|
1
2
|
/**
|
|
2
3
|
* In-memory implementation of WalletRepository.
|
|
3
4
|
* Data is ephemeral and scoped to the instance.
|
|
@@ -21,6 +22,40 @@ export class InMemoryWalletRepository {
|
|
|
21
22
|
async deleteVtxos(address) {
|
|
22
23
|
this.vtxosByAddress.delete(address);
|
|
23
24
|
}
|
|
25
|
+
async getVtxosForScript(script) {
|
|
26
|
+
const allMatches = [];
|
|
27
|
+
for (const bucket of this.vtxosByAddress.values()) {
|
|
28
|
+
for (const vtxo of bucket) {
|
|
29
|
+
if (isVtxoForScript(vtxo, script)) {
|
|
30
|
+
allMatches.push(vtxo);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Dedup by outpoint (last-write-wins across address buckets)
|
|
35
|
+
return mergeByKey([], allMatches, (item) => `${item.txid}:${item.vout}`);
|
|
36
|
+
}
|
|
37
|
+
async saveVtxosForScript(key, vtxos) {
|
|
38
|
+
if (!key.address) {
|
|
39
|
+
throw new Error("InMemoryWalletRepository requires an address");
|
|
40
|
+
}
|
|
41
|
+
for (const vtxo of vtxos) {
|
|
42
|
+
if (!isVtxoForScript(vtxo, key.script)) {
|
|
43
|
+
throw new Error(`VTXO ${vtxo.txid}:${vtxo.vout} script mismatch: expected ${key.script}, got ${vtxo.script}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return this.saveVtxos(key.address, vtxos);
|
|
47
|
+
}
|
|
48
|
+
async deleteVtxosForScript(script) {
|
|
49
|
+
for (const [address, bucket] of this.vtxosByAddress.entries()) {
|
|
50
|
+
const next = bucket.filter((v) => !isVtxoForScript(v, script));
|
|
51
|
+
if (next.length === 0) {
|
|
52
|
+
this.vtxosByAddress.delete(address);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.vtxosByAddress.set(address, next);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
24
59
|
async getUtxos(address) {
|
|
25
60
|
return this.utxosByAddress.get(address) ?? [];
|
|
26
61
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export { MIGRATION_KEY, migrateWalletRepository, requiresMigration, getMigrationStatus, rollbackMigration, } from
|
|
1
|
+
export * from "./walletRepository.js";
|
|
2
|
+
export * from "./contractRepository.js";
|
|
3
|
+
export * from "./inMemory/walletRepository.js";
|
|
4
|
+
export * from "./inMemory/contractRepository.js";
|
|
5
|
+
export * from "./indexedDB/contractRepository.js";
|
|
6
|
+
export * from "./indexedDB/walletRepository.js";
|
|
7
|
+
export { MIGRATION_KEY, migrateWalletRepository, requiresMigration, getMigrationStatus, rollbackMigration, } from "./migrations/fromStorageAdapter.js";
|
|
8
8
|
// Deprecated
|
|
9
|
-
export { WalletRepositoryImpl } from
|
|
10
|
-
export { ContractRepositoryImpl } from
|
|
9
|
+
export { WalletRepositoryImpl } from "./migrations/walletRepositoryImpl.js";
|
|
10
|
+
export { ContractRepositoryImpl } from "./migrations/contractRepositoryImpl.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DB_VERSION, STORE_CONTRACTS } from
|
|
2
|
-
import { closeDatabase, openDatabase } from
|
|
3
|
-
import { initDatabase } from
|
|
4
|
-
import { DEFAULT_DB_NAME } from
|
|
1
|
+
import { DB_VERSION, STORE_CONTRACTS } from "./db.js";
|
|
2
|
+
import { closeDatabase, openDatabase } from "./manager.js";
|
|
3
|
+
import { initDatabase } from "./schema.js";
|
|
4
|
+
import { DEFAULT_DB_NAME } from "../../worker/browser/utils.js";
|
|
5
5
|
/**
|
|
6
6
|
* IndexedDB-based implementation of ContractRepository.
|
|
7
7
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DB_VERSION, STORE_CONTRACTS, LEGACY_STORE_CONTRACT_COLLECTIONS, STORE_TRANSACTIONS, STORE_UTXOS, STORE_VTXOS, STORE_WALLET_STATE, } from
|
|
1
|
+
import { DB_VERSION, STORE_CONTRACTS, LEGACY_STORE_CONTRACT_COLLECTIONS, STORE_TRANSACTIONS, STORE_UTXOS, STORE_VTXOS, STORE_WALLET_STATE, } from "./schema.js";
|
|
2
2
|
export { STORE_VTXOS, STORE_UTXOS, STORE_TRANSACTIONS, STORE_WALLET_STATE, STORE_CONTRACTS, LEGACY_STORE_CONTRACT_COLLECTIONS, DB_VERSION, };
|
|
3
3
|
// Serialization helpers (re-exported from shared module)
|
|
4
|
-
export { serializeTapLeaf, serializeVtxo, serializeUtxo, deserializeTapLeaf, deserializeVtxo, deserializeUtxo, } from
|
|
4
|
+
export { serializeTapLeaf, serializeVtxo, serializeUtxo, deserializeTapLeaf, deserializeVtxo, deserializeUtxo, } from "../serialization.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { scriptFromArkAddress } from
|
|
1
|
+
import { scriptFromArkAddress } from "../scriptFromAddress.js";
|
|
2
2
|
// Store names introduced in V2, they are all new to the migration
|
|
3
3
|
export const STORE_VTXOS = "vtxos";
|
|
4
4
|
export const STORE_UTXOS = "utxos";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { STORE_VTXOS, STORE_UTXOS, STORE_TRANSACTIONS, STORE_WALLET_STATE, serializeVtxo, serializeUtxo, deserializeVtxo, deserializeUtxo, DB_VERSION, } from
|
|
2
|
-
import { closeDatabase, openDatabase } from
|
|
3
|
-
import { initDatabase } from
|
|
4
|
-
import { scriptFromArkAddress } from
|
|
5
|
-
import { DEFAULT_DB_NAME } from
|
|
1
|
+
import { STORE_VTXOS, STORE_UTXOS, STORE_TRANSACTIONS, STORE_WALLET_STATE, serializeVtxo, serializeUtxo, deserializeVtxo, deserializeUtxo, DB_VERSION, } from "./db.js";
|
|
2
|
+
import { closeDatabase, openDatabase } from "./manager.js";
|
|
3
|
+
import { initDatabase } from "./schema.js";
|
|
4
|
+
import { scriptFromArkAddress } from "../scriptFromAddress.js";
|
|
5
|
+
import { DEFAULT_DB_NAME } from "../../worker/browser/utils.js";
|
|
6
|
+
import { isVtxoForScript } from "../../contracts/vtxoOwnership.js";
|
|
6
7
|
/**
|
|
7
8
|
* IndexedDB-based implementation of WalletRepository.
|
|
8
9
|
*/
|
|
@@ -141,6 +142,85 @@ export class IndexedDBWalletRepository {
|
|
|
141
142
|
throw error;
|
|
142
143
|
}
|
|
143
144
|
}
|
|
145
|
+
async getVtxosForScript(script) {
|
|
146
|
+
try {
|
|
147
|
+
const db = await this.getDB();
|
|
148
|
+
return new Promise((resolve, reject) => {
|
|
149
|
+
const transaction = db.transaction([STORE_VTXOS], "readonly");
|
|
150
|
+
const store = transaction.objectStore(STORE_VTXOS);
|
|
151
|
+
const index = store.index("script");
|
|
152
|
+
const request = index.getAll(script);
|
|
153
|
+
request.onerror = () => reject(request.error);
|
|
154
|
+
request.onsuccess = () => {
|
|
155
|
+
const results = request.result || [];
|
|
156
|
+
try {
|
|
157
|
+
// Defensive filter: only rows whose script matches.
|
|
158
|
+
const matching = results.filter((r) => r.script === script);
|
|
159
|
+
// Dedup same outpoint rows across address buckets.
|
|
160
|
+
// Work on raw rows so the address field is available
|
|
161
|
+
// for the canonicality tiebreaker.
|
|
162
|
+
const byOutpoint = new Map();
|
|
163
|
+
for (const row of matching) {
|
|
164
|
+
const outpoint = `${row.txid}:${row.vout}`;
|
|
165
|
+
const existing = byOutpoint.get(outpoint);
|
|
166
|
+
if (!existing) {
|
|
167
|
+
byOutpoint.set(outpoint, row);
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (shouldReplaceVtxo(existing, row)) {
|
|
171
|
+
byOutpoint.set(outpoint, row);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
resolve(Array.from(byOutpoint.values()).map(deserializeVtxoWithBackfill));
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
reject(err);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
console.error(`Failed to get VTXOs for script ${script}:`, error);
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
async saveVtxosForScript(key, vtxos) {
|
|
188
|
+
if (!key.address) {
|
|
189
|
+
throw new Error("IndexedDBWalletRepository requires an address");
|
|
190
|
+
}
|
|
191
|
+
for (const vtxo of vtxos) {
|
|
192
|
+
if (!isVtxoForScript(vtxo, key.script)) {
|
|
193
|
+
throw new Error(`VTXO ${vtxo.txid}:${vtxo.vout} script mismatch: expected ${key.script}, got ${vtxo.script}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return this.saveVtxos(key.address, vtxos);
|
|
197
|
+
}
|
|
198
|
+
async deleteVtxosForScript(script) {
|
|
199
|
+
try {
|
|
200
|
+
const db = await this.getDB();
|
|
201
|
+
return new Promise((resolve, reject) => {
|
|
202
|
+
const transaction = db.transaction([STORE_VTXOS], "readwrite");
|
|
203
|
+
const store = transaction.objectStore(STORE_VTXOS);
|
|
204
|
+
const index = store.index("script");
|
|
205
|
+
const request = index.openCursor(IDBKeyRange.only(script));
|
|
206
|
+
request.onerror = () => reject(request.error);
|
|
207
|
+
request.onsuccess = () => {
|
|
208
|
+
const cursor = request.result;
|
|
209
|
+
if (cursor) {
|
|
210
|
+
cursor.delete();
|
|
211
|
+
cursor.continue();
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
resolve();
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
console.error(`Failed to clear VTXOs for script ${script}:`, error);
|
|
221
|
+
throw error;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
144
224
|
async getUtxos(address) {
|
|
145
225
|
try {
|
|
146
226
|
const db = await this.getDB();
|
|
@@ -351,3 +431,40 @@ function deserializeVtxoWithBackfill(o) {
|
|
|
351
431
|
}
|
|
352
432
|
return deserializeVtxo(o);
|
|
353
433
|
}
|
|
434
|
+
function isCanonicalRow(row) {
|
|
435
|
+
try {
|
|
436
|
+
return scriptFromArkAddress(row.address) === row.script;
|
|
437
|
+
}
|
|
438
|
+
catch {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
function shouldReplaceVtxo(existing, incoming) {
|
|
443
|
+
const existingCanonical = isCanonicalRow(existing);
|
|
444
|
+
const incomingCanonical = isCanonicalRow(incoming);
|
|
445
|
+
if (incomingCanonical && !existingCanonical)
|
|
446
|
+
return true;
|
|
447
|
+
if (existingCanonical && !incomingCanonical)
|
|
448
|
+
return false;
|
|
449
|
+
// Tie on canonicality, check lifecycle completeness
|
|
450
|
+
const existingWeight = getLifecycleWeight(existing);
|
|
451
|
+
const incomingWeight = getLifecycleWeight(incoming);
|
|
452
|
+
if (incomingWeight > existingWeight)
|
|
453
|
+
return true;
|
|
454
|
+
if (existingWeight > incomingWeight)
|
|
455
|
+
return false;
|
|
456
|
+
// Tie on weight, stable sort by address
|
|
457
|
+
return incoming.address < existing.address;
|
|
458
|
+
}
|
|
459
|
+
function getLifecycleWeight(v) {
|
|
460
|
+
let weight = 0;
|
|
461
|
+
if (v.isSpent !== undefined)
|
|
462
|
+
weight += 1;
|
|
463
|
+
if (v.spentBy)
|
|
464
|
+
weight += 2;
|
|
465
|
+
if (v.settledBy)
|
|
466
|
+
weight += 2;
|
|
467
|
+
if (v.arkTxId)
|
|
468
|
+
weight += 2;
|
|
469
|
+
return weight;
|
|
470
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WalletRepositoryImpl } from
|
|
1
|
+
import { WalletRepositoryImpl } from "./walletRepositoryImpl.js";
|
|
2
2
|
export const MIGRATION_KEY = (repoType) => `migration-from-storage-adapter-${repoType}`;
|
|
3
3
|
export async function getMigrationStatus(repoType, storageAdapter) {
|
|
4
4
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hex } from "@scure/base";
|
|
2
2
|
import { TaprootControlBlock } from "@scure/btc-signer";
|
|
3
|
-
import { serializeAssets, deserializeAssets, serializeTransaction, deserializeTransaction, } from
|
|
3
|
+
import { serializeAssets, deserializeAssets, serializeTransaction, deserializeTransaction, } from "../serialization.js";
|
|
4
4
|
const getVtxosStorageKey = (address) => `vtxos:${address}`;
|
|
5
5
|
const getUtxosStorageKey = (address) => `utxos:${address}`;
|
|
6
6
|
const getTransactionsStorageKey = (address) => `tx:${address}`;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { RealmWalletRepository } from
|
|
2
|
-
export { RealmContractRepository } from
|
|
3
|
-
export { ArkRealmSchemas, ARK_REALM_SCHEMA_VERSION, runArkRealmMigrations, } from
|
|
1
|
+
export { RealmWalletRepository } from "./walletRepository.js";
|
|
2
|
+
export { RealmContractRepository } from "./contractRepository.js";
|
|
3
|
+
export { ArkRealmSchemas, ARK_REALM_SCHEMA_VERSION, runArkRealmMigrations, } from "./schemas.js";
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* schemas are defined as plain JS objects conforming to Realm's
|
|
9
9
|
* ObjectSchema shape.
|
|
10
10
|
*/
|
|
11
|
-
import { scriptFromArkAddress } from
|
|
11
|
+
import { scriptFromArkAddress } from "../scriptFromAddress.js";
|
|
12
12
|
export const ArkVtxoSchema = {
|
|
13
13
|
name: "ArkVtxo",
|
|
14
14
|
primaryKey: "pk",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { serializeVtxo, serializeUtxo, deserializeVtxo, deserializeUtxo, serializeAssets, deserializeAssets, } from
|
|
2
|
-
import { scriptFromArkAddress } from
|
|
1
|
+
import { serializeVtxo, serializeUtxo, deserializeVtxo, deserializeUtxo, serializeAssets, deserializeAssets, } from "../serialization.js";
|
|
2
|
+
import { scriptFromArkAddress } from "../scriptFromAddress.js";
|
|
3
|
+
import { isVtxoForScript } from "../../contracts/vtxoOwnership.js";
|
|
3
4
|
/**
|
|
4
5
|
* Realm-based implementation of WalletRepository.
|
|
5
6
|
*
|
|
@@ -85,6 +86,33 @@ export class RealmWalletRepository {
|
|
|
85
86
|
this.realm.delete(toDelete);
|
|
86
87
|
});
|
|
87
88
|
}
|
|
89
|
+
async getVtxosForScript(script) {
|
|
90
|
+
await this.ensureInit();
|
|
91
|
+
const results = this.realm
|
|
92
|
+
.objects("ArkVtxo")
|
|
93
|
+
.filtered("script == $0", script);
|
|
94
|
+
return [...results].map(vtxoObjectToDomain);
|
|
95
|
+
}
|
|
96
|
+
async saveVtxosForScript(key, vtxos) {
|
|
97
|
+
if (!key.address) {
|
|
98
|
+
throw new Error("RealmWalletRepository requires an address");
|
|
99
|
+
}
|
|
100
|
+
for (const vtxo of vtxos) {
|
|
101
|
+
if (!isVtxoForScript(vtxo, key.script)) {
|
|
102
|
+
throw new Error(`VTXO ${vtxo.txid}:${vtxo.vout} script mismatch: expected ${key.script}, got ${vtxo.script}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return this.saveVtxos(key.address, vtxos);
|
|
106
|
+
}
|
|
107
|
+
async deleteVtxosForScript(script) {
|
|
108
|
+
await this.ensureInit();
|
|
109
|
+
this.realm.write(() => {
|
|
110
|
+
const toDelete = this.realm
|
|
111
|
+
.objects("ArkVtxo")
|
|
112
|
+
.filtered("script == $0", script);
|
|
113
|
+
this.realm.delete(toDelete);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
88
116
|
// ── UTXO management ────────────────────────────────────────────────
|
|
89
117
|
async getUtxos(address) {
|
|
90
118
|
await this.ensureInit();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hex } from "@scure/base";
|
|
2
|
-
import { ArkAddress } from
|
|
2
|
+
import { ArkAddress } from "../index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Compute the hex-encoded `scriptPubKey` locking a VTXO from its owning Ark
|
|
5
5
|
* address. Used by repository-layer migrations to backfill `script` on legacy
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { SQLiteWalletRepository } from
|
|
2
|
-
export { SQLiteContractRepository } from
|
|
1
|
+
export { SQLiteWalletRepository } from "./walletRepository.js";
|
|
2
|
+
export { SQLiteContractRepository } from "./contractRepository.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { serializeVtxo, serializeUtxo, deserializeVtxo, deserializeUtxo, serializeAssets, deserializeAssets, } from
|
|
2
|
-
import { scriptFromArkAddress } from
|
|
1
|
+
import { serializeVtxo, serializeUtxo, deserializeVtxo, deserializeUtxo, serializeAssets, deserializeAssets, } from "../serialization.js";
|
|
2
|
+
import { scriptFromArkAddress } from "../scriptFromAddress.js";
|
|
3
|
+
import { isVtxoForScript } from "../../contracts/vtxoOwnership.js";
|
|
3
4
|
/**
|
|
4
5
|
* SQLite-based implementation of WalletRepository.
|
|
5
6
|
*
|
|
@@ -242,6 +243,28 @@ export class SQLiteWalletRepository {
|
|
|
242
243
|
await this.ensureInit();
|
|
243
244
|
await this.db.run(`DELETE FROM ${this.tables.vtxos} WHERE address = ?`, [address]);
|
|
244
245
|
}
|
|
246
|
+
async getVtxosForScript(script) {
|
|
247
|
+
await this.ensureInit();
|
|
248
|
+
const rows = await this.db.all(`SELECT * FROM ${this.tables.vtxos} WHERE script = ?`, [script]);
|
|
249
|
+
return rows.map(vtxoRowToDomain);
|
|
250
|
+
}
|
|
251
|
+
async saveVtxosForScript(key, vtxos) {
|
|
252
|
+
if (!key.address) {
|
|
253
|
+
throw new Error("SQLiteWalletRepository requires an address");
|
|
254
|
+
}
|
|
255
|
+
for (const vtxo of vtxos) {
|
|
256
|
+
if (!isVtxoForScript(vtxo, key.script)) {
|
|
257
|
+
throw new Error(`VTXO ${vtxo.txid}:${vtxo.vout} script mismatch: expected ${key.script}, got ${vtxo.script}`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return this.saveVtxos(key.address, vtxos);
|
|
261
|
+
}
|
|
262
|
+
async deleteVtxosForScript(script) {
|
|
263
|
+
await this.ensureInit();
|
|
264
|
+
await this.db.run(`DELETE FROM ${this.tables.vtxos} WHERE script = ?`, [
|
|
265
|
+
script,
|
|
266
|
+
]);
|
|
267
|
+
}
|
|
245
268
|
// ── UTXO management ────────────────────────────────────────────────
|
|
246
269
|
async getUtxos(address) {
|
|
247
270
|
await this.ensureInit();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { bech32m } from "@scure/base";
|
|
2
2
|
import { Script } from "@scure/btc-signer/script.js";
|
|
3
|
-
import { DEFAULT_ARKADE_HRP } from
|
|
3
|
+
import { DEFAULT_ARKADE_HRP } from "../wallet/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* ArkAddress allows creating and decoding bech32m-encoded Arkade addresses.
|
|
6
6
|
*
|
|
@@ -32,10 +32,10 @@ import { DEFAULT_ARKADE_HRP } from '../wallet/index.js';
|
|
|
32
32
|
*/
|
|
33
33
|
export class ArkAddress {
|
|
34
34
|
/**
|
|
35
|
-
* Create an Arkade address from its server key,
|
|
35
|
+
* Create an Arkade address from its server public key, Taproot output key, and prefix.
|
|
36
36
|
*
|
|
37
37
|
* @param serverPubKey - 32-byte Arkade server public key
|
|
38
|
-
* @param vtxoTaprootKey - 32-byte
|
|
38
|
+
* @param vtxoTaprootKey - 32-byte Taproot output key (a.k.a. tweaked public key)
|
|
39
39
|
* @param hrp - Bech32 human-readable prefix
|
|
40
40
|
* @param version - Address version byte
|
|
41
41
|
* @defaultValue `version = 0`
|
package/dist/esm/script/base.js
CHANGED
|
@@ -2,9 +2,9 @@ import { Script, Address, p2tr, taprootListToTree, TAPROOT_UNSPENDABLE_KEY, } fr
|
|
|
2
2
|
import { TAP_LEAF_VERSION } from "@scure/btc-signer/payment.js";
|
|
3
3
|
import { PSBTOutput } from "@scure/btc-signer/psbt.js";
|
|
4
4
|
import { hex } from "@scure/base";
|
|
5
|
-
import { ArkAddress } from
|
|
6
|
-
import { timelockToSequence } from
|
|
7
|
-
import { CLTVMultisigTapscript, ConditionCSVMultisigTapscript, CSVMultisigTapscript, } from
|
|
5
|
+
import { ArkAddress } from "./address.js";
|
|
6
|
+
import { timelockToSequence } from "../utils/timelock.js";
|
|
7
|
+
import { CLTVMultisigTapscript, ConditionCSVMultisigTapscript, CSVMultisigTapscript, } from "./tapscript.js";
|
|
8
8
|
export const TapTreeCoder = PSBTOutput.tapTree[2];
|
|
9
9
|
export function scriptFromTapLeafScript(leaf) {
|
|
10
10
|
return leaf[1].subarray(0, leaf[1].length - 1); // remove the version byte
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { VtxoScript } from
|
|
2
|
-
import { CSVMultisigTapscript, MultisigTapscript, } from
|
|
1
|
+
import { VtxoScript } from "./base.js";
|
|
2
|
+
import { CSVMultisigTapscript, MultisigTapscript, } from "./tapscript.js";
|
|
3
3
|
import { hex } from "@scure/base";
|
|
4
4
|
/**
|
|
5
5
|
* DefaultVtxo is the default implementation of a VtxoScript.
|