@@ -411,12 +411,19 @@ def supported( cls, crypto ):
411411 for it, or raises an a ValueError. Eg. "ETH"/"Ethereum" --> "ETH"
412412
413413 """
414- validated = cls .CRYPTO_NAMES .get (
415- crypto .lower (),
416- crypto .upper () if crypto .upper () in cls .CRYPTO_SYMBOLS else None
417- )
418- if validated :
419- return validated
414+ try :
415+ validated = cls .CRYPTO_NAMES .get (
416+ crypto .lower (),
417+ crypto .upper () if crypto .upper () in cls .CRYPTO_SYMBOLS else None
418+ )
419+ if validated :
420+ return validated
421+ except Exception as exc :
422+ validated = exc
423+ raise
424+ finally :
425+ log .debug ( f"Validating { crypto !r} yields: { validated !r} " )
426+
420427 raise ValueError ( f"{ crypto } not presently supported; specify { commas ( cls .CRYPTOCURRENCIES )} " )
421428
422429 def __str__ ( self ):
@@ -865,39 +872,38 @@ def path_hardened( path ):
865872
866873
867874def cryptopaths_parser (
868- cryptocurrency ,
875+ cryptocurrency , # Or a cryptopaths list, eg. ["XRP",(ETH,"m/.."),(BTC,NONE,"segwit")]
869876 edit = None ,
870877 hardened_defaults = False ,
871878 format = None ,
872879):
873- """Generate a standard cryptopaths list, from the given sequnce of (<crypto>,<paths>) or
874- "<crypto>[:<paths>]" cryptocurrencies (default: CRYPTO_PATHS, optionally w/ only the hardened
875- portion of the path, eg. omitting the trailing ../0/0).
880+ """Generate a standard cryptopaths list, from the given sequnce of "<crypto>",
881+ (<crypto>,<paths>), (<crypto>,<paths>,<format>), or "<crypto>[:<paths>[:<format>:]"
882+ cryptocurrencies (default: CRYPTO_PATHS, optionally w/ only the hardened portion of the path,
883+ eg. omitting the trailing ../0/0).
876884
877885 Adjusts the provided derivation paths by an optional eg. "../-" path adjustment.
878886
879887 A non-default format may be specified, which may change the default HD derivation path. This
880888 must also be passed back, as it also affects the crypto's account's address format.
881889
882890 """
883- cryptopaths = []
884891 for crypto in cryptocurrency or CRYPTO_PATHS :
885- try :
886- if type ( crypto ) is str :
887- crypto , paths = crypto . split ( ':' ) # A sequence of str
888- else :
889- crypto , paths = crypto # A sequence of tuples
890- except ValueError :
891- crypto , paths = crypto , None
892- crypto = Account .supported ( crypto )
893- if paths is None :
894- paths = Account .path_default ( crypto , format )
892+ if type ( crypto ) is str :
893+ crypto = crypto . split ( ':' )
894+
895+ cry , * pth = crypto
896+ pth , * fmt = pth or ( None ,)
897+ fmt , = fmt or ( None ,)
898+
899+ cry = Account .supported ( cry )
900+ if not pth :
901+ pth = Account .path_default ( cry , fmt or format )
895902 if hardened_defaults :
896- paths ,_ = path_hardened ( paths )
903+ pth ,_ = path_hardened ( pth )
897904 if edit :
898- paths = path_edit ( paths , edit )
899- cryptopaths .append ( (crypto ,paths ,format ) )
900- return cryptopaths
905+ pth = path_edit ( pth , edit )
906+ yield (cry ,pth ,fmt )
901907
902908
903909def random_secret (
@@ -1217,9 +1223,9 @@ def accountgroups(
12171223 master_secret : Union [str ,bytes ],
12181224 cryptopaths : Optional [Sequence [Union [str ,Tuple [str ,str ],Tuple [str ,str ,str ]]]] = None , # default: ETH, BTC at default path, format
12191225 allow_unbounded : bool = True ,
1220- passphrase : Optional [Union [bytes ,str ]] = None , # If mnemonic(s) provided, then passphrase/using_bip39 optional
1226+ passphrase : Optional [Union [bytes ,str ]] = None , # If mnemonic(s) provided, then passphrase/using_bip39 optional
12211227 using_bip39 : bool = False ,
1222- format : Optional [str ] = None ,
1228+ format : Optional [str ] = None , # If the default format for every cryptopath isn't desired
12231229 edit : Optional [str ] = None ,
12241230 hardened_defaults : bool = False ,
12251231) -> Sequence [Sequence [Account ]]:
0 commit comments