cashubtc / nuts

Cashu protocol specifications https://cashubtc.github.io/nuts/
MIT License
152 stars 52 forks source link

NUT-XX: Cached Responses #195

Open lollerfirst opened 3 days ago

lollerfirst commented 3 days ago

Cache every successful PostMintResponse, PostMeltResponse and PostSwapResponse using the respective requests as keys. In case of a network error, clients can replay the same exact requests receive the same responses. This safe-guards against clients accidentally losing money because of connectivity issues.

Implementations:

callebtc commented 2 days ago

Awesome work and thank you for the implementations. I wonder whether we want to add this to the existing NUTs or formulate it as a separate NUT.

In both cases, I think it would be better to formulate this as an optional feature. Right now it is formulated as a MUST.

callebtc commented 2 days ago

One argument for putting this in its own NUT would be that we would have to add a note about caching into every method that we add (like bolt12) whereas it could be formulated more generally as "any endpoint that produces outputs" and we could reference the specific NUTs for mint/melt/swap (and further future methods).

This NUT should also defined a setting flag for each cached endpoint that we announce in the mint info (together with a TTL)

callebtc commented 2 days ago

There are two unrelated files in the PR.

Questions in my mind: