openclaw-overlay-plugin 0.8.35 → 0.8.40

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/index.js CHANGED
@@ -135343,6 +135343,33 @@ var BSVAgentWallet = class _BSVAgentWallet {
135343
135343
  async getBalance() {
135344
135344
  return await this._setup.wallet.balance();
135345
135345
  }
135346
+ /**
135347
+ * Import a raw transaction into the wallet.
135348
+ * Useful for manual funding or recovery.
135349
+ */
135350
+ async importRawTx(hex) {
135351
+ log("Importing raw transaction");
135352
+ const result = await this._setup.wallet.internalizeAction({
135353
+ tx: hex,
135354
+ // Cast to avoid AtomicBEEF vs string mismatch in older SDK versions
135355
+ description: "manual import"
135356
+ });
135357
+ return { success: result.accepted, txid: result.txid || "" };
135358
+ }
135359
+ /**
135360
+ * Import a specific UTXO by TXID and Output Index.
135361
+ * This will fetch the transaction data and add it to the wallet storage.
135362
+ */
135363
+ async importUtxo(txid, vout) {
135364
+ log("Importing UTXO: %s:%d", txid, vout);
135365
+ try {
135366
+ await this._setup.wallet.importOutput({ txid, vout });
135367
+ return { success: true };
135368
+ } catch (err) {
135369
+ log("UTXO import failed: %s", err.message);
135370
+ throw err;
135371
+ }
135372
+ }
135346
135373
  /**
135347
135374
  * Cleanly shut down the wallet, releasing database connections and
135348
135375
  * stopping the background monitor.
@@ -136843,7 +136870,7 @@ function checkBudget(walletDir, requestedSats, dailyLimit) {
136843
136870
  };
136844
136871
  }
136845
136872
  function register(api) {
136846
- const version = "0.8.35";
136873
+ const version = "0.8.40";
136847
136874
  if (isInitialized) return;
136848
136875
  isInitialized = true;
136849
136876
  const config = api.pluginConfig || {};
@@ -137027,6 +137054,21 @@ ${JSON.stringify(event.result, null, 2)}`;
137027
137054
  const { requestId, recipientKey, serviceId, result } = params;
137028
137055
  return (await cmdRespondService(requestId, recipientKey, serviceId, JSON.stringify(result))).data;
137029
137056
  }
137057
+ case "import_utxo": {
137058
+ if (!params.txid) throw new Error("txid required");
137059
+ const vout = params.vout !== void 0 ? parseInt(params.vout, 10) : 0;
137060
+ const wallet = await BSVAgentWallet.load({ network, storageDir: walletDir });
137061
+ const result = await wallet.importUtxo(params.txid, vout);
137062
+ await wallet.destroy();
137063
+ return { success: true, message: "UTXO imported" };
137064
+ }
137065
+ case "import_raw_tx": {
137066
+ if (!params.txhex) throw new Error("txhex required");
137067
+ const wallet = await BSVAgentWallet.load({ network, storageDir: walletDir });
137068
+ const result = await wallet.importRawTx(params.txhex);
137069
+ await wallet.destroy();
137070
+ return result;
137071
+ }
137030
137072
  case "unregister":
137031
137073
  return (await cmdUnregister()).data;
137032
137074
  default:
@@ -137039,7 +137081,7 @@ ${JSON.stringify(event.result, null, 2)}`;
137039
137081
  parameters: {
137040
137082
  type: "object",
137041
137083
  properties: {
137042
- action: { type: "string", enum: ["request", "discover", "balance", "status", "pay", "onboard", "pending-requests", "fulfill", "unregister"] },
137084
+ action: { type: "string", enum: ["request", "discover", "balance", "status", "pay", "onboard", "pending-requests", "fulfill", "unregister", "import_utxo", "import_raw_tx"] },
137043
137085
  service: { type: "string" },
137044
137086
  input: { type: "object" },
137045
137087
  identityKey: { type: "string" },
@@ -137047,7 +137089,10 @@ ${JSON.stringify(event.result, null, 2)}`;
137047
137089
  requestId: { type: "string" },
137048
137090
  recipientKey: { type: "string" },
137049
137091
  serviceId: { type: "string" },
137050
- result: { type: "object" }
137092
+ result: { type: "object" },
137093
+ txid: { type: "string" },
137094
+ vout: { type: "number" },
137095
+ txhex: { type: "string" }
137051
137096
  },
137052
137097
  required: ["action"]
137053
137098
  },
@@ -137069,15 +137114,40 @@ ${JSON.stringify(event.result, null, 2)}`;
137069
137114
  api.logger?.info?.(`[openclaw-overlay] Command received with args: ${JSON.stringify(ctx.args)} (type: ${typeof ctx.args})`);
137070
137115
  const args = Array.isArray(ctx.args) ? ctx.args : typeof ctx.args === "string" ? ctx.args.split(" ").filter(Boolean) : [];
137071
137116
  const action = args[0] || "status";
137117
+ if (action === "help") {
137118
+ return { text: `\u{1F30A} **Overlay Help**
137119
+
137120
+ **Subcommands**:
137121
+ - \`status\`: Show identity and balance
137122
+ - \`balance\`: Show wallet balance
137123
+ - \`discover\`: Find other agents
137124
+ - \`import <txid> [vout]\`: Import a UTXO
137125
+ - \`import-tx <hex>\`: Import raw transaction` };
137126
+ }
137127
+ if (action === "import" && args[1]) {
137128
+ const res = await executeOverlayAction({ action: "import_utxo", txid: args[1], vout: args[2] }, api);
137129
+ return { text: `\u2705 UTXO imported successfully.` };
137130
+ }
137072
137131
  const result = await executeOverlayAction({ action }, api);
137073
137132
  return { text: `**Overlay ${action.toUpperCase()}**
137074
137133
 
137075
- ${typeof result === "string" ? result : JSON.stringify(result, null, 2)}` };
137134
+ ${JSON.stringify(result, null, 2)}` };
137076
137135
  } catch (error) {
137077
137136
  return { text: `\u274C Error: ${error.message}` };
137078
137137
  }
137079
137138
  }
137080
137139
  });
137140
+ api.registerOnboarding({
137141
+ async finalize() {
137142
+ const wallet = await BSVAgentWallet.load({ network, storageDir: walletDir });
137143
+ const balance = await wallet.getBalance();
137144
+ await wallet.destroy();
137145
+ if (balance < 500) {
137146
+ api.logger.warn(`[overlay] Wallet has low balance (${balance} sats). Some features may be limited until funded.`);
137147
+ }
137148
+ return { success: true };
137149
+ }
137150
+ });
137081
137151
  api.registerService({
137082
137152
  id: "openclaw-overlay-relay",
137083
137153
  start: async () => {