cashubtc / cdk

Cashu Development Kit
MIT License
88 stars 45 forks source link

The KeysetId of v1 api parse failed, it's not hex string #89

Closed biluohc closed 7 months ago

biluohc commented 7 months ago

curl -X GET https://8333.space:3338/v1/keys

{"keysets":[{"id":"I2yN+iRYfkzT","unit":"sat","keys":{"1":"03ba786a2c0745f8c30e490288acd7a72dd53d65afd292ddefa326a4a3fa14c566","2":"03361cd8bd1329fea797a6add1cf1990ffcf2270ceb9fc81eeee0e8e9c1bd0cdf5","4":"036e37..

It's version is Nutshell/0.15.2

curl -X GET https://8333.space:3338/v1/info

{"name":"Cashu test mint","pubkey":"03e3d23e1b66eadaf15ce0d640a908e8ba1984baed34ab98c547aab4cf4249440d","version":"Nutshell/0.15.2","description":"This mint is for testing and development purposes only. Do not use this mint as a default mint in your application! Please use it with caution and only with very small amounts. Your Cashu client could have bugs. Accidents and bugs can lead to loss of funds for which we are not responsible for.","contact":[["",""]],"nuts":{"4":{"methods":[{"method":"bolt11","unit":"sat","min_amount":0,"max_amount":500000}],"disabled":false},"5":{"methods":[{"method":"bolt11","unit":"sat","min_amount":0,"max_amount":500000}],"disabled":false},"7":{"supported":true},"8":{"supported":true},"9":{"supported":true},"10":{"supported":true},"11":{"supported":true},"12":{"supported":true}}}
thesimplekid commented 7 months ago

This is isn't a V1 keyset id so it should fail. Nutshell shouldn't be returning the old keyset ids on the v1 endpoint.

To get around this until its fixed I handle it by ignoring non V1 keysets in the /keysets request and then the specific keys can be requested via the /keys/{keyset_id} endpoint. But would like to take this out as well. https://github.com/thesimplekid/cashu-crab/blob/664776f1224840c2f7ab944348e6bf534ff993f2/crates/cdk/src/nuts/nut02.rs#L174-L176

I opened an issue in nutshell https://github.com/cashubtc/nutshell/issues/512

thesimplekid commented 7 months ago

Since nutshell does not plan to fix this I updated to now ignore pre v1 keysets ids in the response but not error. #90