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