Closed plebhash closed 1 month ago
the mine JSON-RPC method allows a buyer to submit:
mine
$ curl -s -X POST \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "mine", "params": { "event": { "pubkey": "98590c0f4959a49f3524b7c009c190798935eeaa50b1232ba74195b419eaa2f2", "created_at": 1668680774, "kind": 1, "tags": [], "content": "hello world" }, "difficulty": 15, "zap": "f481897ee877321783bb76133622b3cc344d691bb79cd6be88f44e819c3b2306" }, "id": 1 }' \ http://localhost:1337
it is assumed that the buyer has previously called the quote JSON-RPC method, so they know how many sats they should send in the zap.
quote
but maybe they send an invalid zap, or the zap does not have enough sats.
so the JSON-RPC handler needs to validate the zap before it starts mining: https://github.com/plebemineira/notemine_hw/blob/ade25cbb4b75fb8d05e56a10c7a211dae454191c/src/lib/service.rs#L101-L111
currently, verify_zap has a dummy placeholder implementation: https://github.com/plebemineira/notemine_hw/blob/759177453006f8b9a0ae6c18c51c342ebc491dfa/src/lib/sell.rs#L7-L25
verify_zap
this implementation should leverage nostr-zapper crate to actually verify if:
nostr-zapper
zap
pow_price
only if those two verifications are succesful, should we start mining
https://nostr.how/en/zaps
the
mine
JSON-RPC method allows a buyer to submit:it is assumed that the buyer has previously called the
quote
JSON-RPC method, so they know how many sats they should send in the zap.but maybe they send an invalid zap, or the zap does not have enough sats.
so the JSON-RPC handler needs to validate the zap before it starts mining: https://github.com/plebemineira/notemine_hw/blob/ade25cbb4b75fb8d05e56a10c7a211dae454191c/src/lib/service.rs#L101-L111
currently,
verify_zap
has a dummy placeholder implementation: https://github.com/plebemineira/notemine_hw/blob/759177453006f8b9a0ae6c18c51c342ebc491dfa/src/lib/sell.rs#L7-L25this implementation should leverage
nostr-zapper
crate to actually verify if:zap
is validzap
contains more sats thanpow_price
only if those two verifications are succesful, should we start mining