From d739fe3c1af2bb0ee3a5057f396c3262e5dce546 Mon Sep 17 00:00:00 2001 From: "Evgeny @ SimpleX Chat" <259188159+evgeny-simplex@users.noreply.github.com> Date: Tue, 29 Sep 2026 08:52:00 +0000 Subject: [PATCH] use deriveAddress, update simplexmq --- cabal.project | 2 +- scripts/nix/sha256map.nix | 2 +- src/Simplex/Chat/Wallet.hs | 10 +++------- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/cabal.project b/cabal.project index 8ad9440394..1f41997068 100644 --- a/cabal.project +++ b/cabal.project @@ -21,7 +21,7 @@ constraints: zip +disable-bzip2 +disable-zstd source-repository-package type: git location: https://github.com/simplex-chat/simplexmq.git - tag: bfd14f19d7fc293facd73a26c857a8c9fe2c51cd + tag: 0cbe3b81facade288f4cb4dc2465f70a4bc8117b source-repository-package type: git diff --git a/scripts/nix/sha256map.nix b/scripts/nix/sha256map.nix index db27570044..54c2ffed89 100644 --- a/scripts/nix/sha256map.nix +++ b/scripts/nix/sha256map.nix @@ -1,5 +1,5 @@ { - "https://github.com/simplex-chat/simplexmq.git"."bfd14f19d7fc293facd73a26c857a8c9fe2c51cd" = "04y9dhrn9l8bwyyk0cxq99zsaprj271yriqcc624jahrln7pckcv"; + "https://github.com/simplex-chat/simplexmq.git"."0cbe3b81facade288f4cb4dc2465f70a4bc8117b" = "1kj700rpnl0797mg7nn5a9kmqxlnpqdy41ffnwpdn30mcdlahfzx"; "https://github.com/simplex-chat/hs-socks.git"."a30cc7a79a08d8108316094f8f2f82a0c5e1ac51" = "0yasvnr7g91k76mjkamvzab2kvlb1g5pspjyjn2fr6v83swjhj38"; "https://github.com/simplex-chat/direct-sqlcipher.git"."f814ee68b16a9447fbb467ccc8f29bdd3546bfd9" = "1ql13f4kfwkbaq7nygkxgw84213i0zm7c1a8hwvramayxl38dq5d"; "https://github.com/simplex-chat/sqlcipher-simple.git"."a46bd361a19376c5211f1058908fc0ae6bf42446" = "1z0r78d8f0812kxbgsm735qf6xx8lvaz27k1a0b4a2m0sshpd5gl"; diff --git a/src/Simplex/Chat/Wallet.hs b/src/Simplex/Chat/Wallet.hs index 90b25dcbf6..4dfb37db97 100644 --- a/src/Simplex/Chat/Wallet.hs +++ b/src/Simplex/Chat/Wallet.hs @@ -15,8 +15,6 @@ module Simplex.Chat.Wallet where import Control.Concurrent.STM -import Control.Monad.Except -import Control.Monad.IO.Class (liftIO) import Crypto.Random (ChaChaDRG) import qualified Data.Aeson.TH as JQ import Data.Bifunctor (first) @@ -28,7 +26,7 @@ import qualified Simplex.Messaging.Crypto.BIP32 as B32 import qualified Simplex.Messaging.Crypto.BIP39 as B39 import Simplex.Messaging.Crypto.BIP44 (AccountIndex, CoinType (..), bip44Path) import qualified Simplex.Messaging.Crypto.Secp256k1 as S -import Simplex.Messaging.Eth.Address (Address, addressFromPrivateKey) +import Simplex.Messaging.Eth.Address (Address, deriveAddress) import Simplex.Messaging.Parsers (defaultJSON, dropPrefix, sumTypeJSON) type AccountKey = S.Secp256k1PrivateKey @@ -70,12 +68,10 @@ masterMnemonic :: B32.WalletMaster -> Text masterMnemonic = decodeLatin1 . B39.entropyPhrase . B32.masterEntropy deriveAccount :: TVar ChaChaDRG -> B32.WalletMaster -> AccountIndex -> IO (Either String (AccountKey, WalletAddress)) -deriveAccount g master n = runExceptT $ do - k <- B32.xkKey <$> ExceptT (B32.derivePath g (B32.walletMasterKey master) path) - a <- liftIO $ addressFromPrivateKey g k - pure (k, WalletAddress {accountIndex = n, keyPath = decodeLatin1 $ B32.renderPath path, address = a}) +deriveAccount g master n = fmap account <$> deriveAddress g (B32.walletMasterKey master) path where path = bip44Path Ethereum n + account (xk, a) = (B32.xkKey xk, WalletAddress {accountIndex = n, keyPath = decodeLatin1 $ B32.renderPath path, address = a}) accountSecret :: AccountKey -> Text accountSecret k = "0x" <> decodeLatin1 (BAE.convertToBase BAE.Base16 $ S.unPrivateKey k)