mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-01 06:29:16 +00:00
core: export the secret of a single name key
/_wallet export gives the seed mnemonic, /_wallet export <account> <name> gives the secret of one derived key, so a single name can be handed over without the seed. Both are what a wallet takes on import: the mnemonic as a recovery phrase, the secret as hex. The commands are named for what they return, APIWalletExportSeedMnemonic and APIWalletExportDerivedSecret, as the difference is which secret leaves the device. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rvc3HbiWBTqbAvRT45G5oX
This commit is contained in:
co-authored by
Claude Opus 5
parent
e7f5908d01
commit
db1b6413e0
@@ -17,11 +17,13 @@ module Simplex.Chat.Wallet
|
||||
deriveNameKey,
|
||||
renderNameKeyPath,
|
||||
accountAddress,
|
||||
accountSecret,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Concurrent.STM
|
||||
import Crypto.Random (ChaChaDRG)
|
||||
import qualified Data.ByteArray.Encoding as BAE
|
||||
import Data.ByteString (ByteString)
|
||||
import Data.Int (Int64)
|
||||
import Data.Text (Text)
|
||||
@@ -91,3 +93,7 @@ deriveNameKey s acc nm = do
|
||||
|
||||
accountAddress :: WalletAccount -> Address
|
||||
accountAddress = addressFromPrivateKey . waKey
|
||||
|
||||
-- | Hex, as wallets take it when a key is imported on its own.
|
||||
accountSecret :: WalletAccount -> ByteString
|
||||
accountSecret a = "0x" <> BAE.convertToBase BAE.Base16 (S.unPrivateKey $ waKey a)
|
||||
|
||||
Reference in New Issue
Block a user