File tree Expand file tree Collapse file tree 3 files changed +13
-8
lines changed
test/unit/Cardano/Wallet/Api Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -149,7 +149,6 @@ import Cardano.Wallet.Primitive.Types
149149 , WalletBalance (.. )
150150 , WalletId (.. )
151151 , WalletName (.. )
152- , hashFromText
153152 , isValidCoin
154153 , unsafeEpochNo
155154 )
@@ -397,7 +396,7 @@ data ByronWalletFromXPrvPostData = ByronWalletFromXPrvPostData
397396 -- ^ A root private key hex-encoded, encrypted using a given passphrase.
398397 -- The underlying key should contain: private key, chain code, and public key
399398 , passphraseHash :: ! (ApiT (Hash " encryption" ))
400- -- ^ A hash of master passphrase. The hash should be a 64-byte output of a
399+ -- ^ A hash of master passphrase. The hash should be an output of a
401400 -- Scrypt function with the following parameters:
402401 -- - logN = 14
403402 -- - r = 8
@@ -685,7 +684,14 @@ instance ToText (ApiT XPrv) where
685684 . getApiT
686685
687686instance FromText (ApiT (Hash " encryption" )) where
688- fromText = fmap ApiT . hashFromText 64
687+ fromText txt = case convertFromBase Base16 $ T. encodeUtf8 txt of
688+ Right bytes -> Right $ ApiT $ Hash bytes
689+ Left _ -> textDecodingError
690+ where
691+ textDecodingError = Left $ TextDecodingError $ unwords
692+ [ " Invalid encrypted passphrase:"
693+ , " expecting a hex-encoded value."
694+ ]
689695
690696{- ------------------------------------------------------------------------------
691697 API Types: Byron
Original file line number Diff line number Diff line change @@ -1092,7 +1092,8 @@ instance Arbitrary ByronWalletFromXPrvPostData where
10921092 arbitrary = do
10931093 n <- arbitrary
10941094 rootXPrv <- ApiT . unsafeXPrv . BS. pack <$> vectorOf 128 arbitrary
1095- h <- ApiT . Hash . B8. pack <$> replicateM 64 arbitrary
1095+ bytesNumber <- choose (64 ,100 )
1096+ h <- ApiT . Hash . B8. pack <$> replicateM bytesNumber arbitrary
10961097 pure $ ByronWalletFromXPrvPostData n rootXPrv h
10971098
10981099instance Arbitrary SomeByronWalletPostData where
Original file line number Diff line number Diff line change @@ -270,15 +270,13 @@ x-walletPassphrase: &walletPassphrase
270270
271271x-walletPassphraseHash : &walletPassphraseHash
272272 description : |
273- A hash of master passphrase. The hash should be a 64-byte output of a Scrypt function with the following parameters:
273+ A hash of master passphrase. The hash should be an output of a Scrypt function with the following parameters:
274274 - logN = 14
275275 - r = 8
276276 - p = 1
277277 type : string
278278 format : hex
279- minLength : 128
280- maxLength : 128
281- example : 3be2ead8e3c3be2ea67c41a6e898ceecddeecd88585d11d15d8733f7ad1adbaf3c1570d8e3c67c41a6e898ceecddeecd88585d11d15d8733f7ad1adbaf3c1570
279+ example : 31347c387c317c574342652b796362417576356c2b4258676a344a314c6343675375414c2f5653393661364e576a2b7550766655513d3d7c2f376738486c59723174734e394f6e4e753253302b6a65515a6b5437316b45414941366a515867386539493d
282280
283281x-walletEncryptedRootPrivateKey : &walletEncryptedRootPrivateKey
284282 description : |
You can’t perform that action at this time.
0 commit comments