mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-27 17:58:47 +00:00
core: the argument is a mnemonic, so name it one
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
443fd43545
commit
da20a039ae
@@ -66,12 +66,12 @@ at the profile level, while what a profile buys sits at the address level.
|
||||
Internal API. The names commands will call these; users will not.
|
||||
|
||||
```
|
||||
/_wallet the next name addresses
|
||||
/_wallet create new generate the seed
|
||||
/_wallet create seed=<phrase> take the seed from a phrase
|
||||
/_wallet export the seed mnemonic
|
||||
/_wallet export <name> one derived secret, as 0x and 64 hex digits
|
||||
/_wallet delete delete the seed
|
||||
/_wallet the next name addresses
|
||||
/_wallet create new generate the seed
|
||||
/_wallet create mnemonic=<phrase> take the seed from a mnemonic
|
||||
/_wallet export the seed mnemonic
|
||||
/_wallet export <name> one derived secret, as 0x and 64 hex digits
|
||||
/_wallet delete delete the seed
|
||||
```
|
||||
|
||||
Creating and importing are one command, because they differ only in where the
|
||||
|
||||
@@ -5584,7 +5584,7 @@ chatCommandP =
|
||||
"/_service_request " *> (APISendServiceRequest <$> A.decimal <* A.space <*> strP <*> optional (" timeout=" *> (realToFrac <$> A.double)) <*> optional (" sign_key=" *> strP) <* A.space <*> jsonP),
|
||||
"/_service_response " *> (APISendServiceResponse <$> A.decimal <* A.space <*> strP <* A.space <*> jsonP),
|
||||
"/_wallet create new" $> APIWalletCreate Nothing,
|
||||
"/_wallet create seed=" *> (APIWalletCreate . Just <$> textP),
|
||||
"/_wallet create mnemonic=" *> (APIWalletCreate . Just <$> textP),
|
||||
"/_wallet export " *> (APIWalletExportDerivedSecret <$> keyIndexP),
|
||||
"/_wallet export" $> APIWalletExportSeedMnemonic,
|
||||
"/_wallet delete" $> APIWalletDelete,
|
||||
|
||||
@@ -96,7 +96,7 @@ testWalletPersists ps = do
|
||||
|
||||
testWalletSharedByProfiles :: HasCallStack => TestParams -> IO ()
|
||||
testWalletSharedByProfiles ps = withNewTestChat ps "alice" aliceProfile $ \alice -> do
|
||||
alice ##> ("/_wallet create seed=" <> B.unpack testPhrase)
|
||||
alice ##> ("/_wallet create mnemonic=" <> B.unpack testPhrase)
|
||||
rows <- nameRows alice
|
||||
alice ##> "/create user alisa"
|
||||
showActiveUser alice "alisa"
|
||||
@@ -109,20 +109,20 @@ testWalletSharedByProfiles ps = withNewTestChat ps "alice" aliceProfile $ \alice
|
||||
|
||||
testWalletImport :: HasCallStack => TestParams -> IO ()
|
||||
testWalletImport ps = withNewTestChat ps "alice" aliceProfile $ \alice -> do
|
||||
alice ##> ("/_wallet create seed=" <> B.unpack testPhrase)
|
||||
alice ##> ("/_wallet create mnemonic=" <> B.unpack testPhrase)
|
||||
alice <## "m/44'/60'/0'/0/1 0x6Fac4D18c912343BF86fa7049364Dd4E424Ab9C0"
|
||||
alice <## "m/44'/60'/0'/0/2 0xb6716976A3ebe8D39aCEB04372f22Ff8e6802D7A"
|
||||
alice ##> "/_wallet export"
|
||||
alice <## B.unpack testPhrase
|
||||
alice ##> ("/_wallet create seed=" <> B.unpack testPhrase)
|
||||
alice ##> ("/_wallet create mnemonic=" <> B.unpack testPhrase)
|
||||
alice <## "bad chat command: this device already has a wallet key"
|
||||
-- a mistyped phrase says nothing about which word was wrong
|
||||
alice ##> ("/_wallet create seed=" <> B.unpack (B.unwords $ replicate 12 "abandon"))
|
||||
alice ##> ("/_wallet create mnemonic=" <> B.unpack (B.unwords $ replicate 12 "abandon"))
|
||||
alice <## "bad chat command: bad recovery phrase"
|
||||
|
||||
testWalletExportDerivedSecret :: HasCallStack => TestParams -> IO ()
|
||||
testWalletExportDerivedSecret ps = withNewTestChat ps "alice" aliceProfile $ \alice -> do
|
||||
alice ##> ("/_wallet create seed=" <> B.unpack testPhrase)
|
||||
alice ##> ("/_wallet create mnemonic=" <> B.unpack testPhrase)
|
||||
_ <- nameRows alice
|
||||
alice ##> "/_wallet export 1"
|
||||
alice <## "m/44'/60'/0'/0/1 0x6Fac4D18c912343BF86fa7049364Dd4E424Ab9C0 0x9a983cb3d832fbde5ab49d692b7a8bf5b5d232479c99333d0fc8e1d21f1b55b6"
|
||||
@@ -135,22 +135,22 @@ testWalletExportDerivedSecret ps = withNewTestChat ps "alice" aliceProfile $ \al
|
||||
|
||||
testWalletDelete :: HasCallStack => TestParams -> IO ()
|
||||
testWalletDelete ps = withNewTestChat ps "alice" aliceProfile $ \alice -> do
|
||||
alice ##> ("/_wallet create seed=" <> B.unpack testPhrase)
|
||||
alice ##> ("/_wallet create mnemonic=" <> B.unpack testPhrase)
|
||||
_ <- nameRows alice
|
||||
alice ##> "/_wallet delete"
|
||||
alice <## "no wallet key"
|
||||
alice ##> ("/_wallet create seed=" <> B.unpack testPhrase)
|
||||
alice ##> ("/_wallet create mnemonic=" <> B.unpack testPhrase)
|
||||
_ <- nameRows alice
|
||||
pure ()
|
||||
|
||||
testWalletImportThenRestore :: HasCallStack => TestParams -> IO ()
|
||||
testWalletImportThenRestore ps = withNewTestChat ps "alice" aliceProfile $ \alice -> do
|
||||
alice ##> ("/_wallet create seed=" <> B.unpack testPhrase)
|
||||
alice ##> ("/_wallet create mnemonic=" <> B.unpack testPhrase)
|
||||
_ <- nameRows alice
|
||||
-- restoring the database replaces the seed with what the backup held, which is nothing
|
||||
forgetSeed alice
|
||||
alice ##> "/_wallet"
|
||||
alice <## "no wallet key"
|
||||
alice ##> ("/_wallet create seed=" <> B.unpack testPhrase)
|
||||
alice ##> ("/_wallet create mnemonic=" <> B.unpack testPhrase)
|
||||
rows <- nameRows alice
|
||||
map fst rows `shouldBe` ["m/44'/60'/0'/0/1", "m/44'/60'/0'/0/2"]
|
||||
|
||||
Reference in New Issue
Block a user