def create_route_for_payment(self, *, amount_msat: int, invoice_pubkey: bytes, min_cltv_expiry: int, r_tags, invoice_features: int, channels: List[Channel], full_path: Optional[LNPaymentPath]) -> Tuple[(LNPaymentRoute, int)]:
    scid_to_my_channels = {chan.short_channel_id: chan for chan in channels if (chan.short_channel_id is not None)}
    private_route_edges = {}
    for private_path in r_tags:
        private_path_nodes = ([edge[0] for edge in private_path][1:] + [invoice_pubkey])
        private_path_rest = [edge[1:] for edge in private_path]
        start_node = private_path[0][0]
        for (end_node, edge_rest) in zip(private_path_nodes, private_path_rest):
            (short_channel_id, fee_base_msat, fee_proportional_millionths, cltv_expiry_delta) = edge_rest
            short_channel_id = ShortChannelID(short_channel_id)
            channel_policy = self.channel_db.get_policy_for_node(short_channel_id=short_channel_id, node_id=start_node, my_channels=scid_to_my_channels)
            if channel_policy:
                fee_base_msat = channel_policy.fee_base_msat
                fee_proportional_millionths = channel_policy.fee_proportional_millionths
                cltv_expiry_delta = channel_policy.cltv_expiry_delta
            node_info = self.channel_db.get_node_info_for_node_id(node_id=end_node)
            route_edge = RouteEdge(start_node=start_node, end_node=end_node, short_channel_id=short_channel_id, fee_base_msat=fee_base_msat, fee_proportional_millionths=fee_proportional_millionths, cltv_expiry_delta=cltv_expiry_delta, node_features=(node_info.features if node_info else 0))
            private_route_edges[route_edge.short_channel_id] = route_edge
            start_node = end_node
    try:
        route = self.network.path_finder.find_route(nodeA=self.node_keypair.pubkey, nodeB=invoice_pubkey, invoice_amount_msat=amount_msat, path=full_path, my_channels=scid_to_my_channels, private_route_edges=private_route_edges)
    except NoChannelPolicy as e:
        raise NoPathFound() from e
    if (not route):
        raise NoPathFound()
    if (not is_route_sane_to_use(route, amount_msat, min_cltv_expiry)):
        self.logger.info(f'rejecting insane route {route}')
        raise NoPathFound()
    assert (len(route) > 0)
    if (route[(- 1)].end_node != invoice_pubkey):
        raise LNPathInconsistent('last node_id != invoice pubkey')
    route[(- 1)].node_features |= invoice_features
    return route
def create_route_for_payment(self, *, amount_msat: int, invoice_pubkey: bytes, min_cltv_expiry: int, r_tags, invoice_features: int, channels: List[Channel], full_path: Optional[LNPaymentPath]) -> Tuple[(LNPaymentRoute, int)]:
    scid_to_my_channels = {chan.short_channel_id: chan for chan in channels if (chan.short_channel_id is not None)}
    private_route_edges = {}
    for private_path in r_tags:
        private_path_nodes = ([edge[0] for edge in private_path][1:] + [invoice_pubkey])
        private_path_rest = [edge[1:] for edge in private_path]
        start_node = private_path[0][0]
        for (end_node, edge_rest) in zip(private_path_nodes, private_path_rest):
            (short_channel_id, fee_base_msat, fee_proportional_millionths, cltv_expiry_delta) = edge_rest
            short_channel_id = ShortChannelID(short_channel_id)
            channel_policy = self.channel_db.get_policy_for_node(short_channel_id=short_channel_id, node_id=start_node, my_channels=scid_to_my_channels)
            if channel_policy:
                fee_base_msat = channel_policy.fee_base_msat
                fee_proportional_millionths = channel_policy.fee_proportional_millionths
                cltv_expiry_delta = channel_policy.cltv_expiry_delta
            node_info = self.channel_db.get_node_info_for_node_id(node_id=end_node)
            route_edge = RouteEdge(start_node=start_node, end_node=end_node, short_channel_id=short_channel_id, fee_base_msat=fee_base_msat, fee_proportional_millionths=fee_proportional_millionths, cltv_expiry_delta=cltv_expiry_delta, node_features=(node_info.features if node_info else 0))
            private_route_edges[route_edge.short_channel_id] = route_edge
            start_node = end_node
    try:
        route = self.network.path_finder.find_route(nodeA=self.node_keypair.pubkey, nodeB=invoice_pubkey, invoice_amount_msat=amount_msat, path=full_path, my_channels=scid_to_my_channels, private_route_edges=private_route_edges)
    except NoChannelPolicy as e:
        raise NoPathFound() from e
    if (not route):
        raise NoPathFound()
    if (not is_route_sane_to_use(route, amount_msat, min_cltv_expiry)):
        self.logger.info(f'rejecting insane route {route}')
        raise NoPathFound()
    assert (len(route) > 0)
    if (route[(- 1)].end_node != invoice_pubkey):
        raise LNPathInconsistent('last node_id != invoice pubkey')
    route[(- 1)].node_features |= invoice_features
    return route