v0.0.45 - Display qrexec service name (qubes.NsignerRpc) in signer connection info; use human-readable timestamps in activity log; fix static release build by adding miner.c to Dockerfile.alpine-musl
This commit is contained in:
@@ -198,6 +198,48 @@ async function demoNip44(targetQube, nostrIndex, pubkeyHex) {
|
||||
}
|
||||
}
|
||||
|
||||
async function demoMineEvent(targetQube, nostrIndex) {
|
||||
console.log("\n--- Demo 4: mine_event (NIP-13 Proof-of-Work) ---");
|
||||
|
||||
const event = {
|
||||
kind: 1,
|
||||
content: "Hello Nostr with PoW!",
|
||||
tags: [],
|
||||
};
|
||||
|
||||
console.log(" Mining with difficulty=4, threads=4, timeout_sec=30...");
|
||||
const response = await callNsigner(targetQube, {
|
||||
id: "5",
|
||||
method: "mine_event",
|
||||
params: [JSON.stringify(event), {
|
||||
difficulty: 4,
|
||||
threads: 4,
|
||||
timeout_sec: 30,
|
||||
nostr_index: nostrIndex,
|
||||
}],
|
||||
});
|
||||
|
||||
if (response.error) {
|
||||
throw new Error(`mine_event failed: ${JSON.stringify(response.error)}`);
|
||||
}
|
||||
|
||||
const result = JSON.parse(response.result);
|
||||
console.log(` achieved_difficulty: ${result.achieved_difficulty}`);
|
||||
console.log(` target_reached: ${result.target_reached}`);
|
||||
console.log(` elapsed_sec: ${result.elapsed_sec}`);
|
||||
console.log(` attempts: ${result.attempts}`);
|
||||
|
||||
const minedEvent = JSON.parse(result.event);
|
||||
console.log(` event id: ${minedEvent.id}`);
|
||||
console.log(` nonce tag: ${JSON.stringify(minedEvent.tags[0])}`);
|
||||
|
||||
if (result.target_reached) {
|
||||
console.log(" ✓ Target difficulty reached!");
|
||||
} else {
|
||||
console.log(` (Target not reached, best effort: ${result.achieved_difficulty} bits)`);
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const targetQube = process.argv[2] || "nostr_signer";
|
||||
const nostrIndex = parseInt(process.argv[3] || "0", 10);
|
||||
@@ -212,6 +254,7 @@ async function main() {
|
||||
const pubkeyHex = await demoGetPublicKey(targetQube, nostrIndex);
|
||||
await demoSignEvent(targetQube, nostrIndex, pubkeyHex);
|
||||
await demoNip44(targetQube, nostrIndex, pubkeyHex);
|
||||
await demoMineEvent(targetQube, nostrIndex);
|
||||
|
||||
console.log("\n=== Summary ===");
|
||||
console.log("All demos completed successfully.");
|
||||
|
||||
Reference in New Issue
Block a user