Handling incorrect mint time #297

Open
opened 2025-10-17 12:56:37 +00:00 by thesimplekid · 2 comments
thesimplekid commented 2025-10-17 12:56:37 +00:00 (Migrated from github.com)

Currently in NUT-06 we optionally return the mint time (https://github.com/cashubtc/nuts/blob/main/06.md). We added this to the spec because a mint using an incorrect time could lead to the spending condition path being allowed when it shouldn't or the reverse. However, we do not define that this time must be correct or within some tolerance.

When I added this to the cdk wallet I put in a check that the returned time was within 30 seconds without much thought, but it seems this is causing issues with some mints that are returning delayed times (https://github.com/cashubtc/cdk/issues/1194) reported up to 20 minutes off.

Since there isn't a tolerance in the spec, I guess cdk shouldn't be doing this check however I think it's an important check for spending conditions. Should we add a tolerance to the spec? I guess then it becomes a question of who has the correct time.

Currently in NUT-06 we optionally return the mint time (https://github.com/cashubtc/nuts/blob/main/06.md). We added this to the spec because a mint using an incorrect time could lead to the spending condition path being allowed when it shouldn't or the reverse. However, we do not define that this time must be correct or within some tolerance. When I added this to the cdk wallet I put in a check that the returned time was within 30 seconds without much thought, but it seems this is causing issues with some mints that are returning delayed times (https://github.com/cashubtc/cdk/issues/1194) reported up to 20 minutes off. Since there isn't a tolerance in the spec, I guess cdk shouldn't be doing this check however I think it's an important check for spending conditions. Should we add a tolerance to the spec? I guess then it becomes a question of who has the correct time.
SatsAndSports commented 2025-10-17 13:52:03 +00:00 (Migrated from github.com)

My latest update, I think 21mint is doing caching:

First, all mints are synced with each other and with my laptop here:

$ date +%s ; for mint in https://21mint.me https://mint.minibits.cash/Bitcoin https://testnut.cashu.space https://8333.space:3338  https://nofees.testnut.cashu.space https://mint.coinos.io; do curl -s $mint/v1/info | jq .time | tr -d '\n'; echo " ${mint}" ; done
1760708875
1760708875 https://21mint.me
1760708876 https://mint.minibits.cash/Bitcoin
1760708876 https://testnut.cashu.space
1760708876 https://8333.space:3338
1760708876 https://nofees.testnut.cashu.space
1760708877 https://mint.coinos.io

But then, I ran the same command multiple times in the following seconds. See that 21mint is not updating

$ date +%s ; for mint in https://21mint.me https://mint.minibits.cash/Bitcoin https://testnut.cashu.space https://8333.space:3338  https://nofees.testnut.cashu.space https://mint.coinos.io; do curl -s $mint/v1/info | jq .time | tr -d '\n'; echo " ${mint}" ; done
1760708984
1760708875 https://21mint.me
1760708985 https://mint.minibits.cash/Bitcoin
1760708985 https://testnut.cashu.space
1760708985 https://8333.space:3338
1760708986 https://nofees.testnut.cashu.space
1760708986 https://mint.coinos.io

Here there is 80 seconds of difference:

$ date +%s ; for mint in https://21mint.me https://mint.minibits.cash/Bitcoin https://testnut.cashu.space https://8333.space:3338  https://nofees.testnut.cashu.space https://mint.coinos.io; do curl -s $mint/v1/info | jq .time | tr -d '\n'; echo " ${mint}" ; done
1760709061
1760708875 https://21mint.me
1760709062 https://mint.minibits.cash/Bitcoin
1760709062 https://testnut.cashu.space
1760709062 https://8333.space:3338
1760709063 https://nofees.testnut.cashu.space
1760709063 https://mint.coinos.io
My latest update, I think 21mint is doing caching: First, all mints are synced with each other and with my laptop here: ``` $ date +%s ; for mint in https://21mint.me https://mint.minibits.cash/Bitcoin https://testnut.cashu.space https://8333.space:3338 https://nofees.testnut.cashu.space https://mint.coinos.io; do curl -s $mint/v1/info | jq .time | tr -d '\n'; echo " ${mint}" ; done 1760708875 1760708875 https://21mint.me 1760708876 https://mint.minibits.cash/Bitcoin 1760708876 https://testnut.cashu.space 1760708876 https://8333.space:3338 1760708876 https://nofees.testnut.cashu.space 1760708877 https://mint.coinos.io ``` But then, I ran the same command multiple times in the following seconds. See that 21mint is not updating ``` $ date +%s ; for mint in https://21mint.me https://mint.minibits.cash/Bitcoin https://testnut.cashu.space https://8333.space:3338 https://nofees.testnut.cashu.space https://mint.coinos.io; do curl -s $mint/v1/info | jq .time | tr -d '\n'; echo " ${mint}" ; done 1760708984 1760708875 https://21mint.me 1760708985 https://mint.minibits.cash/Bitcoin 1760708985 https://testnut.cashu.space 1760708985 https://8333.space:3338 1760708986 https://nofees.testnut.cashu.space 1760708986 https://mint.coinos.io ``` Here there is 80 seconds of difference: ``` $ date +%s ; for mint in https://21mint.me https://mint.minibits.cash/Bitcoin https://testnut.cashu.space https://8333.space:3338 https://nofees.testnut.cashu.space https://mint.coinos.io; do curl -s $mint/v1/info | jq .time | tr -d '\n'; echo " ${mint}" ; done 1760709061 1760708875 https://21mint.me 1760709062 https://mint.minibits.cash/Bitcoin 1760709062 https://testnut.cashu.space 1760709062 https://8333.space:3338 1760709063 https://nofees.testnut.cashu.space 1760709063 https://mint.coinos.io ```
SatsAndSports commented 2025-10-17 15:11:25 +00:00 (Migrated from github.com)

My coding agent thinks CDK is caching it:

Read(crates/cdk/src/wallet/mod.rs)
  ⎿  Read 30 lines (ctrl+o to expand)

● Ah! I see it now - line 319-321:

  self.localstore
      .add_mint(self.mint_url.clone(), Some(mint_info.clone()))
      .await?;

  The mint info IS being saved to local storage! This might mean subsequent calls could potentially use cached data. Let me check the add_mint implementation:
My coding agent thinks CDK is caching it: ``` Read(crates/cdk/src/wallet/mod.rs) ⎿  Read 30 lines (ctrl+o to expand) ● Ah! I see it now - line 319-321: self.localstore .add_mint(self.mint_url.clone(), Some(mint_info.clone())) .await?; The mint info IS being saved to local storage! This might mean subsequent calls could potentially use cached data. Let me check the add_mint implementation: ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo-admin/nuts#297
No description provided.