@1sat/wallet-toolbox 0.0.9 → 0.0.11

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.
Files changed (39) hide show
  1. package/dist/api/balance/index.d.ts +20 -8
  2. package/dist/api/balance/index.js +104 -51
  3. package/dist/api/broadcast/index.d.ts +5 -3
  4. package/dist/api/broadcast/index.js +65 -37
  5. package/dist/api/index.d.ts +16 -15
  6. package/dist/api/index.js +42 -17
  7. package/dist/api/inscriptions/index.d.ts +9 -9
  8. package/dist/api/inscriptions/index.js +79 -31
  9. package/dist/api/locks/index.d.ts +15 -12
  10. package/dist/api/locks/index.js +252 -194
  11. package/dist/api/ordinals/index.d.ts +50 -35
  12. package/dist/api/ordinals/index.js +469 -349
  13. package/dist/api/payments/index.d.ts +15 -4
  14. package/dist/api/payments/index.js +147 -92
  15. package/dist/api/signing/index.d.ts +8 -5
  16. package/dist/api/signing/index.js +70 -33
  17. package/dist/api/skills/registry.d.ts +61 -0
  18. package/dist/api/skills/registry.js +74 -0
  19. package/dist/api/skills/types.d.ts +71 -0
  20. package/dist/api/skills/types.js +14 -0
  21. package/dist/api/sweep/index.d.ts +23 -0
  22. package/dist/api/sweep/index.js +221 -0
  23. package/dist/api/sweep/types.d.ts +30 -0
  24. package/dist/api/sweep/types.js +4 -0
  25. package/dist/api/tokens/index.d.ts +37 -38
  26. package/dist/api/tokens/index.js +398 -341
  27. package/dist/index.d.ts +2 -1
  28. package/dist/index.js +2 -0
  29. package/dist/services/client/OwnerClient.js +4 -0
  30. package/dist/wallet/factory.d.ts +64 -0
  31. package/dist/wallet/factory.js +163 -0
  32. package/dist/wallet/index.d.ts +1 -0
  33. package/dist/wallet/index.js +1 -0
  34. package/package.json +13 -4
  35. package/dist/OneSatWallet.d.ts +0 -316
  36. package/dist/OneSatWallet.js +0 -956
  37. package/dist/api/OneSatApi.d.ts +0 -100
  38. package/dist/api/OneSatApi.js +0 -156
  39. package/dist/indexers/TransactionParser.d.ts +0 -53
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  export * from "./api";
2
2
  export { OneSatServices, type SyncOutput } from "./services/OneSatServices";
3
- export type { OrdfsMetadata, OrdfsContentOptions, OrdfsContentResponse, OrdfsResponseHeaders, Capability, } from "./services/types";
3
+ export type { IndexedOutput, OrdfsMetadata, OrdfsContentOptions, OrdfsContentResponse, OrdfsResponseHeaders, Capability, } from "./services/types";
4
4
  export * from "./services/client";
5
5
  export { ReadOnlySigner } from "./signers/ReadOnlySigner";
6
6
  export * from "./indexers";
7
7
  export * from "./sync";
8
8
  export * from "./cwi";
9
+ export * from "./wallet";
package/dist/index.js CHANGED
@@ -15,3 +15,5 @@ export * from "./indexers";
15
15
  export * from "./sync";
16
16
  // CWI (Chrome Wallet Interface) - BRC-100 implementations
17
17
  export * from "./cwi";
18
+ // Wallet factory for creating 1Sat web wallets
19
+ export * from "./wallet";
@@ -22,6 +22,10 @@ export class OwnerClient extends BaseClient {
22
22
  limit: opts?.limit,
23
23
  rev: opts?.rev,
24
24
  unspent: opts?.unspent,
25
+ sats: opts?.sats,
26
+ spend: opts?.spend,
27
+ events: opts?.events,
28
+ block: opts?.block,
25
29
  refresh: opts?.refresh,
26
30
  });
27
31
  return this.request(`/${owner}/txos${qs}`);
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Factory for creating web wallets.
3
+ *
4
+ * This consolidates the common wallet setup used by both yours-wallet
5
+ * (browser extension) and 1sat-website (React app).
6
+ */
7
+ import { PrivateKey } from "@bsv/sdk";
8
+ import { WalletPermissionsManager, Monitor, type PermissionsManagerConfig } from "@bsv/wallet-toolbox-mobile/out/src/index.client.js";
9
+ import { OneSatServices } from "../services/OneSatServices";
10
+ type Chain = "main" | "test";
11
+ /**
12
+ * Configuration for creating a web wallet.
13
+ */
14
+ export interface WebWalletConfig {
15
+ /** Private key - can be PrivateKey instance, WIF string, or hex string */
16
+ privateKey: PrivateKey | string;
17
+ /** Network: 'main' or 'test' */
18
+ chain: Chain;
19
+ /** Admin originator that bypasses permission checks (e.g., chrome-extension://id or https://wallet.example.com) */
20
+ adminOriginator: string;
21
+ /** Permission configuration for WalletPermissionsManager */
22
+ permissionsConfig: PermissionsManagerConfig;
23
+ /** Fee model. Default: { model: 'sat/kb', value: 1 } */
24
+ feeModel?: {
25
+ model: "sat/kb";
26
+ value: number;
27
+ };
28
+ /** Remote storage URL. If provided, attempts to connect for cloud backup. */
29
+ remoteStorageUrl?: string;
30
+ }
31
+ /**
32
+ * Result of wallet creation.
33
+ */
34
+ export interface WebWalletResult {
35
+ /** Wallet instance with permission management */
36
+ wallet: WalletPermissionsManager;
37
+ /** 1Sat services for API access */
38
+ services: OneSatServices;
39
+ /** Monitor for transaction lifecycle (not started - call monitor.startTasks() when ready) */
40
+ monitor: Monitor;
41
+ /** Cleanup function - stops monitor, destroys wallet */
42
+ destroy: () => Promise<void>;
43
+ }
44
+ /**
45
+ * Create a web wallet with storage, services, permissions, and monitor.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * const { wallet, services, monitor, destroy } = await createWebWallet({
50
+ * privateKey: identityWif,
51
+ * chain: 'main',
52
+ * adminOriginator: 'https://wallet.example.com',
53
+ * permissionsConfig: DEFAULT_PERMISSIONS_CONFIG,
54
+ * });
55
+ *
56
+ * // Wire up monitor callbacks
57
+ * monitor.onTransactionProven = async (status) => console.log('Proven:', status.txid);
58
+ *
59
+ * // Start monitor when ready
60
+ * monitor.startTasks();
61
+ * ```
62
+ */
63
+ export declare function createWebWallet(config: WebWalletConfig): Promise<WebWalletResult>;
64
+ export {};
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Factory for creating web wallets.
3
+ *
4
+ * This consolidates the common wallet setup used by both yours-wallet
5
+ * (browser extension) and 1sat-website (React app).
6
+ */
7
+ import { KeyDeriver, PrivateKey } from "@bsv/sdk";
8
+ import { Wallet, WalletStorageManager, StorageProvider, StorageIdb, StorageClient, WalletPermissionsManager, Services, Monitor, } from "@bsv/wallet-toolbox-mobile/out/src/index.client.js";
9
+ import { OneSatServices } from "../services/OneSatServices";
10
+ // Default database name for IndexedDB storage
11
+ const DEFAULT_DATABASE_NAME = "wallet";
12
+ // Default timeout for remote storage connection
13
+ const DEFAULT_REMOTE_STORAGE_TIMEOUT = 5000;
14
+ // Default fee model
15
+ const DEFAULT_FEE_MODEL = { model: "sat/kb", value: 1 };
16
+ /**
17
+ * Parse a private key from various input formats.
18
+ * Supports PrivateKey instance, WIF string, or hex string.
19
+ */
20
+ function parsePrivateKey(input) {
21
+ if (input instanceof PrivateKey) {
22
+ return input;
23
+ }
24
+ // Try WIF first (starts with 5, K, L for mainnet or c for testnet)
25
+ if (/^[5KLc][1-9A-HJ-NP-Za-km-z]{50,51}$/.test(input)) {
26
+ return PrivateKey.fromWif(input);
27
+ }
28
+ // Try hex (64 characters)
29
+ if (/^[0-9a-fA-F]{64}$/.test(input)) {
30
+ return new PrivateKey(input);
31
+ }
32
+ // Last resort - try WIF anyway
33
+ try {
34
+ return PrivateKey.fromWif(input);
35
+ }
36
+ catch {
37
+ throw new Error("Invalid private key format. Expected PrivateKey instance, WIF string, or 64-char hex string.");
38
+ }
39
+ }
40
+ /**
41
+ * Create a web wallet with storage, services, permissions, and monitor.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const { wallet, services, monitor, destroy } = await createWebWallet({
46
+ * privateKey: identityWif,
47
+ * chain: 'main',
48
+ * adminOriginator: 'https://wallet.example.com',
49
+ * permissionsConfig: DEFAULT_PERMISSIONS_CONFIG,
50
+ * });
51
+ *
52
+ * // Wire up monitor callbacks
53
+ * monitor.onTransactionProven = async (status) => console.log('Proven:', status.txid);
54
+ *
55
+ * // Start monitor when ready
56
+ * monitor.startTasks();
57
+ * ```
58
+ */
59
+ export async function createWebWallet(config) {
60
+ const { chain, adminOriginator, permissionsConfig } = config;
61
+ const feeModel = config.feeModel ?? DEFAULT_FEE_MODEL;
62
+ // 1. Parse private key and create KeyDeriver
63
+ const privateKey = parsePrivateKey(config.privateKey);
64
+ const identityPubKey = privateKey.toPublicKey().toString();
65
+ const keyDeriver = new KeyDeriver(privateKey);
66
+ // 2. Create fallback services and OneSatServices
67
+ const fallbackServices = new Services(chain);
68
+ const oneSatServices = new OneSatServices(chain, undefined, fallbackServices);
69
+ // 3. Create local storage
70
+ const storageOptions = StorageProvider.createStorageBaseOptions(chain);
71
+ storageOptions.feeModel = feeModel;
72
+ const localStorage = new StorageIdb(storageOptions);
73
+ await localStorage.migrate(DEFAULT_DATABASE_NAME, identityPubKey);
74
+ // 4. Create storage manager (local-only initially)
75
+ let storage = new WalletStorageManager(identityPubKey, localStorage);
76
+ await storage.makeAvailable();
77
+ // 5. Create the underlying Wallet
78
+ const underlyingWallet = new Wallet({
79
+ chain,
80
+ keyDeriver,
81
+ storage,
82
+ services: oneSatServices,
83
+ });
84
+ // 6. Attempt remote storage connection if URL provided
85
+ if (config.remoteStorageUrl) {
86
+ console.log(`[createWebWallet] Attempting remote storage connection to ${config.remoteStorageUrl}`);
87
+ try {
88
+ const remoteClient = new StorageClient(underlyingWallet, config.remoteStorageUrl);
89
+ const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error("Remote storage connection timeout")), DEFAULT_REMOTE_STORAGE_TIMEOUT));
90
+ await Promise.race([remoteClient.makeAvailable(), timeoutPromise]);
91
+ // Remote connected - recreate storage manager with backup
92
+ storage = new WalletStorageManager(identityPubKey, localStorage, [
93
+ remoteClient,
94
+ ]);
95
+ await storage.makeAvailable();
96
+ // Check for conflicting actives and resolve if needed
97
+ const storageAny = storage;
98
+ console.log("[createWebWallet] Storage state:", {
99
+ activeKey: storageAny._active?.settings?.storageIdentityKey,
100
+ backups: storageAny._backups?.map(b => b.settings?.storageIdentityKey),
101
+ conflictingActives: storageAny._conflictingActives?.map(c => c.settings?.storageIdentityKey),
102
+ });
103
+ // If there are conflicting actives, resolve by setting local as active (merges remote data)
104
+ if (storageAny._conflictingActives && storageAny._conflictingActives.length > 0) {
105
+ const localKey = storageAny._active?.settings?.storageIdentityKey;
106
+ if (localKey && storageAny.setActive) {
107
+ console.log("[createWebWallet] Resolving conflicts by merging into local storage...");
108
+ await storageAny.setActive(localKey, (msg) => {
109
+ console.log("[createWebWallet] Sync:", msg);
110
+ return msg;
111
+ });
112
+ console.log("[createWebWallet] Conflict resolution complete");
113
+ }
114
+ }
115
+ else if (storageAny._backups && storageAny._backups.length > 0 && storageAny.updateBackups) {
116
+ // No conflicts - push local state to remote backup (non-blocking to avoid IDB timeout)
117
+ console.log("[createWebWallet] Starting background backup to remote...");
118
+ storageAny.updateBackups(undefined, (msg) => {
119
+ console.log("[createWebWallet] Backup:", msg);
120
+ return msg;
121
+ }).then(() => {
122
+ console.log("[createWebWallet] Background backup complete");
123
+ }).catch((err) => {
124
+ console.log("[createWebWallet] Background backup failed:", err instanceof Error ? err.message : err);
125
+ });
126
+ }
127
+ // Update wallet's storage reference
128
+ underlyingWallet._storage = storage;
129
+ console.log("[createWebWallet] Remote storage connected successfully");
130
+ }
131
+ catch (err) {
132
+ console.log("[createWebWallet] Remote storage connection failed:", err instanceof Error ? err.message : err);
133
+ // Graceful degradation - continue with local only
134
+ }
135
+ }
136
+ // 7. Wrap with permissions manager
137
+ const wallet = new WalletPermissionsManager(underlyingWallet, adminOriginator, permissionsConfig);
138
+ // 8. Create monitor (not started - consumer calls startTasks() when ready)
139
+ const monitor = new Monitor({
140
+ chain,
141
+ services: oneSatServices,
142
+ storage,
143
+ chaintracks: oneSatServices.chaintracks,
144
+ msecsWaitPerMerkleProofServiceReq: 500,
145
+ taskRunWaitMsecs: 5000,
146
+ abandonedMsecs: 300000,
147
+ unprovenAttemptsLimitTest: 10,
148
+ unprovenAttemptsLimitMain: 144,
149
+ });
150
+ monitor.addDefaultTasks();
151
+ // 9. Create cleanup function
152
+ const destroy = async () => {
153
+ monitor.stopTasks();
154
+ await monitor.destroy();
155
+ await underlyingWallet.destroy();
156
+ };
157
+ return {
158
+ wallet,
159
+ services: oneSatServices,
160
+ monitor,
161
+ destroy,
162
+ };
163
+ }
@@ -0,0 +1 @@
1
+ export * from "./factory";
@@ -0,0 +1 @@
1
+ export * from "./factory";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/wallet-toolbox",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "BSV wallet library extending @bsv/wallet-toolbox with 1Sat Ordinals protocol support",
5
5
  "author": "1Sat Team",
6
6
  "license": "MIT",
@@ -37,13 +37,22 @@
37
37
  "tester": "bun run build && bun run tester:build && bun ./tester/server.ts"
38
38
  },
39
39
  "dependencies": {
40
- "@bopen-io/templates": "^1.1.4",
41
- "@bsv/sdk": "^1.9.31",
40
+ "@bopen-io/templates": "^1.1.6",
41
+ "@bsv/sdk": "^1.10.1",
42
42
  "buffer": "^6.0.3"
43
43
  },
44
+ "peerDependencies": {
45
+ "@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.1"
46
+ },
47
+ "peerDependenciesMeta": {
48
+ "@bsv/wallet-toolbox-mobile": {
49
+ "optional": true
50
+ }
51
+ },
44
52
  "devDependencies": {
45
53
  "@biomejs/biome": "^1.9.4",
46
- "@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@^1.7.19",
54
+ "@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@^1.7.20-idb-fix.1",
55
+ "@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.1",
47
56
  "@types/bun": "^1.3.4",
48
57
  "@types/chrome": "^0.1.32",
49
58
  "typescript": "^5.9.3"
@@ -1,316 +0,0 @@
1
- import { Transaction, type WalletInterface } from "@bsv/sdk";
2
- import type { WalletStorageManager, sdk as toolboxSdk } from "@bsv/wallet-toolbox";
3
- type Chain = toolboxSdk.Chain;
4
- import { Outpoint } from "./indexers/Outpoint";
5
- import type { Indexer, ParseContext, Txo } from "./indexers/types";
6
- import { OneSatServices } from "./services/OneSatServices";
7
- import type { SyncQueueStorage } from "./sync/types";
8
- /**
9
- * Result of ingestTransaction including parse context for debugging
10
- */
11
- export interface IngestResult {
12
- parseContext: ParseContext;
13
- internalizedCount: number;
14
- }
15
- /**
16
- * Events emitted by OneSatWallet during sync operations
17
- */
18
- export interface OneSatWalletEvents {
19
- /** Sync started */
20
- "sync:start": {
21
- addresses: string[];
22
- };
23
- /** Sync progress update */
24
- "sync:progress": {
25
- pending: number;
26
- done: number;
27
- failed: number;
28
- };
29
- /** Sync complete (queue empty and stream done) */
30
- "sync:complete": Record<string, never>;
31
- /** Sync error */
32
- "sync:error": {
33
- message: string;
34
- };
35
- }
36
- type EventCallback<T> = (event: T) => void;
37
- export interface OneSatWalletArgs {
38
- /**
39
- * The underlying BRC-100 wallet to wrap.
40
- */
41
- wallet: WalletInterface;
42
- /**
43
- * The storage manager from the wallet (needed for direct storage access).
44
- */
45
- storage: WalletStorageManager;
46
- /**
47
- * Network: 'main' or 'test'
48
- */
49
- chain: Chain;
50
- /**
51
- * Addresses owned by this wallet, used for filtering indexed outputs.
52
- */
53
- owners?: Set<string>;
54
- /**
55
- * Indexers to use for parsing transactions.
56
- * If not provided, default indexers will be used.
57
- */
58
- indexers?: Indexer[];
59
- /**
60
- * Custom 1Sat API URL (default: based on chain - mainnet or testnet)
61
- */
62
- onesatUrl?: string;
63
- /**
64
- * Automatically start syncing all owner addresses on construction.
65
- */
66
- autoSync?: boolean;
67
- /**
68
- * Sync queue storage for background processing.
69
- * If provided, enables queue-based sync via sync() method.
70
- */
71
- syncQueue?: SyncQueueStorage;
72
- /**
73
- * Batch size for queue processing (default: 20).
74
- */
75
- syncBatchSize?: number;
76
- }
77
- /**
78
- * OneSatWallet wraps a BRC-100 Wallet with 1Sat-specific indexing and services.
79
- *
80
- * The consumer is responsible for constructing the underlying Wallet with
81
- * the appropriate storage and key derivation for their environment.
82
- */
83
- export declare class OneSatWallet implements WalletInterface {
84
- private readonly wallet;
85
- private readonly storage;
86
- private readonly indexers;
87
- readonly services: OneSatServices;
88
- private owners;
89
- private listeners;
90
- private syncQueue;
91
- private syncBatchSize;
92
- private syncRunning;
93
- private syncStopRequested;
94
- private activeQueueSync;
95
- private sseStreamActive;
96
- private sseUnsubscribe;
97
- private processorActive;
98
- private processorStopRequested;
99
- private streamDone;
100
- constructor(args: OneSatWalletArgs);
101
- getPublicKey: WalletInterface["getPublicKey"];
102
- revealCounterpartyKeyLinkage: WalletInterface["revealCounterpartyKeyLinkage"];
103
- revealSpecificKeyLinkage: WalletInterface["revealSpecificKeyLinkage"];
104
- encrypt: WalletInterface["encrypt"];
105
- decrypt: WalletInterface["decrypt"];
106
- createHmac: WalletInterface["createHmac"];
107
- verifyHmac: WalletInterface["verifyHmac"];
108
- createSignature: WalletInterface["createSignature"];
109
- verifySignature: WalletInterface["verifySignature"];
110
- createAction: WalletInterface["createAction"];
111
- signAction: WalletInterface["signAction"];
112
- abortAction: WalletInterface["abortAction"];
113
- listActions: WalletInterface["listActions"];
114
- internalizeAction: WalletInterface["internalizeAction"];
115
- listOutputs: WalletInterface["listOutputs"];
116
- relinquishOutput: WalletInterface["relinquishOutput"];
117
- acquireCertificate: WalletInterface["acquireCertificate"];
118
- listCertificates: WalletInterface["listCertificates"];
119
- proveCertificate: WalletInterface["proveCertificate"];
120
- relinquishCertificate: WalletInterface["relinquishCertificate"];
121
- discoverByIdentityKey: WalletInterface["discoverByIdentityKey"];
122
- discoverByAttributes: WalletInterface["discoverByAttributes"];
123
- isAuthenticated: WalletInterface["isAuthenticated"];
124
- waitForAuthentication: WalletInterface["waitForAuthentication"];
125
- getHeight: WalletInterface["getHeight"];
126
- getHeaderForHeight: WalletInterface["getHeaderForHeight"];
127
- getNetwork: WalletInterface["getNetwork"];
128
- getVersion: WalletInterface["getVersion"];
129
- /**
130
- * Subscribe to wallet events
131
- */
132
- on<K extends keyof OneSatWalletEvents>(event: K, callback: EventCallback<OneSatWalletEvents[K]>): void;
133
- /**
134
- * Unsubscribe from wallet events
135
- */
136
- off<K extends keyof OneSatWalletEvents>(event: K, callback: EventCallback<OneSatWalletEvents[K]>): void;
137
- /**
138
- * Emit a wallet event
139
- */
140
- private emit;
141
- /**
142
- * Add an address to the set of owned addresses.
143
- * Outputs to these addresses will be indexed.
144
- */
145
- addOwner(address: string): void;
146
- /**
147
- * Parse a transaction through indexers without internalizing.
148
- *
149
- * This is useful for debugging/testing to see what the indexers produce
150
- * without actually storing the transaction in the wallet.
151
- *
152
- * @param tx - Transaction or txid to parse
153
- * @param isBroadcasted - Whether this transaction has been broadcast
154
- * @returns ParseContext with all indexer data
155
- */
156
- parseTransaction(txOrTxid: Transaction | string, isBroadcasted?: boolean): Promise<ParseContext>;
157
- /**
158
- * Parse a single output without full transaction context.
159
- * Runs all indexers' parse() methods but NOT summarize().
160
- *
161
- * @param output - The TransactionOutput to parse
162
- * @param outpoint - The outpoint identifying this output
163
- * @returns Txo with all indexer data populated
164
- */
165
- parseOutput(output: Transaction["outputs"][0], outpoint: Outpoint): Promise<Txo>;
166
- /**
167
- * Load and parse a single output by outpoint.
168
- * Loads the transaction, extracts the output, and runs indexers on it.
169
- *
170
- * @param outpoint - Outpoint string (txid_vout)
171
- * @returns Txo with all indexer data populated
172
- */
173
- loadTxo(outpoint: string): Promise<Txo>;
174
- /**
175
- * Run all indexers on a single Txo and populate its data/owner/basket
176
- */
177
- runIndexersOnTxo(txo: Txo): Promise<void>;
178
- /**
179
- * Parse all inputs - run indexers on source outputs to populate ctx.spends
180
- */
181
- private parseInputs;
182
- /**
183
- * Load a transaction by txid.
184
- * Checks storage first, falls back to beef service.
185
- *
186
- * @param txid - Transaction ID to load
187
- * @returns Transaction (without source transactions hydrated)
188
- */
189
- loadTransaction(txid: string): Promise<Transaction>;
190
- /**
191
- * Load and attach source transactions for all inputs (1 level deep).
192
- * Modifies the transaction in place.
193
- */
194
- hydrateSourceTransactions(tx: Transaction): Promise<void>;
195
- /**
196
- * Build minimal parse context from transaction
197
- */
198
- buildParseContext(tx: Transaction): ParseContext;
199
- /**
200
- * Calculate the byte offset and length of each output's locking script
201
- * within the raw transaction binary. This is needed for wallet-toolbox's
202
- * listOutputs to extract locking scripts on demand.
203
- */
204
- private calculateScriptOffsets;
205
- /**
206
- * Ingest a transaction by running it through indexers and writing directly to storage.
207
- *
208
- * This is the main entry point for adding external transactions to the wallet.
209
- * The indexers extract basket, tags, and custom instructions which are then
210
- * written directly to the wallet's storage.
211
- *
212
- * Unlike internalizeAction, this method also marks any wallet outputs that are
213
- * consumed as inputs in the transaction as spent (spentBy, spendable: false).
214
- *
215
- * @param tx - Transaction to ingest
216
- * @param description - Human-readable description
217
- * @param labels - Optional labels for the transaction
218
- * @param isBroadcasted - Whether this transaction has been broadcast (affects validation)
219
- * @returns Result including parse details for all outputs
220
- */
221
- ingestTransaction(tx: Transaction, description: string, labels?: string[], isBroadcasted?: boolean): Promise<IngestResult>;
222
- /**
223
- * Broadcast a transaction and ingest it into the wallet if successful.
224
- *
225
- * @param tx - Transaction to broadcast
226
- * @param description - Human-readable description for the transaction
227
- * @param labels - Optional labels for the transaction
228
- * @returns The ingest result if successful
229
- * @throws Error if broadcast fails
230
- */
231
- broadcast(tx: Transaction, description: string, labels?: string[]): Promise<IngestResult>;
232
- /**
233
- * Start queue-based sync for all owner addresses.
234
- * Requires syncQueue to be provided in constructor args.
235
- *
236
- * This method:
237
- * 1. Opens SSE stream and enqueues outputs
238
- * 2. Processes queue in batches using Promise.all()
239
- * 3. Continues until queue is empty and stream is done
240
- */
241
- sync(): Promise<void>;
242
- /**
243
- * Handle a single output from the SSE stream.
244
- * Enqueues to the sync queue and updates lastQueuedScore with reorg protection.
245
- */
246
- private handleSyncOutput;
247
- /**
248
- * Process queue in batches until empty or stopped.
249
- */
250
- private processQueueLoop;
251
- /**
252
- * Group queue items by txid.
253
- * @deprecated - claim() now returns items already grouped
254
- */
255
- private groupItemsByTxid;
256
- /**
257
- * Process a single txid - ingest transaction and complete queue items.
258
- * Items are already marked as "processing" by claim().
259
- */
260
- private processTxid;
261
- /**
262
- * Ingest a transaction with knowledge of which outputs are already spent.
263
- */
264
- private ingestWithSpendInfo;
265
- /**
266
- * Mark outputs as spent for spend-only queue items.
267
- */
268
- private markOutputsSpent;
269
- /**
270
- * Stop the sync.
271
- */
272
- stopSync(): void;
273
- /**
274
- * Close the wallet and cleanup all sync connections.
275
- */
276
- close(): void;
277
- /**
278
- * Check if sync is currently running.
279
- */
280
- isSyncing(): boolean;
281
- /**
282
- * Get the sync queue instance (if provided).
283
- */
284
- getQueue(): SyncQueueStorage | null;
285
- /**
286
- * Start only the SSE stream, enqueueing outputs without processing.
287
- * Useful for testing to observe queue buildup.
288
- */
289
- startStream(): Promise<void>;
290
- /**
291
- * Stop the SSE stream.
292
- */
293
- stopStream(): void;
294
- /**
295
- * Check if SSE stream is active.
296
- */
297
- isStreamActive(): boolean;
298
- /**
299
- * Check if SSE stream has completed.
300
- */
301
- isStreamDone(): boolean;
302
- /**
303
- * Start only the queue processor, without starting a new SSE stream.
304
- * Useful for testing to process queued items independently.
305
- */
306
- startProcessor(): Promise<void>;
307
- /**
308
- * Stop the queue processor.
309
- */
310
- stopProcessor(): void;
311
- /**
312
- * Check if queue processor is active.
313
- */
314
- isProcessorActive(): boolean;
315
- }
316
- export {};