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:
@@ -227,6 +227,45 @@ def demo_nip44(target_qube, nostr_index, pubkey_hex):
|
||||
raise RuntimeError("Round-trip FAILED: plaintext does not match decrypted")
|
||||
|
||||
|
||||
def demo_mine_event(target_qube, nostr_index):
|
||||
print("\n--- Demo 4: mine_event (NIP-13 Proof-of-Work) ---")
|
||||
|
||||
event = {"kind": 1, "content": "Hello Nostr with PoW!", "tags": []}
|
||||
|
||||
print(" Mining with difficulty=4, threads=4, timeout_sec=30...")
|
||||
response = call_nsigner(
|
||||
target_qube,
|
||||
{
|
||||
"id": "5",
|
||||
"method": "mine_event",
|
||||
"params": [json.dumps(event), {
|
||||
"difficulty": 4,
|
||||
"threads": 4,
|
||||
"timeout_sec": 30,
|
||||
"nostr_index": nostr_index,
|
||||
}],
|
||||
},
|
||||
)
|
||||
|
||||
if "error" in response:
|
||||
raise RuntimeError(f"mine_event failed: {json.dumps(response['error'])}")
|
||||
|
||||
result = json.loads(response["result"])
|
||||
print(f" achieved_difficulty: {result['achieved_difficulty']}")
|
||||
print(f" target_reached: {result['target_reached']}")
|
||||
print(f" elapsed_sec: {result['elapsed_sec']}")
|
||||
print(f" attempts: {result['attempts']}")
|
||||
|
||||
mined_event = json.loads(result["event"])
|
||||
print(f" event id: {mined_event['id']}")
|
||||
print(f" nonce tag: {mined_event['tags'][0]}")
|
||||
|
||||
if result["target_reached"]:
|
||||
print(" ✓ Target difficulty reached!")
|
||||
else:
|
||||
print(f" (Target not reached, best effort: {result['achieved_difficulty']} bits)")
|
||||
|
||||
|
||||
# --- Main ---
|
||||
|
||||
def main():
|
||||
@@ -243,6 +282,7 @@ def main():
|
||||
pubkey_hex = demo_get_public_key(target_qube, nostr_index)
|
||||
demo_sign_event(target_qube, nostr_index, pubkey_hex)
|
||||
demo_nip44(target_qube, nostr_index, pubkey_hex)
|
||||
demo_mine_event(target_qube, nostr_index)
|
||||
|
||||
print("\n=== Summary ===")
|
||||
print("All demos completed successfully.")
|
||||
|
||||
Reference in New Issue
Block a user