@1sat/wallet-node 0.0.1
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/createNodeWallet.d.ts +88 -0
- package/dist/createNodeWallet.d.ts.map +1 -0
- package/dist/createNodeWallet.js +251 -0
- package/dist/createNodeWallet.js.map +1 -0
- package/dist/fullSync.d.ts +37 -0
- package/dist/fullSync.d.ts.map +1 -0
- package/dist/fullSync.js +62 -0
- package/dist/fullSync.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory for creating node/server wallets.
|
|
3
|
+
*
|
|
4
|
+
* Analogous to createWebWallet but uses StorageKnex (SQLite or MySQL)
|
|
5
|
+
* instead of StorageIdb (IndexedDB) for CLI, agent, and server use cases.
|
|
6
|
+
*/
|
|
7
|
+
import { OneSatServices } from '@1sat/client';
|
|
8
|
+
import { PrivateKey } from '@bsv/sdk';
|
|
9
|
+
import { Monitor, StorageClient, Wallet, WalletStorageManager } from '@bsv/wallet-toolbox';
|
|
10
|
+
import { type Knex } from 'knex';
|
|
11
|
+
import { type FullSyncResult, type FullSyncStage } from './fullSync';
|
|
12
|
+
type Chain = 'main' | 'test';
|
|
13
|
+
/**
|
|
14
|
+
* Configuration for creating a node wallet.
|
|
15
|
+
*/
|
|
16
|
+
export interface NodeWalletConfig {
|
|
17
|
+
/** Private key - can be PrivateKey instance, WIF string, or hex string */
|
|
18
|
+
privateKey: PrivateKey | string;
|
|
19
|
+
/** Network: 'main' or 'test' */
|
|
20
|
+
chain: Chain;
|
|
21
|
+
/** Fee model. Default: { model: 'sat/kb', value: 100 } */
|
|
22
|
+
feeModel?: {
|
|
23
|
+
model: 'sat/kb';
|
|
24
|
+
value: number;
|
|
25
|
+
};
|
|
26
|
+
/** Remote storage URL. If provided, attempts to connect for cloud backup. */
|
|
27
|
+
remoteStorageUrl?: string;
|
|
28
|
+
/** Unique identifier for this storage instance. Must be persisted by the consuming application and reused across sessions. */
|
|
29
|
+
storageIdentityKey: string;
|
|
30
|
+
/** Knex configuration for database connection. Default: SQLite at ./wallet.db */
|
|
31
|
+
storage?: Knex.Config;
|
|
32
|
+
/** Callback when a transaction is broadcasted (called after remote sync if connected) */
|
|
33
|
+
onTransactionBroadcasted?: (txid: string) => void;
|
|
34
|
+
/** Callback when a transaction is proven (called after remote sync if connected) */
|
|
35
|
+
onTransactionProven?: (txid: string, blockHeight: number) => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Result of wallet creation.
|
|
39
|
+
*/
|
|
40
|
+
export interface NodeWalletResult {
|
|
41
|
+
/** Wallet instance */
|
|
42
|
+
wallet: Wallet;
|
|
43
|
+
/** 1Sat services for API access */
|
|
44
|
+
services: OneSatServices;
|
|
45
|
+
/** Monitor for transaction lifecycle (not started - call monitor.startTasks() when ready) */
|
|
46
|
+
monitor: Monitor;
|
|
47
|
+
/** Cleanup function - stops monitor, destroys wallet, closes database */
|
|
48
|
+
destroy: () => Promise<void>;
|
|
49
|
+
/** Full sync with remote backup (only available if remoteStorageUrl was provided and connected) */
|
|
50
|
+
fullSync?: (onProgress?: (stage: FullSyncStage, message: string) => void) => Promise<FullSyncResult>;
|
|
51
|
+
/** Storage manager (for debugging/diagnostics) */
|
|
52
|
+
storage: WalletStorageManager;
|
|
53
|
+
/** Remote storage client (for debugging/diagnostics, undefined if not connected) */
|
|
54
|
+
remoteStorage?: StorageClient;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create a node wallet with storage, services, and monitor.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* // SQLite (default)
|
|
62
|
+
* const { wallet, monitor, destroy } = await createNodeWallet({
|
|
63
|
+
* privateKey: 'L1...',
|
|
64
|
+
* chain: 'main',
|
|
65
|
+
* storageIdentityKey: 'my-cli-agent',
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* // MySQL
|
|
69
|
+
* const { wallet, monitor, destroy } = await createNodeWallet({
|
|
70
|
+
* privateKey: 'L1...',
|
|
71
|
+
* chain: 'main',
|
|
72
|
+
* storageIdentityKey: 'my-server',
|
|
73
|
+
* storage: {
|
|
74
|
+
* client: 'mysql2',
|
|
75
|
+
* connection: { host: '127.0.0.1', user: 'root', password: '...', database: 'wallet' },
|
|
76
|
+
* useNullAsDefault: true,
|
|
77
|
+
* },
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* monitor.startTasks();
|
|
81
|
+
*
|
|
82
|
+
* // When done
|
|
83
|
+
* await destroy();
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function createNodeWallet(config: NodeWalletConfig): Promise<NodeWalletResult>;
|
|
87
|
+
export {};
|
|
88
|
+
//# sourceMappingURL=createNodeWallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNodeWallet.d.ts","sourceRoot":"","sources":["../src/createNodeWallet.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAc,UAAU,EAAwB,MAAM,UAAU,CAAA;AAEvE,OAAO,EACN,OAAO,EAEP,aAAa,EAGb,MAAM,EACN,oBAAoB,EACpB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,KAAK,IAAI,EAAoB,MAAM,MAAM,CAAA;AAClD,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAY,MAAM,YAAY,CAAA;AAE9E,KAAK,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;AAY5B;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,0EAA0E;IAC1E,UAAU,EAAE,UAAU,GAAG,MAAM,CAAA;IAC/B,gCAAgC;IAChC,KAAK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|
|
4
|
+
* Analogous to createWebWallet but uses StorageKnex (SQLite or MySQL)
|
|
5
|
+
* instead of StorageIdb (IndexedDB) for CLI, agent, and server use cases.
|
|
6
|
+
*/
|
|
7
|
+
import { OneSatServices } from '@1sat/client';
|
|
8
|
+
import { KeyDeriver, PrivateKey } from '@bsv/sdk';
|
|
9
|
+
import { Monitor, Services, StorageClient, StorageKnex, StorageProvider, Wallet, WalletStorageManager, } from '@bsv/wallet-toolbox';
|
|
10
|
+
import { knex as makeKnex } from 'knex';
|
|
11
|
+
import { fullSync } from './fullSync';
|
|
12
|
+
const DEFAULT_STORAGE_NAME = 'wallet';
|
|
13
|
+
const DEFAULT_REMOTE_STORAGE_TIMEOUT = 5000;
|
|
14
|
+
const DEFAULT_FEE_MODEL = { model: 'sat/kb', value: 100 };
|
|
15
|
+
const DEFAULT_STORAGE = {
|
|
16
|
+
client: 'better-sqlite3',
|
|
17
|
+
connection: { filename: './wallet.db' },
|
|
18
|
+
useNullAsDefault: true,
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Parse a private key from various input formats.
|
|
22
|
+
* Supports PrivateKey instance, WIF string, or hex string.
|
|
23
|
+
*/
|
|
24
|
+
function parsePrivateKey(input) {
|
|
25
|
+
if (input instanceof PrivateKey) {
|
|
26
|
+
return input;
|
|
27
|
+
}
|
|
28
|
+
// Try WIF first (starts with 5, K, L for mainnet or c for testnet)
|
|
29
|
+
if (/^[5KLc][1-9A-HJ-NP-Za-km-z]{50,51}$/.test(input)) {
|
|
30
|
+
return PrivateKey.fromWif(input);
|
|
31
|
+
}
|
|
32
|
+
// Try hex (64 characters)
|
|
33
|
+
if (/^[0-9a-fA-F]{64}$/.test(input)) {
|
|
34
|
+
return new PrivateKey(input);
|
|
35
|
+
}
|
|
36
|
+
// Last resort - try WIF anyway
|
|
37
|
+
try {
|
|
38
|
+
return PrivateKey.fromWif(input);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
throw new Error('Invalid private key format. Expected PrivateKey instance, WIF string, or 64-char hex string.');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create a node wallet with storage, services, and monitor.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // SQLite (default)
|
|
50
|
+
* const { wallet, monitor, destroy } = await createNodeWallet({
|
|
51
|
+
* privateKey: 'L1...',
|
|
52
|
+
* chain: 'main',
|
|
53
|
+
* storageIdentityKey: 'my-cli-agent',
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* // MySQL
|
|
57
|
+
* const { wallet, monitor, destroy } = await createNodeWallet({
|
|
58
|
+
* privateKey: 'L1...',
|
|
59
|
+
* chain: 'main',
|
|
60
|
+
* storageIdentityKey: 'my-server',
|
|
61
|
+
* storage: {
|
|
62
|
+
* client: 'mysql2',
|
|
63
|
+
* connection: { host: '127.0.0.1', user: 'root', password: '...', database: 'wallet' },
|
|
64
|
+
* useNullAsDefault: true,
|
|
65
|
+
* },
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* monitor.startTasks();
|
|
69
|
+
*
|
|
70
|
+
* // When done
|
|
71
|
+
* await destroy();
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export async function createNodeWallet(config) {
|
|
75
|
+
const { chain } = config;
|
|
76
|
+
const feeModel = config.feeModel ?? DEFAULT_FEE_MODEL;
|
|
77
|
+
// 1. Parse private key and create KeyDeriver
|
|
78
|
+
const privateKey = parsePrivateKey(config.privateKey);
|
|
79
|
+
const identityPubKey = privateKey.toPublicKey().toString();
|
|
80
|
+
const keyDeriver = new KeyDeriver(privateKey);
|
|
81
|
+
// 2. Create fallback services and OneSatServices
|
|
82
|
+
const fallbackServices = new Services(chain);
|
|
83
|
+
const oneSatServices = new OneSatServices(chain, undefined, fallbackServices);
|
|
84
|
+
// 3. Create Knex instance and local storage
|
|
85
|
+
const knex = makeKnex(config.storage ?? DEFAULT_STORAGE);
|
|
86
|
+
const storageOptions = StorageProvider.createStorageBaseOptions(chain);
|
|
87
|
+
storageOptions.feeModel = feeModel;
|
|
88
|
+
const localStorage = new StorageKnex({ ...storageOptions, knex });
|
|
89
|
+
await localStorage.migrate(DEFAULT_STORAGE_NAME, config.storageIdentityKey);
|
|
90
|
+
// 4. Create storage manager with local-only storage initially
|
|
91
|
+
const storage = new WalletStorageManager(identityPubKey, localStorage, []);
|
|
92
|
+
await storage.makeAvailable();
|
|
93
|
+
// 5. Create wallet
|
|
94
|
+
const wallet = new Wallet({
|
|
95
|
+
chain,
|
|
96
|
+
keyDeriver,
|
|
97
|
+
storage,
|
|
98
|
+
services: oneSatServices,
|
|
99
|
+
});
|
|
100
|
+
// 6. Attempt remote storage connection
|
|
101
|
+
let remoteClient;
|
|
102
|
+
if (config.remoteStorageUrl) {
|
|
103
|
+
console.log(`[createNodeWallet] Attempting remote storage connection to ${config.remoteStorageUrl}`);
|
|
104
|
+
try {
|
|
105
|
+
remoteClient = new StorageClient(wallet, config.remoteStorageUrl);
|
|
106
|
+
const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error('Remote storage connection timeout')), DEFAULT_REMOTE_STORAGE_TIMEOUT));
|
|
107
|
+
await Promise.race([remoteClient.makeAvailable(), timeoutPromise]);
|
|
108
|
+
await storage.addWalletStorageProvider(remoteClient);
|
|
109
|
+
const remoteStorageKey = remoteClient.getSettings().storageIdentityKey;
|
|
110
|
+
const isActive = storage.getBackupStores().includes(remoteStorageKey);
|
|
111
|
+
if (isActive) {
|
|
112
|
+
console.log('[createNodeWallet] Remote backup connected (we are active)');
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
console.log('[createNodeWallet] Another device is active, performing full sync...');
|
|
116
|
+
await fullSync({
|
|
117
|
+
storage,
|
|
118
|
+
remoteStorage: remoteClient,
|
|
119
|
+
identityKey: identityPubKey,
|
|
120
|
+
onProgress: (stage, msg) => console.log(`[createNodeWallet] fullSync ${stage}: ${msg}`),
|
|
121
|
+
});
|
|
122
|
+
await storage.setActive(config.storageIdentityKey, (msg) => {
|
|
123
|
+
console.log('[createNodeWallet] setActive:', msg);
|
|
124
|
+
return msg;
|
|
125
|
+
});
|
|
126
|
+
console.log('[createNodeWallet] Remote backup connected (now active after handoff)');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
console.log('[createNodeWallet] Remote backup connection failed:', err instanceof Error ? err.message : err);
|
|
131
|
+
remoteClient = undefined;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// 7. Helper to sync to remote backup
|
|
135
|
+
const syncToBackup = async (context) => {
|
|
136
|
+
if (storage.getBackupStores().length > 0) {
|
|
137
|
+
await storage.updateBackups(undefined, (msg) => {
|
|
138
|
+
console.log(`[createNodeWallet] ${context}:`, msg);
|
|
139
|
+
return msg;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
// 8. Intercept createAction/signAction to sync after immediate broadcasts
|
|
144
|
+
if (remoteClient) {
|
|
145
|
+
const originalCreateAction = wallet.createAction.bind(wallet);
|
|
146
|
+
wallet.createAction = async (args) => {
|
|
147
|
+
const result = await originalCreateAction(args);
|
|
148
|
+
if (result.txid) {
|
|
149
|
+
console.log('[createNodeWallet] Broadcast detected in createAction:', result.txid);
|
|
150
|
+
syncToBackup('Backup after createAction').catch((err) => {
|
|
151
|
+
console.warn('[createNodeWallet] Failed to sync after createAction:', err);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
155
|
+
};
|
|
156
|
+
const originalSignAction = wallet.signAction.bind(wallet);
|
|
157
|
+
wallet.signAction = async (args) => {
|
|
158
|
+
const result = await originalSignAction(args);
|
|
159
|
+
if (result.txid) {
|
|
160
|
+
console.log('[createNodeWallet] Broadcast detected in signAction:', result.txid);
|
|
161
|
+
syncToBackup('Backup after signAction').catch((err) => {
|
|
162
|
+
console.warn('[createNodeWallet] Failed to sync after signAction:', err);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
return result;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
// 9. Create monitor (not started - consumer calls startTasks() when ready)
|
|
169
|
+
const monitor = new Monitor({
|
|
170
|
+
chain,
|
|
171
|
+
services: oneSatServices,
|
|
172
|
+
storage,
|
|
173
|
+
chaintracks: oneSatServices.chaintracks,
|
|
174
|
+
msecsWaitPerMerkleProofServiceReq: 500,
|
|
175
|
+
taskRunWaitMsecs: 5000,
|
|
176
|
+
abandonedMsecs: 300000,
|
|
177
|
+
unprovenAttemptsLimitTest: 10,
|
|
178
|
+
unprovenAttemptsLimitMain: 144,
|
|
179
|
+
});
|
|
180
|
+
monitor.addDefaultTasks();
|
|
181
|
+
console.log('[createNodeWallet] Monitor created with tasks:', monitor._tasks.map((t) => t.name));
|
|
182
|
+
// 10. Wire up monitor callbacks
|
|
183
|
+
monitor.onTransactionBroadcasted = async (result) => {
|
|
184
|
+
console.log('[createNodeWallet] Monitor detected broadcast:', result.txid);
|
|
185
|
+
if (remoteClient) {
|
|
186
|
+
try {
|
|
187
|
+
await syncToBackup('Backup after monitor broadcast');
|
|
188
|
+
console.log('[createNodeWallet] Synced to backup after monitor broadcast');
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
console.warn('[createNodeWallet] Failed to sync after monitor broadcast:', err);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (result.txid && config.onTransactionBroadcasted) {
|
|
195
|
+
try {
|
|
196
|
+
config.onTransactionBroadcasted(result.txid);
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
console.warn('[createNodeWallet] User callback error after broadcast:', err);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
monitor.onTransactionProven = async (status) => {
|
|
204
|
+
console.log('[createNodeWallet] Transaction proven:', status.txid, 'block', status.blockHeight);
|
|
205
|
+
if (remoteClient) {
|
|
206
|
+
try {
|
|
207
|
+
await syncToBackup('Backup after confirmation');
|
|
208
|
+
console.log('[createNodeWallet] Synced to backup after confirmation');
|
|
209
|
+
}
|
|
210
|
+
catch (err) {
|
|
211
|
+
console.warn('[createNodeWallet] Failed to sync after confirmation:', err);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (config.onTransactionProven) {
|
|
215
|
+
try {
|
|
216
|
+
config.onTransactionProven(status.txid, status.blockHeight);
|
|
217
|
+
}
|
|
218
|
+
catch (err) {
|
|
219
|
+
console.warn('[createNodeWallet] User callback error after proven:', err);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
// 11. Create cleanup function
|
|
224
|
+
const destroy = async () => {
|
|
225
|
+
monitor.stopTasks();
|
|
226
|
+
await monitor.destroy();
|
|
227
|
+
await wallet.destroy();
|
|
228
|
+
await knex.destroy();
|
|
229
|
+
};
|
|
230
|
+
// 12. Create fullSync function if remote storage is connected
|
|
231
|
+
const fullSyncFn = remoteClient
|
|
232
|
+
? async (onProgress) => {
|
|
233
|
+
return fullSync({
|
|
234
|
+
storage,
|
|
235
|
+
remoteStorage: remoteClient,
|
|
236
|
+
identityKey: identityPubKey,
|
|
237
|
+
onProgress,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
: undefined;
|
|
241
|
+
return {
|
|
242
|
+
wallet,
|
|
243
|
+
services: oneSatServices,
|
|
244
|
+
monitor,
|
|
245
|
+
destroy,
|
|
246
|
+
fullSync: fullSyncFn,
|
|
247
|
+
storage,
|
|
248
|
+
remoteStorage: remoteClient,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=createNodeWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNodeWallet.js","sourceRoot":"","sources":["../src/createNodeWallet.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE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CAAC,IAAI,CACX,sDAAsD,EACtD,GAAG,CACH,CAAA;YACF,CAAC;QACF,CAAC;IACF,CAAC,CAAA;IAED,8BAA8B;IAC9B,MAAM,OAAO,GAAG,KAAK,IAAmB,EAAE;QACzC,OAAO,CAAC,SAAS,EAAE,CAAA;QACnB,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;QACvB,MAAM,MAAM,CAAC,OAAO,EAAE,CAAA;QACtB,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;IACrB,CAAC,CAAA;IAED,8DAA8D;IAC9D,MAAM,UAAU,GAAG,YAAY;QAC9B,CAAC,CAAC,KAAK,EACL,UAA4D,EAClC,EAAE;YAC5B,OAAO,QAAQ,CAAC;gBACf,OAAO;gBACP,aAAa,EAAE,YAAY;gBAC3B,WAAW,EAAE,cAAc;gBAC3B,UAAU;aACV,CAAC,CAAA;QACH,CAAC;QACF,CAAC,CAAC,SAAS,CAAA;IAEZ,OAAO;QACN,MAAM;QACN,QAAQ,EAAE,cAAc;QACxB,OAAO;QACP,OAAO;QACP,QAAQ,EAAE,UAAU;QACpB,OAAO;QACP,aAAa,EAAE,YAAY;KAC3B,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Full wallet synchronization with remote backup server.
|
|
3
|
+
*
|
|
4
|
+
* Performs a complete resync: push local -> reset sync state -> full pull from server.
|
|
5
|
+
* This is a deliberate user action (not automatic) for recovering from sync issues.
|
|
6
|
+
*/
|
|
7
|
+
import type { WalletStorageManager } from '@bsv/wallet-toolbox';
|
|
8
|
+
import type { sdk as toolboxSdk } from '@bsv/wallet-toolbox';
|
|
9
|
+
type WalletStorageProvider = toolboxSdk.WalletStorageProvider;
|
|
10
|
+
export type FullSyncStage = 'pushing' | 'resetting' | 'pulling' | 'complete';
|
|
11
|
+
export interface FullSyncOptions {
|
|
12
|
+
/** Local storage manager */
|
|
13
|
+
storage: WalletStorageManager;
|
|
14
|
+
/** Remote backup storage provider (StorageClient) */
|
|
15
|
+
remoteStorage: WalletStorageProvider;
|
|
16
|
+
/** Identity key for the wallet */
|
|
17
|
+
identityKey: string;
|
|
18
|
+
/** Optional progress callback */
|
|
19
|
+
onProgress?: (stage: FullSyncStage, message: string) => void;
|
|
20
|
+
/** Max rough size per chunk in bytes (default: 1MB) */
|
|
21
|
+
maxRoughSize?: number;
|
|
22
|
+
/** Max items per chunk (default: 100) */
|
|
23
|
+
maxItems?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface FullSyncResult {
|
|
26
|
+
pushed: {
|
|
27
|
+
inserts: number;
|
|
28
|
+
updates: number;
|
|
29
|
+
};
|
|
30
|
+
pulled: {
|
|
31
|
+
inserts: number;
|
|
32
|
+
updates: number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export declare function fullSync(options: FullSyncOptions): Promise<FullSyncResult>;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=fullSync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fullSync.d.ts","sourceRoot":"","sources":["../src/fullSync.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,KAAK,EAAE,GAAG,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAI5D,KAAK,qBAAqB,GAAG,UAAU,CAAC,qBAAqB,CAAA;AAE7D,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAA;AAE5E,MAAM,WAAW,eAAe;IAC/B,4BAA4B;IAC5B,OAAO,EAAE,oBAAoB,CAAA;IAC7B,qDAAqD;IACrD,aAAa,EAAE,qBAAqB,CAAA;IACpC,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,iCAAiC;IACjC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5D,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5C,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAC5C;AAED,wBAAsB,QAAQ,CAC7B,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,cAAc,CAAC,CAgGzB"}
|
package/dist/fullSync.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Full wallet synchronization with remote backup server.
|
|
3
|
+
*
|
|
4
|
+
* Performs a complete resync: push local -> reset sync state -> full pull from server.
|
|
5
|
+
* This is a deliberate user action (not automatic) for recovering from sync issues.
|
|
6
|
+
*/
|
|
7
|
+
import { createSyncMap } from '@bsv/wallet-toolbox/out/src/storage/schema/entities/EntityBase.js';
|
|
8
|
+
import { EntitySyncState } from '@bsv/wallet-toolbox/out/src/storage/schema/entities/EntitySyncState.js';
|
|
9
|
+
export async function fullSync(options) {
|
|
10
|
+
const { storage, remoteStorage, identityKey, onProgress, maxRoughSize = 1000000, maxItems = 100, } = options;
|
|
11
|
+
onProgress?.('pushing', 'Pushing local data to remote...');
|
|
12
|
+
const localSettings = storage.getSettings();
|
|
13
|
+
const remoteSettings = await remoteStorage.makeAvailable();
|
|
14
|
+
let pushInserts = 0;
|
|
15
|
+
let pushUpdates = 0;
|
|
16
|
+
let chunkCount = 0;
|
|
17
|
+
for (;;) {
|
|
18
|
+
const ss = await EntitySyncState.fromStorage(remoteStorage, identityKey, localSettings);
|
|
19
|
+
const args = ss.makeRequestSyncChunkArgs(identityKey, remoteSettings.storageIdentityKey, maxRoughSize, maxItems);
|
|
20
|
+
args.since = undefined;
|
|
21
|
+
const chunk = await storage.runAsSync(async (sync) => sync.getSyncChunk(args));
|
|
22
|
+
const result = await remoteStorage.processSyncChunk(args, chunk);
|
|
23
|
+
pushInserts += result.inserts;
|
|
24
|
+
pushUpdates += result.updates;
|
|
25
|
+
chunkCount++;
|
|
26
|
+
onProgress?.('pushing', `Chunk ${chunkCount}: ${result.inserts} inserts, ${result.updates} updates`);
|
|
27
|
+
if (result.done)
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
onProgress?.('pushing', `Pushed ${pushInserts} inserts, ${pushUpdates} updates`);
|
|
31
|
+
onProgress?.('resetting', 'Resetting sync state...');
|
|
32
|
+
const auth = await storage.getAuth();
|
|
33
|
+
await storage.runAsStorageProvider(async (active) => {
|
|
34
|
+
const syncStates = await active.findSyncStates({
|
|
35
|
+
partial: {
|
|
36
|
+
userId: auth.userId,
|
|
37
|
+
storageIdentityKey: remoteSettings.storageIdentityKey,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
if (syncStates.length > 0) {
|
|
41
|
+
const syncState = syncStates[0];
|
|
42
|
+
await active.updateSyncState(syncState.syncStateId, {
|
|
43
|
+
syncMap: JSON.stringify(createSyncMap()),
|
|
44
|
+
when: undefined,
|
|
45
|
+
status: 'unknown',
|
|
46
|
+
});
|
|
47
|
+
onProgress?.('resetting', 'Sync state reset complete');
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
onProgress?.('resetting', 'No existing sync state found');
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
onProgress?.('pulling', 'Pulling all data from remote...');
|
|
54
|
+
const pullResult = await storage.syncFromReader(identityKey, remoteStorage);
|
|
55
|
+
onProgress?.('pulling', `Pulled ${pullResult.inserts} inserts, ${pullResult.updates} updates`);
|
|
56
|
+
onProgress?.('complete', 'Full sync complete');
|
|
57
|
+
return {
|
|
58
|
+
pushed: { inserts: pushInserts, updates: pushUpdates },
|
|
59
|
+
pulled: { inserts: pullResult.inserts, updates: pullResult.updates },
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=fullSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fullSync.js","sourceRoot":"","sources":["../src/fullSync.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,mEAAmE,CAAA;AACjG,OAAO,EAAE,eAAe,EAAE,MAAM,wEAAwE,CAAA;AA0BxG,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC7B,OAAwB;IAExB,MAAM,EACL,OAAO,EACP,aAAa,EACb,WAAW,EACX,UAAU,EACV,YAAY,GAAG,OAAO,EACtB,QAAQ,GAAG,GAAG,GACd,GAAG,OAAO,CAAA;IAEX,UAAU,EAAE,CAAC,SAAS,EAAE,iCAAiC,CAAC,CAAA;IAE1D,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,EAAE,CAAA;IAC3C,MAAM,cAAc,GAAG,MAAM,aAAa,CAAC,aAAa,EAAE,CAAA;IAE1D,IAAI,WAAW,GAAG,CAAC,CAAA;IACnB,IAAI,WAAW,GAAG,CAAC,CAAA;IACnB,IAAI,UAAU,GAAG,CAAC,CAAA;IAElB,SAAS,CAAC;QACT,MAAM,EAAE,GAAG,MAAM,eAAe,CAAC,WAAW,CAC3C,aAAa,EACb,WAAW,EACX,aAAa,CACb,CAAA;QACD,MAAM,IAAI,GAAG,EAAE,CAAC,wBAAwB,CACvC,WAAW,EACX,cAAc,CAAC,kBAAkB,EACjC,YAAY,EACZ,QAAQ,CACR,CAAA;QAED,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;QAEtB,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CACpD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CACvB,CAAA;QAED,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,gB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UAAU,EAAE,CAAC,SAAS,EAAE,iCAAiC,CAAC,CAAA;IAE1D,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,aAAa,CAAC,CAAA;IAE3E,UAAU,EAAE,CACX,SAAS,EACT,UAAU,UAAU,CAAC,OAAO,aAAa,UAAU,CAAC,OAAO,UAAU,CACrE,CAAA;IAED,UAAU,EAAE,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAA;IAE9C,OAAO;QACN,MAAM,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE;QACtD,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE;KACpE,CAAA;AACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @1sat/wallet-node - Node/Bun wallet factory for 1Sat Ordinals SDK
|
|
3
|
+
*
|
|
4
|
+
* This package provides the Node-specific wallet factory using Knex storage (SQLite/MySQL).
|
|
5
|
+
*/
|
|
6
|
+
export * from '@1sat/wallet';
|
|
7
|
+
export { createNodeWallet } from './createNodeWallet';
|
|
8
|
+
export type { NodeWalletConfig, NodeWalletResult } from './createNodeWallet';
|
|
9
|
+
export { fullSync } from './fullSync';
|
|
10
|
+
export type { FullSyncOptions, FullSyncResult, FullSyncStage } from './fullSync';
|
|
11
|
+
export { Monitor, Services, StorageClient, StorageKnex, StorageProvider, StorageSqlite, Wallet, WalletStorageManager, type sdk as walletSdk, } from '@bsv/wallet-toolbox';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,cAAc,CAAA;AAG5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAG5E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAGhF,OAAO,EACN,OAAO,EACP,QAAQ,EACR,aAAa,EACb,WAAW,EACX,eAAe,EACf,aAAa,EACb,MAAM,EACN,oBAAoB,EACpB,KAAK,GAAG,IAAI,SAAS,GACrB,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @1sat/wallet-node - Node/Bun wallet factory for 1Sat Ordinals SDK
|
|
3
|
+
*
|
|
4
|
+
* This package provides the Node-specific wallet factory using Knex storage (SQLite/MySQL).
|
|
5
|
+
*/
|
|
6
|
+
// Re-export everything from base wallet
|
|
7
|
+
export * from '@1sat/wallet';
|
|
8
|
+
// Node-specific factory
|
|
9
|
+
export { createNodeWallet } from './createNodeWallet';
|
|
10
|
+
// Full sync
|
|
11
|
+
export { fullSync } from './fullSync';
|
|
12
|
+
// Re-export node toolbox utilities
|
|
13
|
+
export { Monitor, Services, StorageClient, StorageKnex, StorageProvider, StorageSqlite, Wallet, WalletStorageManager, } from '@bsv/wallet-toolbox';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wCAAwC;AACxC,cAAc,cAAc,CAAA;AAE5B,wBAAwB;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGrD,YAAY;AACZ,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAGrC,mCAAmC;AACnC,OAAO,EACN,OAAO,EACP,QAAQ,EACR,aAAa,EACb,WAAW,EACX,eAAe,EACf,aAAa,EACb,MAAM,EACN,oBAAoB,GAEpB,MAAM,qBAAqB,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@1sat/wallet-node",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Node/Bun wallet factory for 1Sat Ordinals SDK",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": ["dist"],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"dev": "tsc --watch",
|
|
18
|
+
"clean": "rm -rf dist"
|
|
19
|
+
},
|
|
20
|
+
"keywords": ["1sat", "bsv", "ordinals", "wallet", "node", "server", "cli"],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@1sat/wallet": "^0.0.5"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@bsv/sdk": "^1.10.4",
|
|
27
|
+
"@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@1.7.24-idb-fix.1",
|
|
28
|
+
"knex": "^3.0.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@bsv/sdk": "^1.10.4",
|
|
32
|
+
"@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@1.7.24-idb-fix.1",
|
|
33
|
+
"knex": "^3.1.0",
|
|
34
|
+
"typescript": "^5.9.3"
|
|
35
|
+
}
|
|
36
|
+
}
|