@arkade-os/sdk 0.4.26 → 0.4.27
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 +5 -25
- package/dist/cjs/contracts/contractManager.js +31 -11
- package/dist/cjs/contracts/contractWatcher.js +2 -2
- package/dist/cjs/identity/hdCapableIdentity.js +18 -0
- package/dist/cjs/identity/index.js +3 -1
- package/dist/cjs/identity/seedIdentity.js +16 -0
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/wallet/delegator.js +10 -4
- package/dist/cjs/wallet/hdDescriptorProvider.js +29 -0
- package/dist/cjs/wallet/inputSignerRouter.js +98 -0
- package/dist/cjs/wallet/serviceWorker/wallet.js +1 -0
- package/dist/cjs/wallet/signingErrors.js +32 -0
- package/dist/cjs/wallet/unroll.js +5 -1
- package/dist/cjs/wallet/wallet.js +232 -86
- package/dist/cjs/wallet/walletReceiveRotator.js +547 -0
- package/dist/cjs/worker/messageBus.js +1 -0
- package/dist/esm/contracts/contractManager.js +31 -11
- package/dist/esm/contracts/contractWatcher.js +2 -2
- package/dist/esm/identity/hdCapableIdentity.js +17 -1
- package/dist/esm/identity/index.js +1 -0
- package/dist/esm/identity/seedIdentity.js +16 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/wallet/delegator.js +10 -4
- package/dist/esm/wallet/hdDescriptorProvider.js +29 -0
- package/dist/esm/wallet/inputSignerRouter.js +94 -0
- package/dist/esm/wallet/serviceWorker/wallet.js +1 -0
- package/dist/esm/wallet/signingErrors.js +27 -0
- package/dist/esm/wallet/unroll.js +5 -1
- package/dist/esm/wallet/wallet.js +231 -86
- package/dist/esm/wallet/walletReceiveRotator.js +540 -0
- package/dist/esm/worker/messageBus.js +1 -0
- package/dist/types/contracts/contractManager.d.ts +33 -3
- package/dist/types/contracts/types.d.ts +19 -2
- package/dist/types/identity/descriptorProvider.d.ts +7 -0
- package/dist/types/identity/hdCapableIdentity.d.ts +30 -3
- package/dist/types/identity/index.d.ts +1 -0
- package/dist/types/identity/seedIdentity.d.ts +16 -0
- package/dist/types/index.d.ts +6 -6
- package/dist/types/wallet/hdDescriptorProvider.d.ts +22 -1
- package/dist/types/wallet/index.d.ts +34 -0
- package/dist/types/wallet/inputSignerRouter.d.ts +35 -0
- package/dist/types/wallet/serviceWorker/wallet.d.ts +10 -0
- package/dist/types/wallet/signingErrors.d.ts +19 -0
- package/dist/types/wallet/wallet.d.ts +51 -2
- package/dist/types/wallet/walletReceiveRotator.d.ts +306 -0
- package/dist/types/worker/messageBus.d.ts +1 -0
- package/package.json +1 -1
|
@@ -19,7 +19,13 @@ export interface ReadonlyHDCapableIdentity extends ReadonlyIdentity {
|
|
|
19
19
|
* concrete descriptor by replacing the `*` with a derivation index.
|
|
20
20
|
*/
|
|
21
21
|
readonly descriptor: string;
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* True iff `descriptor` derives from this identity's xpub/seed.
|
|
24
|
+
*
|
|
25
|
+
* @deprecated Prefer `DescriptorProvider.isOurs()` via
|
|
26
|
+
* `HDDescriptorProvider` for rotating HD wallets or
|
|
27
|
+
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
28
|
+
*/
|
|
23
29
|
isOurs(descriptor: string): boolean;
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
@@ -37,8 +43,29 @@ export interface ReadonlyHDCapableIdentity extends ReadonlyIdentity {
|
|
|
37
43
|
* explicitly-non-rotating use cases.
|
|
38
44
|
*/
|
|
39
45
|
export interface HDCapableIdentity extends ReadonlyHDCapableIdentity, Identity {
|
|
40
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Signs each request with the key derived from its descriptor.
|
|
48
|
+
*
|
|
49
|
+
* @deprecated Prefer `DescriptorProvider.signWithDescriptor()` via
|
|
50
|
+
* `HDDescriptorProvider` or `StaticDescriptorProvider`. Identities keep
|
|
51
|
+
* this method only as backing implementation for descriptor providers.
|
|
52
|
+
*/
|
|
41
53
|
signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
|
|
42
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Signs a message using the key derived from `descriptor`.
|
|
56
|
+
*
|
|
57
|
+
* @deprecated Prefer `DescriptorProvider.signMessageWithDescriptor()` via
|
|
58
|
+
* `HDDescriptorProvider` or `StaticDescriptorProvider`. Identities keep
|
|
59
|
+
* this method only as backing implementation for descriptor providers.
|
|
60
|
+
*/
|
|
43
61
|
signMessageWithDescriptor(descriptor: string, message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
44
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Structural type guard for {@link HDCapableIdentity}. Returns `true`
|
|
65
|
+
* when the value exposes the four members the HD wallet flow relies on:
|
|
66
|
+
* `descriptor`, `isOurs`, `signWithDescriptor`, and
|
|
67
|
+
* `signMessageWithDescriptor`. Used by callers that need to opt into
|
|
68
|
+
* the HD path (e.g. installing an `HDDescriptorProvider`) without
|
|
69
|
+
* coupling to a concrete identity class.
|
|
70
|
+
*/
|
|
71
|
+
export declare function isHDCapableIdentity(value: unknown): value is HDCapableIdentity;
|
|
@@ -53,4 +53,5 @@ export { isDescriptor, normalizeToDescriptor, extractPubKey, parseHDDescriptor,
|
|
|
53
53
|
export type { ParsedHDDescriptor } from "./descriptor.js";
|
|
54
54
|
export type { DescriptorProvider, DescriptorSigningRequest, } from "./descriptorProvider.js";
|
|
55
55
|
export type { HDCapableIdentity, ReadonlyHDCapableIdentity, } from "./hdCapableIdentity.js";
|
|
56
|
+
export { isHDCapableIdentity } from "./hdCapableIdentity.js";
|
|
56
57
|
export { StaticDescriptorProvider } from "./staticDescriptorProvider.js";
|
|
@@ -117,15 +117,27 @@ export declare class SeedIdentity implements HDCapableIdentity {
|
|
|
117
117
|
* Returns true when `descriptor` is derived from this identity's seed.
|
|
118
118
|
* HD descriptors match by account xpub; bare `tr(pubkey)` descriptors
|
|
119
119
|
* match by raw pubkey. See {@link descriptorIsOurs}.
|
|
120
|
+
*
|
|
121
|
+
* @deprecated Prefer `DescriptorProvider.isOurs()` via
|
|
122
|
+
* `HDDescriptorProvider` for rotating HD wallets or
|
|
123
|
+
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
120
124
|
*/
|
|
121
125
|
isOurs(descriptor: string): boolean;
|
|
122
126
|
/**
|
|
123
127
|
* Signs each request with the key derived from its descriptor.
|
|
124
128
|
* Each descriptor must share this identity's seed ({@link isOurs}).
|
|
129
|
+
*
|
|
130
|
+
* @deprecated Prefer `DescriptorProvider.signWithDescriptor()` via
|
|
131
|
+
* `HDDescriptorProvider` or `StaticDescriptorProvider`. Identities keep
|
|
132
|
+
* this method only as backing implementation for descriptor providers.
|
|
125
133
|
*/
|
|
126
134
|
signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
|
|
127
135
|
/**
|
|
128
136
|
* Signs a message with the key derived from `descriptor`.
|
|
137
|
+
*
|
|
138
|
+
* @deprecated Prefer `DescriptorProvider.signMessageWithDescriptor()` via
|
|
139
|
+
* `HDDescriptorProvider` or `StaticDescriptorProvider`. Identities keep
|
|
140
|
+
* this method only as backing implementation for descriptor providers.
|
|
129
141
|
*/
|
|
130
142
|
signMessageWithDescriptor(descriptor: string, message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
131
143
|
private derivePrivateKeyForDescriptor;
|
|
@@ -212,6 +224,10 @@ export declare class ReadonlyDescriptorIdentity implements ReadonlyHDCapableIden
|
|
|
212
224
|
* HD descriptors match by account xpub; bare `tr(pubkey)` descriptors
|
|
213
225
|
* fall back to comparing against the index-0 x-only pubkey. See
|
|
214
226
|
* {@link descriptorIsOurs}.
|
|
227
|
+
*
|
|
228
|
+
* @deprecated Prefer `DescriptorProvider.isOurs()` via
|
|
229
|
+
* `HDDescriptorProvider` for rotating HD wallets or
|
|
230
|
+
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
215
231
|
*/
|
|
216
232
|
isOurs(descriptor: string): boolean;
|
|
217
233
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,9 +9,9 @@ import { DefaultVtxo } from "./script/default.js";
|
|
|
9
9
|
import { DelegateVtxo } from "./script/delegate.js";
|
|
10
10
|
import { MessageHandler, RequestEnvelope, ResponseEnvelope, MessageBus } from "./worker/messageBus.js";
|
|
11
11
|
import { VtxoScript, EncodedVtxoScript, TapLeafScript, TapTreeCoder, getSequence } from "./script/base.js";
|
|
12
|
-
import { TxType, IWallet, IReadonlyWallet, BaseWalletConfig, WalletConfig, ReadonlyWalletConfig, ProviderClass, ArkTransaction, Coin, ExtendedCoin, ExtendedVirtualCoin, WalletBalance, SendBitcoinParams, SettleParams, Status, VirtualStatus, Outpoint, VirtualCoin, TxKey, GetVtxosFilter, TapLeaves, StorageConfig, isSpendable, isSubdust, isRecoverable, isExpired, Asset, Recipient, IssuanceParams, IssuanceResult, ReissuanceParams, BurnParams, AssetDetails, AssetMetadata, KnownMetadata } from "./wallet/index.js";
|
|
12
|
+
import { TxType, IWallet, IReadonlyWallet, BaseWalletConfig, WalletConfig, WalletMode, ReadonlyWalletConfig, ProviderClass, ArkTransaction, Coin, ExtendedCoin, ExtendedVirtualCoin, WalletBalance, SendBitcoinParams, SettleParams, Status, VirtualStatus, Outpoint, VirtualCoin, TxKey, GetVtxosFilter, TapLeaves, StorageConfig, isSpendable, isSubdust, isRecoverable, isExpired, Asset, Recipient, IssuanceParams, IssuanceResult, ReissuanceParams, BurnParams, AssetDetails, AssetMetadata, KnownMetadata } from "./wallet/index.js";
|
|
13
13
|
import { Batch } from "./wallet/batch.js";
|
|
14
|
-
import { Wallet, ReadonlyWallet, waitForIncomingFunds, IncomingFunds } from "./wallet/wallet.js";
|
|
14
|
+
import { Wallet, ReadonlyWallet, waitForIncomingFunds, IncomingFunds, DescriptorSigningProviderMissingError, MissingSigningDescriptorError } from "./wallet/wallet.js";
|
|
15
15
|
import { TxTree, TxTreeNode } from "./tree/txTree.js";
|
|
16
16
|
import { SignerSession, TreeNonces, TreePartialSigs } from "./tree/signingSession.js";
|
|
17
17
|
import { Ramps } from "./wallet/ramps.js";
|
|
@@ -19,7 +19,7 @@ import { HDDescriptorProvider } from "./wallet/hdDescriptorProvider.js";
|
|
|
19
19
|
import { isVtxoExpiringSoon, VtxoManager } from "./wallet/vtxo-manager.js";
|
|
20
20
|
import type { IVtxoManager, SettlementConfig } from "./wallet/vtxo-manager.js";
|
|
21
21
|
import { ServiceWorkerWallet, ServiceWorkerReadonlyWallet, DEFAULT_MESSAGE_TIMEOUTS } from "./wallet/serviceWorker/wallet.js";
|
|
22
|
-
import type { MessageTimeouts } from "./wallet/serviceWorker/wallet.js";
|
|
22
|
+
import type { MessageTimeouts, ServiceWorkerWalletMode } from "./wallet/serviceWorker/wallet.js";
|
|
23
23
|
import { OnchainWallet } from "./wallet/onchain.js";
|
|
24
24
|
import { setupServiceWorker } from "./worker/browser/utils.js";
|
|
25
25
|
import { ESPLORA_URL, EsploraProvider, OnchainProvider, ExplorerTransaction } from "./providers/onchain.js";
|
|
@@ -49,11 +49,11 @@ import { DelegatorManagerImpl, IDelegatorManager } from "./wallet/delegator.js";
|
|
|
49
49
|
export * from "./arkfee/index.js";
|
|
50
50
|
export * as asset from "./extension/asset/index.js";
|
|
51
51
|
import { ContractManager, ContractWatcher, contractHandlers, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, encodeArkContract, decodeArkContract, contractFromArkContract, contractFromArkContractWithAddress, isArkContract } from "./contracts/index.js";
|
|
52
|
-
import type { Contract, ContractVtxo, ContractState, ContractEvent, ContractEventCallback, ContractBalance, ContractWithVtxos, ContractHandler, PathSelection, PathContext, ContractManagerConfig, CreateContractParams, ContractWatcherConfig, ParsedArkContract, DefaultContractParams, DelegateContractParams, VHTLCContractParams } from "./contracts/index.js";
|
|
52
|
+
import type { Contract, ContractVtxo, ContractState, ContractEvent, ContractEventCallback, ContractBalance, ContractWithVtxos, ContractHandler, PathSelection, PathContext, ExtendedContractVtxo, ContractManagerConfig, CreateContractParams, ContractWatcherConfig, ParsedArkContract, DefaultContractParams, DelegateContractParams, VHTLCContractParams } from "./contracts/index.js";
|
|
53
53
|
import { IContractManager } from "./contracts/contractManager.js";
|
|
54
54
|
import { timelockToSequence, sequenceToTimelock } from "./utils/timelock.js";
|
|
55
55
|
import { closeDatabase, openDatabase } from "./repositories/indexedDB/manager.js";
|
|
56
56
|
import { WalletMessageHandler, WalletNotInitializedError, ReadonlyWalletError, DelegatorNotConfiguredError } from "./wallet/serviceWorker/wallet-message-handler.js";
|
|
57
57
|
import { MESSAGE_BUS_NOT_INITIALIZED, MessageBusNotInitializedError, ServiceWorkerTimeoutError } from "./worker/errors.js";
|
|
58
|
-
export { Wallet, ReadonlyWallet, SingleKey, ReadonlySingleKey, SeedIdentity, MnemonicIdentity, ReadonlyDescriptorIdentity, isBatchSignable, OnchainWallet, Ramps, VtxoManager, HDDescriptorProvider, DelegatorManagerImpl, RestDelegatorProvider, ESPLORA_URL, EsploraProvider, ELECTRUM_WS_URL, ELECTRUM_TCP_HOST, ElectrumOnchainProvider, WsElectrumChainSource, RestArkProvider, RestIndexerProvider, ArkAddress, DefaultVtxo, DelegateVtxo, VtxoScript, VHTLC, TxType, IndexerTxType, ChainTxType, SettlementEventType, setupServiceWorker, MessageBus, WalletMessageHandler, WalletNotInitializedError, ReadonlyWalletError, DelegatorNotConfiguredError, MESSAGE_BUS_NOT_INITIALIZED, MessageBusNotInitializedError, ServiceWorkerTimeoutError, ServiceWorkerWallet, ServiceWorkerReadonlyWallet, DEFAULT_MESSAGE_TIMEOUTS, decodeTapscript, MultisigTapscript, CSVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, CLTVMultisigTapscript, TapTreeCoder, ArkPsbtFieldKey, ArkPsbtFieldKeyType, setArkPsbtField, getArkPsbtFields, CosignerPublicKey, VtxoTreeExpiry, VtxoTaprootTree, ConditionWitness, buildOffchainTx, verifyTapscriptSignatures, waitForIncomingFunds, hasBoardingTxExpired, combineTapscriptSigs, isVtxoExpiringSoon, isValidArkAddress, ArkNote, networks, closeDatabase, openDatabase, IndexedDBWalletRepository, IndexedDBContractRepository, InMemoryWalletRepository, InMemoryContractRepository, MIGRATION_KEY, migrateWalletRepository, requiresMigration, getMigrationStatus, rollbackMigration, WalletRepositoryImpl, ContractRepositoryImpl, Intent, BIP322, TxTree, P2A, Unroll, Transaction, TxWeightEstimator, timelockToSequence, sequenceToTimelock, ArkError, maybeArkError, Batch, validateVtxoTxGraph, validateConnectorsTxGraph, buildForfeitTx, isRecoverable, isSpendable, isSubdust, isExpired, getSequence, ContractManager, ContractWatcher, contractHandlers, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, encodeArkContract, decodeArkContract, contractFromArkContract, contractFromArkContractWithAddress, isArkContract, };
|
|
59
|
-
export type { Identity, ReadonlyIdentity, BatchSignableIdentity, SignRequest, IWallet, IReadonlyWallet, BaseWalletConfig, WalletConfig, ReadonlyWalletConfig, ProviderClass, ArkTransaction, Coin, ExtendedCoin, ExtendedVirtualCoin, WalletBalance, SendBitcoinParams, SettleParams, Status, VirtualStatus, Outpoint, VirtualCoin, TxKey, TapscriptType, ArkTxInput, OffchainTx, TapLeaves, IncomingFunds, SeedIdentityOptions, MnemonicOptions, NetworkOptions, DescriptorOptions, IndexerProvider, PageResponse, BatchInfo, ChainTx, CommitmentTx, TxHistoryRecord, Vtxo, VtxoChain, Tx, OnchainProvider, ArkProvider, SettlementEvent, FeeInfo, ArkInfo, SignedIntent, Output, TxNotification, ExplorerTransaction, ElectrumTransactionHistory, ElectrumBlockHeader, ElectrumUnspent, BatchFinalizationEvent, BatchFinalizedEvent, BatchFailedEvent, TreeSigningStartedEvent, TreeNoncesEvent, BatchStartedEvent, TreeTxEvent, TreeSignatureEvent, ScheduledSession, PaginationOptions, SubscriptionResponse, SubscriptionHeartbeat, SubscriptionEvent, Network, NetworkName, ArkTapscript, RelativeTimelock, EncodedVtxoScript, TapLeafScript, SignerSession, TreeNonces, TreePartialSigs, GetVtxosFilter, SettlementConfig, IVtxoManager, Asset, Recipient, IssuanceParams, IssuanceResult, ReissuanceParams, BurnParams, AssetDetails, AssetMetadata, KnownMetadata, Nonces, PartialSig, ArkPsbtFieldCoder, TxTreeNode, AnchorBumper, VSize, StorageConfig, Contract, ContractVtxo, ContractState, ContractEvent, ContractEventCallback, ContractBalance, ContractWithVtxos, ContractHandler, IContractManager, PathSelection, PathContext, ContractManagerConfig, CreateContractParams, ContractWatcherConfig, ParsedArkContract, DefaultContractParams, DelegateContractParams, VHTLCContractParams, MessageHandler, RequestEnvelope, ResponseEnvelope, MessageTimeouts, IDelegatorManager, DelegatorProvider, DelegateInfo, DelegateOptions, WalletRepository, ContractRepository, MigrationStatus, };
|
|
58
|
+
export { Wallet, ReadonlyWallet, SingleKey, ReadonlySingleKey, SeedIdentity, MnemonicIdentity, ReadonlyDescriptorIdentity, isBatchSignable, OnchainWallet, Ramps, VtxoManager, HDDescriptorProvider, DelegatorManagerImpl, RestDelegatorProvider, ESPLORA_URL, EsploraProvider, ELECTRUM_WS_URL, ELECTRUM_TCP_HOST, ElectrumOnchainProvider, WsElectrumChainSource, RestArkProvider, RestIndexerProvider, ArkAddress, DefaultVtxo, DelegateVtxo, VtxoScript, VHTLC, TxType, IndexerTxType, ChainTxType, SettlementEventType, setupServiceWorker, MessageBus, WalletMessageHandler, WalletNotInitializedError, ReadonlyWalletError, DelegatorNotConfiguredError, MESSAGE_BUS_NOT_INITIALIZED, MessageBusNotInitializedError, ServiceWorkerTimeoutError, ServiceWorkerWallet, ServiceWorkerReadonlyWallet, DEFAULT_MESSAGE_TIMEOUTS, decodeTapscript, MultisigTapscript, CSVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, CLTVMultisigTapscript, TapTreeCoder, ArkPsbtFieldKey, ArkPsbtFieldKeyType, setArkPsbtField, getArkPsbtFields, CosignerPublicKey, VtxoTreeExpiry, VtxoTaprootTree, ConditionWitness, buildOffchainTx, verifyTapscriptSignatures, waitForIncomingFunds, hasBoardingTxExpired, combineTapscriptSigs, isVtxoExpiringSoon, isValidArkAddress, ArkNote, networks, closeDatabase, openDatabase, IndexedDBWalletRepository, IndexedDBContractRepository, InMemoryWalletRepository, InMemoryContractRepository, MIGRATION_KEY, migrateWalletRepository, requiresMigration, getMigrationStatus, rollbackMigration, WalletRepositoryImpl, ContractRepositoryImpl, Intent, BIP322, TxTree, P2A, Unroll, Transaction, TxWeightEstimator, timelockToSequence, sequenceToTimelock, ArkError, maybeArkError, DescriptorSigningProviderMissingError, MissingSigningDescriptorError, Batch, validateVtxoTxGraph, validateConnectorsTxGraph, buildForfeitTx, isRecoverable, isSpendable, isSubdust, isExpired, getSequence, ContractManager, ContractWatcher, contractHandlers, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, encodeArkContract, decodeArkContract, contractFromArkContract, contractFromArkContractWithAddress, isArkContract, };
|
|
59
|
+
export type { Identity, ReadonlyIdentity, BatchSignableIdentity, SignRequest, IWallet, IReadonlyWallet, BaseWalletConfig, WalletConfig, WalletMode, ReadonlyWalletConfig, ProviderClass, ArkTransaction, Coin, ExtendedCoin, ExtendedVirtualCoin, WalletBalance, SendBitcoinParams, SettleParams, Status, VirtualStatus, Outpoint, VirtualCoin, TxKey, TapscriptType, ArkTxInput, OffchainTx, TapLeaves, IncomingFunds, SeedIdentityOptions, MnemonicOptions, NetworkOptions, DescriptorOptions, IndexerProvider, PageResponse, BatchInfo, ChainTx, CommitmentTx, TxHistoryRecord, Vtxo, VtxoChain, Tx, OnchainProvider, ArkProvider, SettlementEvent, FeeInfo, ArkInfo, SignedIntent, Output, TxNotification, ExplorerTransaction, ElectrumTransactionHistory, ElectrumBlockHeader, ElectrumUnspent, BatchFinalizationEvent, BatchFinalizedEvent, BatchFailedEvent, TreeSigningStartedEvent, TreeNoncesEvent, BatchStartedEvent, TreeTxEvent, TreeSignatureEvent, ScheduledSession, PaginationOptions, SubscriptionResponse, SubscriptionHeartbeat, SubscriptionEvent, Network, NetworkName, ArkTapscript, RelativeTimelock, EncodedVtxoScript, TapLeafScript, SignerSession, TreeNonces, TreePartialSigs, GetVtxosFilter, SettlementConfig, IVtxoManager, Asset, Recipient, IssuanceParams, IssuanceResult, ReissuanceParams, BurnParams, AssetDetails, AssetMetadata, KnownMetadata, Nonces, PartialSig, ArkPsbtFieldCoder, TxTreeNode, AnchorBumper, VSize, StorageConfig, Contract, ContractVtxo, ContractState, ContractEvent, ContractEventCallback, ContractBalance, ContractWithVtxos, ContractHandler, IContractManager, PathSelection, ExtendedContractVtxo, PathContext, ContractManagerConfig, CreateContractParams, ContractWatcherConfig, ParsedArkContract, DefaultContractParams, DelegateContractParams, VHTLCContractParams, MessageHandler, RequestEnvelope, ResponseEnvelope, MessageTimeouts, ServiceWorkerWalletMode, IDelegatorManager, DelegatorProvider, DelegateInfo, DelegateOptions, WalletRepository, ContractRepository, MigrationStatus, };
|
|
@@ -2,6 +2,7 @@ import { DescriptorProvider, DescriptorSigningRequest } from "../identity/descri
|
|
|
2
2
|
import { HDCapableIdentity } from "../identity/hdCapableIdentity.js";
|
|
3
3
|
import { WalletRepository } from "../repositories/walletRepository.js";
|
|
4
4
|
import { Transaction } from "../utils/transaction.js";
|
|
5
|
+
import { ReceiveRotatorBoot, ReceiveRotatorBootOpts, ReceiveRotatorFactory } from "./walletReceiveRotator.js";
|
|
5
6
|
/**
|
|
6
7
|
* HD-wallet {@link DescriptorProvider} that allocates a fresh signing
|
|
7
8
|
* descriptor on every call. The provider holds no notion of "current" — it
|
|
@@ -29,7 +30,7 @@ import { Transaction } from "../utils/transaction.js";
|
|
|
29
30
|
* // next: tr([fp/86'/0'/0']xpub/0/1)
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
|
-
export declare class HDDescriptorProvider implements DescriptorProvider {
|
|
33
|
+
export declare class HDDescriptorProvider implements DescriptorProvider, ReceiveRotatorFactory {
|
|
33
34
|
private readonly identity;
|
|
34
35
|
private readonly walletRepository;
|
|
35
36
|
private constructor();
|
|
@@ -48,6 +49,19 @@ export declare class HDDescriptorProvider implements DescriptorProvider {
|
|
|
48
49
|
* index.
|
|
49
50
|
*/
|
|
50
51
|
getNextSigningDescriptor(): Promise<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Re-derive the descriptor at the most recently allocated index
|
|
54
|
+
* WITHOUT advancing — i.e. read the same descriptor
|
|
55
|
+
* `getNextSigningDescriptor` last returned. Returns `undefined`
|
|
56
|
+
* when no descriptor has ever been allocated on this repo.
|
|
57
|
+
*
|
|
58
|
+
* Used by the boot path to keep the wallet's display address
|
|
59
|
+
* stable across restarts: when no tagged display contract exists
|
|
60
|
+
* (e.g. a fresh wallet that hasn't rotated yet, or a wallet whose
|
|
61
|
+
* baseline-only repo carries no rotation history), the boot should
|
|
62
|
+
* re-derive the existing index rather than burn a new one.
|
|
63
|
+
*/
|
|
64
|
+
getCurrentSigningDescriptor(): Promise<string | undefined>;
|
|
51
65
|
/**
|
|
52
66
|
* Returns true when the given descriptor is derivable from this wallet's
|
|
53
67
|
* seed. Delegates to the underlying identity, which handles both HD and
|
|
@@ -62,6 +76,13 @@ export declare class HDDescriptorProvider implements DescriptorProvider {
|
|
|
62
76
|
signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
|
|
63
77
|
/** Signs a message using the key derived from `descriptor`. */
|
|
64
78
|
signMessageWithDescriptor(descriptor: string, message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
79
|
+
/**
|
|
80
|
+
* HD providers participate in receive rotation. The default
|
|
81
|
+
* factory boot (contract-repo lookup → allocate fresh descriptor)
|
|
82
|
+
* is exactly what we want, so this just delegates to
|
|
83
|
+
* {@link WalletReceiveRotator.defaultBoot}.
|
|
84
|
+
*/
|
|
85
|
+
createReceiveRotator(opts: ReceiveRotatorBootOpts): Promise<ReceiveRotatorBoot | undefined>;
|
|
65
86
|
/**
|
|
66
87
|
* Substitute the wildcard in the identity's account-descriptor template
|
|
67
88
|
* with a concrete index, going through the descriptors-scure parser
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Bytes } from "@scure/btc-signer/utils.js";
|
|
2
2
|
import { ArkProvider, Output, SettlementEvent } from "../providers/ark.js";
|
|
3
3
|
import { Identity, ReadonlyIdentity } from "../identity/index.js";
|
|
4
|
+
import { DescriptorProvider } from "../identity/descriptorProvider.js";
|
|
4
5
|
import { RelativeTimelock } from "../script/tapscript.js";
|
|
5
6
|
import { EncodedVtxoScript, TapLeafScript } from "../script/base.js";
|
|
6
7
|
import { RenewalConfig, SettlementConfig } from "./vtxo-manager.js";
|
|
@@ -15,6 +16,30 @@ import { DelegatorProvider } from "../providers/delegator.js";
|
|
|
15
16
|
export declare const DEFAULT_ARKADE_SERVER_URL: "https://arkade.computer";
|
|
16
17
|
export declare const DEFAULT_ARKADE_HRP: "ark";
|
|
17
18
|
export declare const DEFAULT_NETWORK_NAME: "bitcoin";
|
|
19
|
+
/**
|
|
20
|
+
* Wallet receive-address strategy.
|
|
21
|
+
*
|
|
22
|
+
* - `'auto'` *(default)*: **short-term** — currently identical to
|
|
23
|
+
* `'static'`. The `'auto'` name is reserved for a future change that
|
|
24
|
+
* will re-enable identity-probing once HD rotation has matured in
|
|
25
|
+
* the field. Until then, opt into HD explicitly via `'hd'` or a
|
|
26
|
+
* {@link DescriptorProvider}.
|
|
27
|
+
* *(See `TODO(hd-maturation)` in
|
|
28
|
+
* `src/wallet/walletReceiveRotator.ts:resolveDescriptorProvider` for
|
|
29
|
+
* the flip-back criteria.)*
|
|
30
|
+
* - `'static'`: never rotate. The wallet uses one receive address derived
|
|
31
|
+
* from `identity.xOnlyPublicKey()`.
|
|
32
|
+
* - `'hd'`: must rotate, using the built-in HD provider derived from the
|
|
33
|
+
* identity. Throws at `Wallet.create` if the identity isn't HD-capable
|
|
34
|
+
* or its descriptor isn't rangeable — no silent fallback.
|
|
35
|
+
* - A {@link DescriptorProvider} instance: rotate via the supplied
|
|
36
|
+
* provider on every incoming VTXO. The wallet does not probe the
|
|
37
|
+
* identity; the caller is responsible for ensuring the identity can
|
|
38
|
+
* sign for whatever pubkey the provider returns. Errors thrown by the
|
|
39
|
+
* provider propagate — there is no silent fallback for an explicit
|
|
40
|
+
* provider.
|
|
41
|
+
*/
|
|
42
|
+
export type WalletMode = "auto" | "static" | "hd" | DescriptorProvider;
|
|
18
43
|
/**
|
|
19
44
|
* Base configuration options shared by all wallet types.
|
|
20
45
|
*
|
|
@@ -164,6 +189,15 @@ export interface WalletConfig extends ReadonlyWalletConfig {
|
|
|
164
189
|
* @see SettlementConfig
|
|
165
190
|
*/
|
|
166
191
|
settlementConfig?: SettlementConfig | false;
|
|
192
|
+
/**
|
|
193
|
+
* Receive-address strategy. Pass `'static'`, `'hd'`, or a
|
|
194
|
+
* {@link DescriptorProvider} instance to drive rotation; omit (or
|
|
195
|
+
* pass `'auto'`) for the built-in auto-detect behaviour. See
|
|
196
|
+
* {@link WalletMode}.
|
|
197
|
+
*
|
|
198
|
+
* @defaultValue `'auto'`
|
|
199
|
+
*/
|
|
200
|
+
walletMode?: WalletMode;
|
|
167
201
|
}
|
|
168
202
|
/**
|
|
169
203
|
* Repository implementations used to store wallet and contract state.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Transaction } from "@scure/btc-signer";
|
|
2
|
+
import { Identity } from "../identity/index.js";
|
|
3
|
+
import { ContractRepository } from "../repositories/contractRepository.js";
|
|
4
|
+
import { DescriptorProvider } from "../identity/descriptorProvider.js";
|
|
5
|
+
export interface InputSigningJob {
|
|
6
|
+
/** Index in the source transaction. */
|
|
7
|
+
index: number;
|
|
8
|
+
/**
|
|
9
|
+
* Script used to identify the owning contract. For normal inputs this
|
|
10
|
+
* is the input's witnessUtxo script. For arkTx inputs this is the
|
|
11
|
+
* source VTXO script, because the witnessUtxo carries the checkpoint
|
|
12
|
+
* script instead.
|
|
13
|
+
*/
|
|
14
|
+
lookupScript: Uint8Array;
|
|
15
|
+
}
|
|
16
|
+
export interface InputSignerRouterDeps {
|
|
17
|
+
identity: Identity;
|
|
18
|
+
contractRepository: ContractRepository;
|
|
19
|
+
descriptorProvider?: DescriptorProvider;
|
|
20
|
+
boardingPkScript: Uint8Array;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Routes PSBT inputs to the correct signer based on the owning contract.
|
|
24
|
+
* Inputs whose script matches a `default`/`delegate` contract with a
|
|
25
|
+
* non-baseline owner are sent to {@link DescriptorProvider}; everything
|
|
26
|
+
* else (baseline-owned contracts, non-default/non-delegate contracts,
|
|
27
|
+
* and the boarding script) is sent to {@link Identity}. Inputs with no
|
|
28
|
+
* matching contract and no boarding match are silently skipped, matching
|
|
29
|
+
* how the wallet historically handled cosigner/connector inputs.
|
|
30
|
+
*/
|
|
31
|
+
export declare class InputSignerRouter {
|
|
32
|
+
private readonly deps;
|
|
33
|
+
constructor(deps: InputSignerRouterDeps);
|
|
34
|
+
sign(tx: Transaction, jobs: InputSigningJob[]): Promise<Transaction>;
|
|
35
|
+
}
|
|
@@ -10,6 +10,7 @@ import type { IVtxoManager, SettlementConfig } from "../vtxo-manager.js";
|
|
|
10
10
|
import type { ContractWatcherConfig } from "../../contracts/contractWatcher.js";
|
|
11
11
|
type RequestType = WalletUpdaterRequest["type"];
|
|
12
12
|
export type MessageTimeouts = Partial<Record<RequestType, number>>;
|
|
13
|
+
export type ServiceWorkerWalletMode = "auto" | "static" | "hd";
|
|
13
14
|
export declare const DEFAULT_MESSAGE_TIMEOUTS: Readonly<Record<RequestType, number>>;
|
|
14
15
|
/**
|
|
15
16
|
* Service Worker-based wallet implementation for browser environments.
|
|
@@ -68,6 +69,14 @@ interface ServiceWorkerWalletOptions {
|
|
|
68
69
|
messageBusTimeoutMs?: number;
|
|
69
70
|
/** Optional settlement configuration forwarded to the worker wallet. */
|
|
70
71
|
settlementConfig?: SettlementConfig | false;
|
|
72
|
+
/**
|
|
73
|
+
* Receive-address strategy forwarded to the worker wallet.
|
|
74
|
+
*
|
|
75
|
+
* Service workers can only receive serializable configuration, so the
|
|
76
|
+
* descriptor-provider object form accepted by `Wallet.create()` is not
|
|
77
|
+
* supported here.
|
|
78
|
+
*/
|
|
79
|
+
walletMode?: ServiceWorkerWalletMode;
|
|
71
80
|
/** Optional contract watcher configuration forwarded to the worker wallet. */
|
|
72
81
|
watcherConfig?: Partial<Omit<ContractWatcherConfig, "indexerProvider">>;
|
|
73
82
|
/**
|
|
@@ -109,6 +118,7 @@ type MessageBusInitConfig = {
|
|
|
109
118
|
esploraUrl?: string;
|
|
110
119
|
timeoutMs?: number;
|
|
111
120
|
settlementConfig?: SettlementConfig | false;
|
|
121
|
+
walletMode?: ServiceWorkerWalletMode;
|
|
112
122
|
watcherConfig?: Partial<Omit<ContractWatcherConfig, "indexerProvider">>;
|
|
113
123
|
messageTimeouts?: Record<string, number>;
|
|
114
124
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when a rotated contract (default or delegate) is missing the
|
|
3
|
+
* metadata.signingDescriptor required to route it to a descriptor-aware
|
|
4
|
+
* signer.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MissingSigningDescriptorError extends Error {
|
|
7
|
+
readonly contractScript: string;
|
|
8
|
+
readonly contractType: "default" | "delegate";
|
|
9
|
+
readonly name = "MissingSigningDescriptorError";
|
|
10
|
+
constructor(contractScript: string, contractType: "default" | "delegate");
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Thrown when an input needs descriptor-aware signing but no
|
|
14
|
+
* DescriptorProvider was wired into the wallet.
|
|
15
|
+
*/
|
|
16
|
+
export declare class DescriptorSigningProviderMissingError extends Error {
|
|
17
|
+
readonly name = "DescriptorSigningProviderMissingError";
|
|
18
|
+
constructor();
|
|
19
|
+
}
|
|
@@ -19,6 +19,9 @@ import { DelegatorProvider } from "../providers/delegator.js";
|
|
|
19
19
|
import { DelegateVtxo } from "../script/delegate.js";
|
|
20
20
|
import { IDelegatorManager } from "./delegator.js";
|
|
21
21
|
import { ContractManager } from "../contracts/contractManager.js";
|
|
22
|
+
import { WalletReceiveRotator } from "./walletReceiveRotator.js";
|
|
23
|
+
import { DescriptorProvider } from "../identity/descriptorProvider.js";
|
|
24
|
+
import { DescriptorSigningProviderMissingError, MissingSigningDescriptorError } from "./signingErrors.js";
|
|
22
25
|
export declare const getArkadeServerUrl: ({ arkServerUrl, }: {
|
|
23
26
|
arkServerUrl?: string;
|
|
24
27
|
}) => string;
|
|
@@ -30,13 +33,13 @@ export type IncomingFunds = {
|
|
|
30
33
|
newVtxos: ExtendedVirtualCoin[];
|
|
31
34
|
spentVtxos: ExtendedVirtualCoin[];
|
|
32
35
|
};
|
|
36
|
+
export { DescriptorSigningProviderMissingError, MissingSigningDescriptorError };
|
|
33
37
|
export declare class ReadonlyWallet implements IReadonlyWallet {
|
|
34
38
|
readonly identity: ReadonlyIdentity;
|
|
35
39
|
readonly network: Network;
|
|
36
40
|
readonly onchainProvider: OnchainProvider;
|
|
37
41
|
readonly indexerProvider: IndexerProvider;
|
|
38
42
|
readonly arkServerPublicKey: Bytes;
|
|
39
|
-
readonly offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
|
|
40
43
|
readonly boardingTapscript: DefaultVtxo.Script;
|
|
41
44
|
readonly dustAmount: bigint;
|
|
42
45
|
readonly walletRepository: WalletRepository;
|
|
@@ -50,7 +53,20 @@ export declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
50
53
|
readonly walletContractTimelocks: RelativeTimelock[];
|
|
51
54
|
protected _pendingSpendOutpoints: Set<string>;
|
|
52
55
|
get assetManager(): IReadonlyAssetManager;
|
|
56
|
+
/**
|
|
57
|
+
* Backing field for the active receive tapscript. Read via the
|
|
58
|
+
* public `offchainTapscript` getter; written only by
|
|
59
|
+
* {@link Wallet.setOffchainTapscriptForRotation}, which
|
|
60
|
+
* {@link WalletReceiveRotator.rotate} is the sole intended caller of.
|
|
61
|
+
*/
|
|
62
|
+
protected _offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
|
|
53
63
|
protected constructor(identity: ReadonlyIdentity, network: Network, onchainProvider: OnchainProvider, indexerProvider: IndexerProvider, arkServerPublicKey: Bytes, offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script, boardingTapscript: DefaultVtxo.Script, dustAmount: bigint, walletRepository: WalletRepository, contractRepository: ContractRepository, delegatorProvider?: DelegatorProvider | undefined, watcherConfig?: ReadonlyWalletConfig["watcherConfig"], walletContractTimelocks?: RelativeTimelock[]);
|
|
64
|
+
/**
|
|
65
|
+
* Currently-active receive tapscript. Read-only from the outside;
|
|
66
|
+
* mutated only via {@link Wallet.setOffchainTapscriptForRotation}
|
|
67
|
+
* by {@link WalletReceiveRotator.rotate}.
|
|
68
|
+
*/
|
|
69
|
+
get offchainTapscript(): DefaultVtxo.Script | DelegateVtxo.Script;
|
|
54
70
|
/**
|
|
55
71
|
* Protected helper to set up shared wallet configuration.
|
|
56
72
|
* Extracts common logic used by both ReadonlyWallet.create() and Wallet.create().
|
|
@@ -215,6 +231,32 @@ export declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
215
231
|
private _vtxoManager?;
|
|
216
232
|
private _vtxoManagerInitializing?;
|
|
217
233
|
private _walletAssetManager?;
|
|
234
|
+
/**
|
|
235
|
+
* HD receive rotator. Owns the {@link DescriptorProvider}, the
|
|
236
|
+
* `vtxo_received` subscription, and the rotate-and-register
|
|
237
|
+
* lifecycle. Absent in `walletMode: 'static'` and for SingleKey
|
|
238
|
+
* wallets under `'auto'`. Wired in via the constructor; the actual
|
|
239
|
+
* subscription is installed lazily on first `getVtxoManager()` so
|
|
240
|
+
* the contract manager is up first.
|
|
241
|
+
*/
|
|
242
|
+
private _receiveRotator?;
|
|
243
|
+
private _receiveRotatorInstalled;
|
|
244
|
+
/**
|
|
245
|
+
* Descriptor-aware signer used by {@link _signerRouter} to sign
|
|
246
|
+
* inputs locked by rotated pubkeys. Same instance the rotator owns;
|
|
247
|
+
* stashed here so the spending paths don't have to reach inside the
|
|
248
|
+
* rotator. Undefined for static / non-HD-capable wallets — those
|
|
249
|
+
* paths only ever take the identity-sign branch.
|
|
250
|
+
*/
|
|
251
|
+
private readonly _descriptorProvider?;
|
|
252
|
+
private readonly _signerRouter;
|
|
253
|
+
/**
|
|
254
|
+
* @internal Sole write path for `offchainTapscript` after construction.
|
|
255
|
+
* Called by {@link WalletReceiveRotator.rotate} once the rotated
|
|
256
|
+
* display contract has been persisted. External code must treat
|
|
257
|
+
* `offchainTapscript` as read-only.
|
|
258
|
+
*/
|
|
259
|
+
setOffchainTapscriptForRotation(tapscript: DefaultVtxo.Script | DelegateVtxo.Script): void;
|
|
218
260
|
/**
|
|
219
261
|
* Async mutex that serializes all operations submitting VTXOs to the Arkade
|
|
220
262
|
* server (`settle`, `send`, `sendBitcoin`). This prevents VtxoManager's
|
|
@@ -233,7 +275,7 @@ export declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
233
275
|
readonly settlementConfig: SettlementConfig | false;
|
|
234
276
|
protected constructor(identity: Identity, network: Network, onchainProvider: OnchainProvider, arkProvider: ArkProvider, indexerProvider: IndexerProvider, arkServerPublicKey: Bytes, offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script, boardingTapscript: DefaultVtxo.Script, serverUnrollScript: CSVMultisigTapscript.Type, forfeitOutputScript: Bytes, forfeitPubkey: Bytes, dustAmount: bigint, walletRepository: WalletRepository, contractRepository: ContractRepository,
|
|
235
277
|
/** @deprecated Use settlementConfig */
|
|
236
|
-
renewalConfig?: WalletConfig["renewalConfig"], delegatorProvider?: DelegatorProvider, watcherConfig?: WalletConfig["watcherConfig"], settlementConfig?: WalletConfig["settlementConfig"], walletContractTimelocks?: RelativeTimelock[]);
|
|
278
|
+
renewalConfig?: WalletConfig["renewalConfig"], delegatorProvider?: DelegatorProvider, watcherConfig?: WalletConfig["watcherConfig"], settlementConfig?: WalletConfig["settlementConfig"], walletContractTimelocks?: RelativeTimelock[], receiveRotator?: WalletReceiveRotator, descriptorProvider?: DescriptorProvider);
|
|
237
279
|
get assetManager(): IAssetManager;
|
|
238
280
|
getVtxoManager(): Promise<VtxoManager>;
|
|
239
281
|
dispose(): Promise<void>;
|
|
@@ -297,6 +339,13 @@ export declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
297
339
|
* @param session - Optional musig2 signing session. When omitted, signing steps are skipped.
|
|
298
340
|
*/
|
|
299
341
|
createBatchHandler(intentId: string, inputs: ExtendedCoin[], expectedRecipients: Recipient[], session?: SignerSession): Batch.Handler;
|
|
342
|
+
/**
|
|
343
|
+
* Build {@link InputSigningJob}s for a tx whose signable inputs can be
|
|
344
|
+
* resolved from their own `witnessUtxo.script`. Inputs without a
|
|
345
|
+
* `witnessUtxo` are silently omitted, mirroring the wallet's
|
|
346
|
+
* historical silent-skip behaviour for cosigner/connector inputs.
|
|
347
|
+
*/
|
|
348
|
+
private inputSigningJobsFromWitnessUtxos;
|
|
300
349
|
safeRegisterIntent(intent: SignedIntent<Intent.RegisterMessage>, inputs: ExtendedCoin[]): Promise<string>;
|
|
301
350
|
makeRegisterIntentSignature(coins: ExtendedCoin[], outputs: TransactionOutput[], onchainOutputsIndexes: number[], cosignerPubKeys: string[], validAt?: number): Promise<SignedIntent<Intent.RegisterMessage>>;
|
|
302
351
|
makeDeleteIntentSignature(coins: ExtendedCoin[]): Promise<SignedIntent<Intent.DeleteMessage>>;
|