@1sat/wallet-toolbox 0.0.70 → 0.0.71

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.
@@ -92,9 +92,31 @@ export async function createWebWallet(config) {
92
92
  remoteClient = new StorageClient(underlyingWallet, config.remoteStorageUrl);
93
93
  const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error("Remote storage connection timeout")), DEFAULT_REMOTE_STORAGE_TIMEOUT));
94
94
  await Promise.race([remoteClient.makeAvailable(), timeoutPromise]);
95
- // Add remote as backup destination (push-only, no pull)
95
+ // Add remote to storage manager - it will partition as conflicting if another device is active
96
96
  await storage.addWalletStorageProvider(remoteClient);
97
- console.log("[createWebWallet] Remote backup connected");
97
+ // Check if remote ended up in backup stores (active) or got partitioned (conflicting)
98
+ const remoteStorageKey = remoteClient.getSettings().storageIdentityKey;
99
+ const isActive = storage.getBackupStores().includes(remoteStorageKey);
100
+ if (isActive) {
101
+ console.log("[createWebWallet] Remote backup connected (we are active)");
102
+ }
103
+ else {
104
+ // Another device is active - need fullSync then setActive
105
+ // fullSync builds ID mappings before setActive attempts to merge
106
+ console.log("[createWebWallet] Another device is active, performing full sync...");
107
+ await fullSync({
108
+ storage,
109
+ remoteStorage: remoteClient,
110
+ identityKey: identityPubKey,
111
+ onProgress: (stage, msg) => console.log(`[createWebWallet] fullSync ${stage}: ${msg}`),
112
+ });
113
+ // Claim active status (merge now works because mappings exist from fullSync)
114
+ await storage.setActive(config.storageIdentityKey, (msg) => {
115
+ console.log("[createWebWallet] setActive:", msg);
116
+ return msg;
117
+ });
118
+ console.log("[createWebWallet] Remote backup connected (now active after handoff)");
119
+ }
98
120
  }
99
121
  catch (err) {
100
122
  console.log("[createWebWallet] Remote backup connection failed:", err instanceof Error ? err.message : err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/wallet-toolbox",
3
- "version": "0.0.70",
3
+ "version": "0.0.71",
4
4
  "description": "BSV wallet library extending @bsv/wallet-toolbox with 1Sat Ordinals protocol support",
5
5
  "author": "1Sat Team",
6
6
  "license": "MIT",