From 189fb7c5db038c131d0f8240dd759136db32aa3b Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Sat, 15 Oct 2022 00:58:49 +0200 Subject: [PATCH] force sorted dictionary for keyset calculation --- cashu/core/crypto.py | 4 +++- cashu/mint/startup.py | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cashu/core/crypto.py b/cashu/core/crypto.py index 3c8fb0e..3524281 100644 --- a/cashu/core/crypto.py +++ b/cashu/core/crypto.py @@ -38,7 +38,9 @@ def derive_pubkeys(keys: Dict[int, PrivateKey]): def derive_keyset_id(keys: Dict[int, PublicKey]): """Deterministic derivation keyset_id from set of public keys.""" - pubkeys_concat = "".join([p.serialize().hex() for _, p in keys.items()]) + # sort public keys by amount + sorted_keys = dict(sorted(keys.items())) + pubkeys_concat = "".join([p.serialize().hex() for _, p in sorted_keys.items()]) return base64.b64encode( hashlib.sha256((pubkeys_concat).encode("utf-8")).digest() ).decode()[:12] diff --git a/cashu/mint/startup.py b/cashu/mint/startup.py index 4cf2151..762533c 100644 --- a/cashu/mint/startup.py +++ b/cashu/mint/startup.py @@ -8,7 +8,6 @@ from loguru import logger from cashu.core.migrations import migrate_databases from cashu.core.settings import CASHU_DIR, LIGHTNING -# from cashu.lightning import WALLET from cashu.mint import migrations from cashu.mint.ledger import Ledger