ledger/utils.py
def parse_derivation(derivation_path: str) -> List[int]:
    '''
    turns a derivation path (e.g. m/44h/0) into a list of integer indexes
        e.g. [2147483692, 0]
    Args:
        derivation_path (str): the human-readable derivation path
    Returns:
        (list(int)): the derivaion path as a list of indexes
    '''
    int_nodes: List[int] = []

    # Must be / separated
    nodes: List[str] = derivation_path.split('/')
    # If the first node is not m, error.
    # TODO: allow partial path knowledge
    if nodes[0] != 'm':
        raise ValueError('Bad path. Got: {}'.format(derivation_path))
    if len(nodes) == 1:
        return []
    # Go over all other nodes, and convert to indexes
    nodes = nodes[1:]
    for i in range(len(nodes)):
        if nodes[i][-1] in ['h', "'"]:  # Support 0h and 0' conventions
            int_nodes.append(int(nodes[i][:-1]) + BIP32_HARDEN)
        else:
            int_nodes.append(int(nodes[i]))
    return int_nodes

    turns a derivation path (e.g. m/44h/0) into a list of integer indexes
        e.g. [2147483692, 0]
    Args:
        derivation_path (str): the human-readable derivation path
    Returns:
        (list(int)): the derivaion path as a list of indexes
    
turns a derivation path  into a list of integer indexes
e.g.
turns a derivation path into a list of integer indexes e . g .
def parse_derivation(derivation_path: str) -> List[int]:
    int_nodes: List[int] = []
    nodes: List[str] = derivation_path.split('/')
    if nodes[0] != 'm':
        raise ValueError('Bad path. Got: {}'.format(derivation_path))
    if len(nodes) == 1:
        return []
    nodes = nodes[1:]
    for i in range(len(nodes)):
        if nodes[i][-1] in ['h', "'"]:  
            int_nodes.append(int(nodes[i][:-1]) + BIP32_HARDEN)
        else:
            int_nodes.append(int(nodes[i]))
    return int_nodes
def parse_derivation ( derivation_path : str ) -> List [ int ] : int_nodes : List [ int ] = [ ] nodes : List [ str ] = derivation_path . split ( '/' ) if nodes [ 0 ] != 'm' : raise ValueError ( 'Bad path. Got: {}' . format ( derivation_path ) ) if len ( nodes ) == 1 : return [ ] nodes = nodes [ 1 : ] for i in range ( len ( nodes ) ) : if nodes [ i ] [ - 1 ] in [ 'h' , "'" ] : int_nodes . append ( int ( nodes [ i ] [ : - 1 ] ) + BIP32_HARDEN ) else : int_nodes . append ( int ( nodes [ i ] ) ) return int_nodes
turns a derivation path (e.g.
turns a derivation path ( e . g .
'''
    turns a derivation path (e.g. m/44h/0) into a list of integer indexes
        e.g. [2147483692, 0]
    Args:
        derivation_path (str): the human-readable derivation path
    Returns:
        (list(int)): the derivaion path as a list of indexes
    ''' # Must be / separated # If the first node is not m, error. # TODO: allow partial path knowledge # Go over all other nodes, and convert to indexes # Support 0h and 0' conventions
the derivaion path as a list of indexes
the derivaion path as a list of indexes
(list(int))
derivation_path
str
the human-readable derivation path
the human - readable derivation path